apt-get install python-pip
pip install shadowsocks
sudo ssserver -p 443 -k password -m aes-256-cfb --user nobody -d start
function iso7064Mod97_10(iban) { | |
var remainder = iban, | |
block; | |
while (remainder.length > 2){ | |
block = remainder.slice(0, 9); | |
remainder = parseInt(block, 10) % 97 + remainder.slice(block.length); | |
} | |
return parseInt(remainder, 10) % 97; |
# for development | |
pm2 start npm --name "next" -- run dev | |
# for production | |
npm run build | |
pm2 start npm --name "next" -- start | |
"scripts": { | |
"start": "node ./node_modules/.bin/pm2 start app.js -i max --attach" |
#!/usr/bin/env node | |
console.log('yay gist') |
When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).
When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.
Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.
So let's go through the one query that's worth memorizing to handle your eager loading.
Next.js, Nginx with Reverse proxy, SSL certificate
- UPDATE (07/20/2021):
- This process got simplified over the years of this gist being out
- Older version of this gist (without certbot): https://gist.github.com/kocisov/2a9567eb51b83dfef48efce02ef3ab06/33fdd88872a0801bdde58fccce430fa48737ae10
- I would also now recommend deploying to Vercel if you don't need custom server support
/* | |
INIT: ensure Babel/Eslint/Flow is configured for ES Class Fields & Static Properties | |
JSX USAGE: <Iframe src='http://web.site' onLoad={myOnloadFunction}/> | |
*/ | |
import React, { Component, PropTypes } from 'react' | |
import ReactDOM from 'react-dom' | |
class Iframe extends Component { | |
static propTypes: Object = { |
Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.
{ | |
"apps": [{ | |
"name": "Application", | |
"exec_interpreter": "./node_modules/babel-cli/bin/babel-node.js", | |
"script": "./bin/www", | |
"args": [], | |
"watch": ["public", "package.json", "pm2.development.json"], | |
"ignore_watch": ["public"], | |
"watch_options": { | |
"persistent": true, |
// quick snippet to check the connection in your RN app | |
// dispatches an `setIsConnected` action every time the NetInfo changes (on/off network) | |
componentDidMount() { | |
const dispatchConnected = isConnected => this.props.dispatch(setIsConnected(isConnected)); | |
NetInfo.isConnected.fetch().then().done(() => { | |
NetInfo.isConnected.addEventListener('change', dispatchConnected); | |
}); | |
} |