Skip to content

Instantly share code, notes, and snippets.

Avatar
🍑
be sweet

Suyan suyanhanx

🍑
be sweet
View GitHub Profile
@suyanhanx
suyanhanx / get_free_vars.ts
Created Aug 27, 2020 — forked from buhichan/get_free_vars.ts
js get free variables hack
View get_free_vars.ts
/**
* some insane hack, just want to avoid using expensive parser.
*/
export function getFreeVariables(expr:string, knownSymbols:Record<string,unknown>){
const freeVariables = new Set<string>();
//eslint-disable-next-line
const anyThingPrimitive = ()=>{};
View hook-form.tsx
import * as React from "react"
import { BehaviorSubject } from 'rxjs';
const ERROR_DETAIL = Symbol("errors")
const HAS_ERROR = Symbol("has error")
const InternalSymbolKeys = [ERROR_DETAIL,HAS_ERROR]
enum FieldType {
arrayItem,
View pack.js
/**
* @file 在内存中打包 zip 文件的类,需要设置 `/var/run/${namespace}` 的权限为777
* @author o.o@mug.dog
*/
import * as fs from 'fs';
import * as path from 'path';
import * as mkdirp from 'mkdirp';
import * as archiver from 'archiver';
import * as copydir from 'copy-dir';
@suyanhanx
suyanhanx / eslint-pushed-changes.sh
Created Oct 20, 2018 — forked from stalniy/eslint-pushed-changes.sh
ESLINT + pre-receive git hook
View eslint-pushed-changes.sh
#!/bin/bash
TEMPDIR=`mktemp -d`
ESLINTRC=$TEMPDIR/.eslintrc
COMMAND="eslint --color -c $ESLINTRC --rule 'import/no-unresolved: 0' --rule 'import/no-duplicates: 0' --rule 'import/export: 0'"
git show HEAD:.eslintrc > $ESLINTRC
echo "### Ensure changes follow our code style... ####"
# See https://www.kernel.org/pub/software/scm/git/docs/githooks.html#pre-receive
@suyanhanx
suyanhanx / eslint-pushed-changes.sh
Created Oct 20, 2018 — forked from stalniy/eslint-pushed-changes.sh
ESLINT + pre-receive git hook
View eslint-pushed-changes.sh
#!/bin/bash
TEMPDIR=`mktemp -d`
ESLINTRC=$TEMPDIR/.eslintrc
COMMAND="eslint --color -c $ESLINTRC --rule 'import/no-unresolved: 0' --rule 'import/no-duplicates: 0' --rule 'import/export: 0'"
git show HEAD:.eslintrc > $ESLINTRC
echo "### Ensure changes follow our code style... ####"
# See https://www.kernel.org/pub/software/scm/git/docs/githooks.html#pre-receive