Skip to content

Instantly share code, notes, and snippets.

View zen0wu's full-sized avatar
⌨️
Smashing Keyboard

Zeno Wu zen0wu

⌨️
Smashing Keyboard
View GitHub Profile
@zen0wu
zen0wu / action.yaml
Created May 28, 2021 22:18
Custom composite cache actions on github actions
name: Cache (v2)
description: >
Cache files onto S3 bucket. It has 3 steps:
1. It tries to restore the cache using the given key.
If the caches hits, exit.
2. It runs the given script using shell, if the cache missed in step 1.
3. It saves to the cache after the script.
inputs:
s3-bucket:
function errorPromise() {
return new Promise((_resolve, _reject) => {
console.log('error coming up');
throw new Error('oops');
});
}
function okPromise() {
return new Promise((_resolve, _reject) => {
console.log('ok');
@zen0wu
zen0wu / build.gradle.kts
Created February 23, 2019 01:57
Kotlin + Gradle + JVM with JS project setup
plugins {
`java-library`
id("kotlin-multiplatform") version "1.3.21"
}
allprojects {
group = "xxx"
version = "1.0.0-SNAPSHOT"
}
@zen0wu
zen0wu / lmdb_bench.c
Created October 22, 2018 04:46
LMDB random vs seq write
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <lmdb.h>
@zen0wu
zen0wu / .c
Created October 22, 2018 04:46
LMDB seq vs random write
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <lmdb.h>
@zen0wu
zen0wu / .c
Created October 22, 2018 04:45
LMDB seq vs random write
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <lmdb.h>
class HList {
static hnil(): HNil {
return HNil.instance;
}
static hcons<V, Next extends HList>(value: V, next: Next) {
return new HCons<V, Next>(value, next);
}
}
class HNil extends HList {
static readonly instance = new HNil();
function invertTable(t)
local res = {}
for k, v in pairs(t) do
res[v] = k
end
return res
end
local capsMap = {
-- Arrow keys
{
val $u: `package`.this.universe.type = `package`.this.universe;
val $m: $u.Mirror = `package`.this.universe.runtimeMirror(this.getClass.getClassLoader);
$u.Expr.apply($m, {
final class $treecreator1 extends TreeCreator {
def apply[U >: Nothing <: Universe with Singleton]($m$untyped: Mirror[U]): (U)#Tree = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.Literal($u.Constant(3))
}
@zen0wu
zen0wu / java-utf8.sh
Created September 30, 2012 12:31
Add this to your .profile or .bashrc to fuck things up with java & UTF-8
alias javac='javac -J-Dfile.encoding=UTF8'
alias java='java -Dfile.encoding=UTF8' # What the fuck is this!!! Why should I do this!!! How stupid is JAVA!!!