This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
INPUT=`pwd` | |
OUTPUT=`pwd`'_upgrade' | |
NAME=`node -e "console.log(require('./package.json').name);"` | |
DEPENDENCIES=`node -e "console.log(Object.keys(require('./package.json').dependencies).join(' '));"` | |
DEV_DEPENDENCIES=`node -e "console.log(Object.keys(require('./package.json').devDependencies).join(' '));"` | |
rm -rf $OUTPUT | |
(cd /tmp && react-native init $NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.push = coroutine(function*(data, users){ | |
let params = { | |
MessageStructure: 'json', | |
Message: JSON.stringify({ | |
default: data.subject, | |
APNS: JSON.stringify(assign({ | |
aps: assign({alert: data.alert, sound: data.sound}, data.apns||{}), | |
},_.omit(data, 'alert', 'collapseKey', 'subject', 'apns', 'sound'))), | |
GCM: JSON.stringify({ | |
collapseKey: data.collapseKey, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set autoindent | |
set autoread " Make Vim automatically open changed files | |
set background=dark | |
" set cinoptions=:0,(s,u0,U1 | |
set clipboard=unnamed | |
set colorcolumn=120 | |
set columns=130 | |
set copyindent | |
set cursorline | |
set directory^=$HOME/.vim/swp// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const express = require('express'); | |
const app = express(); | |
const ewrap = f=>(...args)=>f(...args).catch(args[args.length-1]); | |
app.all('/test', ewrap(async (req, res)=>{ | |
await new Promise(function (resolve, reject) { | |
setTimeout(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const express = require('express'); | |
const app = (()=>{ | |
const ewrap = f=>{ | |
if (f.length>3) | |
return f; | |
return (req, res, next)=>(async ()=>f(req, res, next))().catch(next); | |
}; | |
let app = express(); | |
for (let fn of ['use', 'all', 'get', 'post', 'put', 'delete', 'head', 'options']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.use(async (req, res, next)=>{ | |
try { | |
req.user = await auth.validate(req); | |
} catch(err) { | |
if (...) | |
return res.json({error: 'user not found'}); | |
next(err); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PS1="\[\033]0;\w\007\]\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ " | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxBxDxCxegedabagacad | |
export LANG=en_US.UTF-8 | |
alias ls='ls -GFh' | |
alias rgrep='ag --vimgrep' | |
alias rfind='find . | grep -i' | |
alias tldr='tldr -t ocean' | |
alias sizes='du -hd1' | |
export NODE_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.DS_Store | |
*.swp | |
Podfile.lock | |
npm-debug.log* | |
node_modules | |
build/ | |
DerivedData/ | |
Pods/ | |
*.pbxuser | |
!default.pbxuser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const express = require('express'); | |
const axios = require('axios'); | |
let app = express(); | |
app.use('/test', (req, res, next)=>next('route'), (req, res)=>res.json({ok: true})); | |
app.listen(8080, async ()=>{ | |
let {data} = await axios.get('http://localhost:8080/test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/pdf', authenticated, async (req, res)=>{ | |
let browser = await puppeteer.launch(); | |
try { | |
let page = await browser.newPage(); | |
await page.goto(url.format({ | |
protocol: 'http:', | |
host: '127.0.0.1:3000', | |
pathname: '/', | |
query: req.query, | |
}), {waitUntil: 'networkidle'}); |
OlderNewer