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 = ()=>{};
@suyanhanx
suyanhanx / resetVueData.ts
Created Apr 17, 2020
重置 Vue 组件的数据
View resetVueData.ts
/**
* 重置 Vue 组件的数据
* @param {Vue} instance
*/
export function resetVueData(instance: Vue): void {
Object.assign(instance.$data, (instance.$option.data as any).call(instance))
}
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,
@suyanhanx
suyanhanx / formatAmountCapitalized.js
Created Jul 4, 2019
formatAmountCapitalized 将金额数字转换成大写
View formatAmountCapitalized.js
export function formatAmountCapitalized(n) {
let fraction = ['角', '分'];
let digit = [
'零', '壹', '贰', '叁', '肆',
'伍', '陆', '柒', '捌', '玖'
];
let unit = [
['元', '万', '亿'],
['', '拾', '佰', '仟']
];
View js-sleep.js
function sleep(d){
for(var t = Date.now();Date.now() - t <= d;);
}
sleep(5000); //当前方法暂停5秒
View call.js
// 无root拉起钉钉打卡
var a = app.intent({
action: "VIEW",
data: "dingtalk://dingtalkclient/page/link?url=https://attend.dingtalk.com/attend/index.html"
});
app.startActivity(a);
//需要用到root权限 否则打不开
var TimeStamp = Math.round(new Date());
var corpId = ""; //自己想办法获取公司的ID ding开头的一串码
View gist:e754c0cc1c36e075afd6eaf88a6a1c6c
/* * { color: blue !important; } */
/* 隐藏滚动条*/
.xterm .xterm-viewport::-webkit-scrollbar {
display: none;
}
@suyanhanx
suyanhanx / JobjectExtension.c#
Last active Dec 10, 2018
transform a JObject to a Dictionary ( for IDictionary/IEnumerable)
View JobjectExtension.c#
using System;
using System.Linq;
using System.Collections.Generic;
/// <summary>
/// JObject扩展
/// </summary>
public static class JObjectExtensions
{
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 / pre-receive.go
Created Oct 28, 2018
a commit message check
View pre-receive.go
package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"regexp"
"strings"
)
You can’t perform that action at this time.