Skip to content

Instantly share code, notes, and snippets.

View suyanhanx's full-sized avatar
🥦

Suyan suyanhanx

🥦
  • Shanghai,China
  • 23:07 (UTC +08:00)
View GitHub Profile
@dahlia
dahlia / lisp.rb
Created September 2, 2010 07:52
30 minutes Lisp in Ruby
# 30 minutes Lisp in Ruby
# Hong Minhee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
@Treeki
Treeki / TurnipPrices.cpp
Last active April 5, 2024 13:55
AC:NH turnip price calculator
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// munged from https://github.com/simontime/Resead
namespace sead
{
class Random
{
@dahjelle
dahjelle / pre-commit.sh
Created July 13, 2016 16:48
Pre-commit hook for eslint, linting *only* staged changes.
#!/bin/bash
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done
@yurydelendik
yurydelendik / !wasmllvm.md
Last active February 23, 2024 05:08
Using WebAssembly in LLVM

NOTE: the content is out-of-date. All development is moved to the https://github.com/yurydelendik/wasmception

Using WebAssembly in LLVM

Compiling

# locations, e.g.
export WORKDIR=~/llvmwasm; mkdir -p $WORKDIR
export INSTALLDIR=$WORKDIR
@linhmtran168
linhmtran168 / pre-commit-eslint
Last active February 6, 2024 12:28
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
// 2018.5.11更新: 减少了swap
function qSort(compare) {
var swap = (p1, p2) => {
var tmp = this[p1];
this[p1] = this[p2];
this[p2] = tmp;
}
var sortRange = (start, end) => {
var midValue = this[start];
var p1 = start + 1, p2 = end - 1;
@Zheaoli
Zheaoli / Jetbrains JVM Config
Last active July 27, 2022 05:37
This is a JVM config for Jetbrains IDE on my laptop(With i9 10th CPU and 64G RAM)
-Xms128m
-Xmx8182m
-XX:ReservedCodeCacheSize=512m
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:+UnlockExperimentalVMOptions -XX:+UseZGC
-XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5
-XX:+UnlockDiagnosticVMOptions -XX:-ZProactive
@buhichan
buhichan / bubu-form-antd.tsx
Last active December 30, 2020 09:04
model (rxjs) based form
import { Form, Col, Row, Button } from "antd"
import { FormItemProps } from "antd/lib/form"
import { useObservables } from "./use-observables"
import * as React from "react"
import { AbstractControl, ValidationInfo, FormControls, FormControlList } from "./model"
import { CloseOutlined, PlusOutlined, MinusOutlined } from "@ant-design/icons"
type FormItemRenderChildren<T, Meta> = (inputProps: { value?: T; onChange?: (v: T) => void }, behavior: Meta | null, err: ValidationInfo) => React.ReactNode
export function FormItem<T, Meta>({
@buhichan
buhichan / typescript-di.tsx
Last active October 19, 2020 11:11
A typescript DI solution with no need of reflect-metadata (and can also need no decorators, if you prefer it)
//Idea is borrowed from https://github.com/gnaeus/react-ioc
//Differences are:
//1. Does not require reflect-metadata
//2. Has an additional "useProvider" method
import * as React from "react"
export interface Disposable {
dispose?(): void
}