Skip to content

Instantly share code, notes, and snippets.

View yihuang's full-sized avatar
🏠
Working from home

yihuang yihuang

🏠
Working from home
  • Shenzhen, China
  • 14:30 (UTC -12:00)
View GitHub Profile
@yihuang
yihuang / class.lua
Created December 27, 2015 12:55 — forked from jzrake/class.lua
Partial implementation of the Python class model for Lua
--------------------------------------------------------------------------------
--
-- Partial implementation of the Python class model for Lua
--
-- Copyright (c) 2012, Jonathan Zrake
--
--------------------------------------------------------------------------------
--
-- Exports the following functions:
--
@yihuang
yihuang / test-lua-intf.cpp
Created December 28, 2015 15:07
lua-intf test
#include "LuaIntf/LuaIntf.h"
extern "C" {
#include "lua.h"
}
using namespace LuaIntf;
void test(char* s) {
}
#include "LuaIntf/LuaIntf.h"
extern "C" {
#include "lua.h"
}
using namespace LuaIntf;
void open(lua_State* L) {
LuaBinding(L)
.addConstant("GL_ES_VERSION_2_0", 1)
@yihuang
yihuang / lua-intf-return-pointer.cpp
Created January 1, 2016 10:13
test lua intf, return pointer.
#include "LuaIntf/LuaIntf.h"
using namespace LuaIntf;
void* test_malloc(int n) {
return malloc(n);
}
void test_free(void* p) {
free(p);
}
@yihuang
yihuang / curl_multi_work_with_libuv.lua
Created December 26, 2017 06:11
lua curl multi api work with libuv.
local uv = require_uv()
-- run uv event loop in engine loop.
return RunLoop.schedule(function()
uv.run('nowait')
end, 0.02, 0.02)
local multi = curl.multi()
local function check_info()
@yihuang
yihuang / chinese_recovery_phase.hs
Created January 21, 2018 17:15
Use chinese character as recovery phase for daedalus wallet.
#!stack runhaskell
import Data.List(elemIndex)
import System.Environment(getArgs)
wl_en :: [String]
wl_en =
[ "abandon", "ability", "able", "about", "above", "absent"
, "absorb", "abstract", "absurd", "abuse", "access", "accident"
, "account", "accuse", "achieve", "acid", "acoustic", "acquire"
, "across", "act", "action", "actor", "actress", "actual"
@yihuang
yihuang / reflection-tutorial.hs
Created May 12, 2018 20:28
Minimal demo for Data.Reflection usage.
{-# LANGUAGE FlexibleContexts, RecordWildCards, ConstraintKinds #-}
import System.Environment
import Data.Reflection
newtype Config = Config{
cfgCount :: Int
}
type HasConfig = Given Config
@yihuang
yihuang / gist:358e0b1944e8c0cac204d20eb6efd35e
Last active May 30, 2018 05:38
cardano-wallet-swagger_v1.json
{"swagger":"2.0","info":{"version":"cardano-sl:1","title":"Cardano Wallet API","license":{"url":"https://raw.githubusercontent.com/input-output-hk/cardano-sl/develop/lib/LICENSE","name":"MIT"},"description":"This is the specification for the Cardano Wallet API, automatically generated as a [Swagger](https://swagger.io/) spec from the [Servant](http://haskell-servant.readthedocs.io/en/stable/) API of [Cardano](https://github.com/input-output-hk/cardano-sl).\n\nSoftware Version | Git Revision\n-------------------|-------------------\ncardano-sl:1 | c3a292fee627bc9e76bb5b4896df59471a4dbdc4\n\n> **Warning**: This version is currently a **BETA-release** which is still under testing before\n> its final stable release. Should you encounter any issues or have any remarks, please let us\n> know; your feedback is highly appreciated.\n\n\nGetting Started\n===============\n\nIn the following examples, we will use *curl* to illustrate request to an API running on the default port **8090**.\n\nPlease note that wallet web
@yihuang
yihuang / cardano-v1-api-demo.py
Created May 30, 2018 06:53
Demonstrate use cardano v1 api to receive funds.
from pyswagger import App, Security
from pyswagger.contrib.client.requests import Client
from pyswagger.primitives import Primitive, create_str, validate_str
from mnemonic import Mnemonic
def validate_hex_base16(obj, ret, val, ctx):
print('validate', val)
return val
prim = Primitive()
@yihuang
yihuang / gadt-and-partial-function.hs
Last active May 10, 2019 18:06
gadt and partial function
{-# LANGUAGE GADTs, KindSignatures, DataKinds #-}
module Test where
data Test =
Test1 { test1 :: Int }
| Test2 { test2 :: Int }
data TestBranch = TTest1 | TTest2
data Test' (a :: TestBranch) where
Test'1 :: { test'1 :: Int } -> Test' TTest1