Skip to content

Instantly share code, notes, and snippets.

View nothingrealhappen's full-sized avatar
🏠
Working from home

NothingRealHappen nothingrealhappen

🏠
Working from home
  • Mars
View GitHub Profile
@nothingrealhappen
nothingrealhappen / utils.js
Created May 20, 2018 08:18
pageScript for turbolinks version
export const pageScript = (path, fn) => (...args) => {
$(document).on('turbolinks:load', () => {
const pageID = $('body').attr('id');
const map = {
string: () => pageID === path,
object: () => path.some(x => x === pageID)
};
const isAllow = map[typeof path]();
return isAllow ? fn(...args) : null;
});
@nothingrealhappen
nothingrealhappen / README.md
Created April 12, 2018 03:01
Submit form with jquery/vanillajs/form control
onSubmit event handler form action redirect(submit success to backend)
$.submit
$.trigger
HTMLFormElement.submit
...
@nothingrealhappen
nothingrealhappen / post.md
Last active May 9, 2018 05:46
Introduce to Y Combinator with Javascript
layout title date tags
title
Introduce to Y Combinator with Javascript
2018-03-24 15:46:19 -0700

梳理总结一下自己对 Y Combinator 理解,也来重新认识这样一个有趣的东西。

在开始之前有必要先来介绍一下图灵机λ演算之间的关系。

@nothingrealhappen
nothingrealhappen / post-checkout
Created February 20, 2017 06:21
auto update npm package when git submodule update
#!/bin/sh
# exit when checkout a file
[ "$3" == "0" ] && exit
cd gulp
echo "Checking npm modules"
npm ls > /dev/null && {
゚ω゚ノ= /`m´)ノ ~┻━┻ //*´∇`*/ ['_']; o=(゚ー゚) =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o -(゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];(゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];(゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\'; (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o];(゚Д゚) [゚o゚]='\"';(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+(゚Д゚)[゚o゚]+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o
@nothingrealhappen
nothingrealhappen / dianping.html
Last active August 10, 2016 08:17
点评区块样式
<section style="margin: 0 20px;">
<section style="height: 1.5em;">
<section style="height: 100%;width: 1.2em;float: left;border-top-width: 0.15em;border-top-style: solid;border-color: rgb(198, 198, 199);border-left-width: 0.15em;border-left-style: solid;"></section>
</section>
<section style="margin: -1.4em 0.1em; padding: 0.8em; box-sizing: border-box; color: rgb(131, 87, 87); background-color: #f3f3f3;" data-bgless="lighten" data-bglessp="15%">
<section style="color: #595651; font-size: 1em; line-height: 1.4; word-break: break-all; word-wrap: break-word; text-align: left;">
${text}
</section>
</section>
<section style="height: 1.5em; box-sizing: border-box;">
@nothingrealhappen
nothingrealhappen / iterm2.profile.json
Last active July 1, 2016 08:54
my iterm2 profile
{
"Working Directory" : "\/Users\/vanilla",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Red Component" : 0.8379544019699097,
"Color Space" : "Calibrated",
"Blue Component" : 0.8379434943199158,
"Alpha Component" : 1,
"Green Component" : 0.837929368019104
},
@nothingrealhappen
nothingrealhappen / use_find_server.js
Created June 29, 2016 09:18
find localnet server
const findServer = require('./find_server');
findServer({
pingKey: 'your pingkey in config.js',
port: '3001',
path: '/ping',
cb: ip => {
console.log(ip);
},
});
@nothingrealhappen
nothingrealhappen / install.sh
Created June 21, 2016 04:33
dotfile install script
#!/bin/bash
safe_link(){
local src="$1"
local dest="$HOME/`basename $src`"
[ ! -e "$dest" ] && ln -sf "$src" "$dest"
}
DOTFILES="/Users/x/Dropbox/dotfile/dotfiles"
@nothingrealhappen
nothingrealhappen / upload.js
Last active May 25, 2016 08:22
Crop avatar before upload to server
// import crop package
import crop from 'crop-image';
// input file onChange callback
this.upload = e => {
const files = e.target.files;
if (files && files[0]) {
const image = new Image();
image.onload = () => {