Skip to content

Instantly share code, notes, and snippets.

@yuanotes
yuanotes / godot_reload_debugger.js
Created October 20, 2020 16:35
This script enabls godot client listen to file modifications by external editors
const net = require('net');
const fs = require('fs');
const reloadCMD = "\x20\x00\x00\x00\x13\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00\x0e\x00\x00\x00reload_scripts\x00\x00"
// start godot client at first /Applications/Godot.app/Contents/MacOS/Godot -d --remote-debug 127.0.0.1:8008
const port = 8008;
const server = net.createServer();
@yuanotes
yuanotes / gist:2bcd7bcc7a30e51a7ce5e956766be8b3
Created February 14, 2019 08:43
blockstack id verification
Verifying my Blockstack ID is secured with the address 1LBRU2Pu2jQfXqVELfP3VyfunRDXDZoydb https://explorer.blockstack.org/address/1LBRU2Pu2jQfXqVELfP3VyfunRDXDZoydb
@yuanotes
yuanotes / blockchain.py
Created January 17, 2018 15:43
A simple blockchain implemented with python.
# -*- coding: utf-8 -*-
"""
A simple blockchain.
"""
import sys
import requests
import hashlib
import json
from urllib.parse import urlparse
from time import time
@yuanotes
yuanotes / browser.js
Last active December 22, 2017 08:03
Detect browser with UA in China
const ua = navigator.userAgent.toLowerCase();
export function isWechat() {
return /micromessenger/i.test(ua);
}
export function isAndroid() {
return /android/i.test(ua);
}
@yuanotes
yuanotes / min-char-rnn.py
Created June 12, 2017 15:25 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@yuanotes
yuanotes / resp2csv.py
Created August 21, 2016 08:32
Process elastic search json result to csv.
# coding=utf-8
import re
import os.path
import sys
import json
PATH = os.path.dirname(os.path.abspath(__file__))
def get_file_name(name):
@yuanotes
yuanotes / hidpi.txt
Created January 9, 2016 14:57 — forked from simX/hidpi.txt
Enable HiDPI mode in Mountain Lion w/o Quartz Debug
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@yuanotes
yuanotes / console.js
Created November 3, 2015 10:44
A helper script for playing http://minmaxia.com/basic/
function hackElement(el){
var priceText = el.getElementsByTagName("tr")[0].getElementsByTagName("td")[1].innerText.replace(/[,$]/g, "");
var tickText = el.getElementsByTagName("tr")[1].getElementsByTagName("td")[1].innerText.replace(/,/g, "");
if (priceText === "" || tickText === "") {
return;
}
var price = parseInt(priceText);
var tick = parseInt(/(\d+)\/tick/.exec(tickText)[1]);
var value = price/tick;
var tbody = el.getElementsByTagName("tbody")[0];
@yuanotes
yuanotes / png2svg.sh
Last active April 8, 2024 18:57
Convert png to svg.
#!/bin/bash
if [ "$1" == "" ]; then
echo Usage: $0 pngfile
exit 0
fi
FILE=`basename $1 .png`
if [ ! -e $FILE.png ]; then
@yuanotes
yuanotes / main.nim
Created June 24, 2015 12:54
Nim with IUP
from iup import nil
from os import nil
when isMainModule:
discard iup.open(nil, nil)
iup.show(iup.dialog(iup.label("Hello, world!")))
iup.mainLoop()
iup.close()