Skip to content

Instantly share code, notes, and snippets.

View theJian's full-sized avatar
👾
Fighting space invaders

Tan Kian theJian

👾
Fighting space invaders
  • Anaemia Studios
  • The place where there is no darkness.
View GitHub Profile
let lowercase = 'abcdefghijklmnopqrstuvwxyz'
let uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
let numbers = '0123456789'
let punctuation = "<>`@#~!\"$%^&/()=+*-_.,;:?\\\'{}[] " " and space
for str in [lowercase, uppercase, numbers, punctuation]
for key in split(str, '\zs')
execute printf("noremap <silent> <buffer> <nowait> %s :call DO_SOMETHING_OR_NOTHING<cr>", key)
endfor
endfor
@theJian
theJian / README.md
Created December 10, 2017 13:48 — forked from HenrikJoreteg/README.md
Minimalist routing in Redux

Why would you want to do this? Because you often don't need more. It's nice to not have to think about your "router" as this big special thing.

Instead, with this approch, your app's current pathname is just another piece of state, just like anything else.

This also means that when doing server-side rendering of a redux app, you can just do:

var app = require('your/redux/app')
var React = require('react')
@theJian
theJian / what-forces-layout.md
Created August 17, 2017 03:00 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@theJian
theJian / foo.js
Last active September 23, 2016 09:48
foo.js
var res = {};
function traversal(item, pathNodes = []) {
if(typeof item !== 'object') {
res[pathNodes.join('.')] = item;
return ;
}
for(let x in item) {
traversal(item[x], pathNodes.concat(x));
}
@theJian
theJian / bash_tips.sh
Created September 14, 2016 15:05
bash tips
# last command
!!
# last command beginning with xyz
!xyz
# print rather than excuting last command
!!:p
# the end of previous command

Keybase proof

I hereby claim:

  • I am theJian on github.
  • I am thejian (https://keybase.io/thejian) on keybase.
  • I have a public key whose fingerprint is 6479 A388 C1D7 3960 EB52 AD38 F1A5 222F C4E2 F99C

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am theJian on github.
  • I am thejian (https://keybase.io/thejian) on keybase.
  • I have a public key whose fingerprint is 6479 A388 C1D7 3960 EB52 AD38 F1A5 222F C4E2 F99C

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am theJian on github.
  • I am thejian (https://keybase.io/thejian) on keybase.
  • I have a public key whose fingerprint is 6479 A388 C1D7 3960 EB52 AD38 F1A5 222F C4E2 F99C

To claim this, I am signing this object:

@theJian
theJian / .js
Created March 7, 2016 13:08
pass arguments to callback function
function callback(a, b) {
return function() {
console.log('sum = ', (a+b));
}
}
var x = 1, y = 2;
document.getElementById('someelem').addEventListener('click', callback(x, y));
@theJian
theJian / ss-install.md
Created February 12, 2016 15:18 — forked from aa65535/ss-install.md
shadowsocks-libev install at Debian or CentOS

Debian

cd /tmp
# 下载源码
git clone https://github.com/madeye/shadowsocks-libev.git
# 开始编译
cd shadowsocks-libev
./autogen.sh
./configure --prefix=/usr && make
make install