Skip to content

Instantly share code, notes, and snippets.

View chenyong's full-sized avatar
💭
Debugging TypeScript...

ChenYong chenyong

💭
Debugging TypeScript...
View GitHub Profile
#000
#000000
#101010
#108ee9
#1279d8
#184478
#1890ff
#1a90ff
#238FF3
@chenyong
chenyong / keybindings.json
Created June 9, 2020 08:10
Sublime Text keybindings to disable wrapping indented blocks
[
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|$)", "match_all": true }
]
},
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{${0:$SELECTION}}"}, "context":
[
@chenyong
chenyong / failure.md
Last active May 20, 2020 03:38
Router code generated.
  let routerTree = parseRoutePath(window.location.hash.slice(1), routerRules); // ->> IRouteParseResult

  ReactDOM.render(<Container router={routerTree as any} />, document.querySelector(".app"));
let Container: FC&lt;{ router: GenRouterTypeMain }&gt; = React.memo((props) =&gt; {
@chenyong
chenyong / base.text
Created January 6, 2020 06:33
Turned out query-string is smaller than qs.
=>> du -ah dist/
4.0K dist//index.html
4.0K dist//main.77549c57.js
8.0K dist/
@chenyong
chenyong / repos.text
Created December 20, 2019 02:47
Sort Github languages by repos, generated with https://github.com/Cirru/repos-rank
0 8413518 JavaScript
1 6892376 Java
2 5856934 HTML
3 4526268 Python
4 2521744 Ecere Projects
5 2299768 PHP
6 2211079 CSS
7 1965206 C#
8 1864343 C++
9 1795196 Ruby
@chenyong
chenyong / bug.edn
Last active December 18, 2019 15:21
Cirru EDN Bug
{
:a {:a 1}
:b 1, :c 1
}
@chenyong
chenyong / gen-types.ts
Created October 22, 2019 04:54
Generation of router types(Drafted by hand)
/*
a
b
c/:cid
d/:did
e?f
g/:gid?h
*/
@chenyong
chenyong / find.coffee
Created September 11, 2019 08:02
temp script for find out deps
fs = require 'fs'
_ = require 'lodash'
data = JSON.parse fs.readFileSync 'data.text', 'utf8'
dict = data.map (list) ->
[list[0], list[1..].flat() ]
@chenyong
chenyong / dropdown-area.tsx
Created September 3, 2019 06:49
Dropdown area component with mostly DOM operations. It works but has quite some drawbacks.
import { h, FunctionComponent, VNode, render } from "preact";
import { css } from "emotion";
import { useState, useRef, useEffect, useLayoutEffect } from "preact/hooks";
import { timeout } from "../util/time";
interface IPosition {
left?: number;
right?: number;
top?: number;
bottom?: number;
@chenyong
chenyong / markup.tsx
Created June 25, 2019 11:21
Immer Form solution
<LabeledField label={lingual.event} showRequired={false}>
<EventDropdown
placeholder={lingual.pleaseSelect}
notFoundContent={lingual.pleaseSelect}
onDeselect={() => {
this.changeField("event", null);
}}
value={form.event}
onChange={(value) => {
this.changeField("event", value);