Skip to content

Instantly share code, notes, and snippets.


Bruce He HeGanjie

View GitHub Profile
HeGanjie / recur.clj
Last active Oct 3, 2021
CPS can't reduce the time complexity...
View recur.clj
(defn fac [n]
(if (zero? n) 1
(* n (fac (dec n)))))
(defn fac-t [n acc] ; n 1
(if (zero? n) acc
(recur (dec n) (* acc n))))
(defn fac-c [n f] ; n identity
HeGanjie / geo2screen.ts
Created Sep 11, 2021
View geo2screen.ts
import * as d3Scale from "d3-scale"
import _ from "lodash";
export interface MappingInfo {
onWindowSize: number[]
screenA: number[]
geoA: number[]
screenB: number[]
geoB: number[]
HeGanjie / tailwind.config.js
Last active Jul 12, 2021
tailwindcss with px2rem
View tailwind.config.js
module.exports = {
purge: ['./src/**/*.html', './src/**/*.tsx', './src/**/*.ts'],
darkMode: false, // or 'media' or 'class'
theme: {
// using px2rem, 1rem = 100px for 1920 screen
fontSize: {
"xs": "0.12rem",
"sm": "0.14rem",
"base": "0.16rem",
View android-flex.css
.flex {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
.flex.flex--reverse {
-webkit-box-orient: horizontal;
HeGanjie / document.ejs
Last active Dec 13, 2020
rem 全屏自适应逻辑,1080p下 1rem=100px
View document.ejs
<!doctype html>
<html style="font-size: 100px">
<meta charset="utf-8" />
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<% if (context.title != null) { %>
<title><%= context.title %></title>
<% } %>
HeGanjie / Drag PNG here.bat
Created Sep 12, 2014
bat for pngquant, auto cover original png file (DANGEROUS)
View Drag PNG here.bat
@echo off
set path=%~d0%~p0
"%path%pngquant.exe" --force --ext .png --verbose --ordered --speed=1 --quality=50-90 %1
HeGanjie / common-styled-component.jsx
Last active Feb 23, 2020
Allow you quickly style a div like this: <Box mg10x pd20y textCenter width300 itblock font20 color-white bold />
View common-styled-component.jsx
import styled from '@emotion/styled'
import _ from 'lodash'
const DirectDict = {
t: [0],
r: [1],
b: [2],
l: [3],
x: [1, 3],
View combination.js
// in: [['xxx'], ['yyy', 'zzz'], ...]
// out: [['xxx', 'yyy', ...], ['xxx', 'zzz', ...]]
function calcCombination(options) {
if (_.isEmpty(options)) {
return [[]]
let [firstOpt,] = options
let remainCombinations = calcCombination(rest)
return _.flatMap(remainCombinations, rc => {
return => [o1, ...rc])
ssh -L -R # limit for
watch -n0 busybox nc -l -p 3389 -e /bin/nc 8000 # have restart time gap
socat tcp-listen:443,reuseaddr,fork tcp:localhost:8080 # need install
# can not install socat, compile yourself?
HeGanjie /
Created Apr 23, 2018
quick run typescript
npx -p typescript -p ts-node -c "nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec 'ts-node' src/server/app.ts"
npm i ts-node --no-save
npx -p typescript -p ts-node -c 'node -r ts-node/register --inspect-brk src/server/app.ts'
npx webpack --progress