Skip to content

Instantly share code, notes, and snippets.

View eggfly's full-sized avatar
🎯
flutter-hacking

eggfly

🎯
flutter-hacking
  • Beijing
View GitHub Profile
@eggfly
eggfly / TypeErasureTest.kt
Created August 27, 2024 11:19
TypeErasure Interesting Code
package com.example;
import java.util.*;
public class TestErase {
public static class MyJsonObject implements Map<String, Object> {
@Override
public int size() {
return 0;
}
@eggfly
eggfly / LeibnizPi.kt
Created August 26, 2024 12:21
Interesting Pi Leibniz Algorithm in Kotlin
package com.test
import java.math.BigDecimal
import java.math.MathContext
import java.math.RoundingMode
import java.text.NumberFormat
fun divideBigDecimal(dividend: BigDecimal, divisor: BigDecimal, scale: Int): BigDecimal {
return dividend.divide(divisor, scale, RoundingMode.HALF_UP)
}
# Decompile
dtc -I dtb -O dts -o devicetree.dts /boot/dtb/<your_devicetree_file_name>.dtb
# Compile
dtc -I dts -O dtb devicetree.dts -o <your_devicetree_file_name>.dtb
# Merge with DTBO
fdtoverlay -i modified-base.dtb -o modified-full.dtb /boot/tegra194-p3668-all-p3509-0000-user-custom.dtbo
# DTS from fs
@eggfly
eggfly / file_upload_server.py
Last active June 4, 2024 11:21
A simple HTTP server that can receive file uploads.
from http.server import BaseHTTPRequestHandler, HTTPServer
import cgi
import os
UPLOAD_DIRECTORY = 'uploads'
class FileUploadHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
@eggfly
eggfly / MiniMax.ino
Created April 14, 2024 07:28
MiniMax.ino
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
// flash mode 要改dio
// 1. Replace with your network credentials
const char* ssid = " ";
const char* password = " ";
// 2. Replace with your OpenAI API key
@eggfly
eggfly / esp32_lv_test.py
Last active March 14, 2024 15:24
ESP32-MicroPython-LVGL-ILI9341-Test.py
from ili9XXX import ili9341
import lvgl as lv
from machine import Pin, PWM
def init_backlight(brightness):
frequency = 5000
duty_cycle = int(1023 * brightness)
led = PWM(Pin(21), frequency)
led.duty(duty_cycle)
@eggfly
eggfly / mini_mp3_radio_decoder.c
Created July 9, 2023 06:55 — forked from Flix01/mini_mp3_radio_decoder.c
Very basic single-file, plain C, openAL mp3 radio decoder
// gist made after this issue: https://github.com/mackron/dr_libs/issues/142
/*
The license refers to this single file.
Every included or linked library comes with its own license
===============================================================================
Public Domain (www.unlicense.org)
===============================================================================
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
@eggfly
eggfly / main.cpp
Created October 16, 2022 14:44 — forked from fffonion/main.cpp
Read Xiaomi Mijia temperature and humidity sensor 2 (LYWSD03MMC) from ESP32
#include <Arduino.h>
#include <BLEDevice.h>
BLEClient *pClient;
BLEScan *pBLEScan;
#define SCAN_TIME 10 // seconds
bool connected = false;
@eggfly
eggfly / pycurses.py
Created August 23, 2022 03:49 — forked from claymcleod/pycurses.py
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()
@eggfly
eggfly / main.cc
Created August 10, 2022 08:12
A demo of __builtin_frame_address()
#include <iostream>
void my_stack_trace(int max_depth) {
uintptr_t frame = (uintptr_t) __builtin_frame_address(0);
uintptr_t next;
while (max_depth--) {
next = *(uintptr_t *) frame;
frame = next;
std::cout << (void *) next << std::endl;
}