Skip to content

Instantly share code, notes, and snippets.

; supervisor config file
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
chmod=0700 ; socket file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
; supervisor config file
;[unix_http_server]
;file=/var/run/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
[supervisord]
function flatten(arr) {
return arr.reduce( (flat, toFlatten) => {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
console.log( flatten([[1,2,[3]],4]) );

Instagram API

Authorise to obtain authorisation code

https://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=code&scope=[basic+likes+relationships]

Obtain access token via cURL

curl -F 'client_id=[client_id]' -F 'client_secret=[client_secret]' -F 'grant_type=authorization_code' -F 'redirect_uri=[redirect_uri]' -F 'code=[authorisation_code]' https://api.instagram.com/oauth/access_token

# Recursively iterate through folder
#!/bin/bash
FOLDER = ~/Desktop/Folder
for file in $(find $FOLDER -name '*.mp4'); do
echo $file # will print the full path
echo ${file##*/} # will print the filename
echo dirname $file
done

Haproxy

sudo nano /etc/haproxy/haproxy.cfg // edit configuration file
haproxy -f /etc/haproxy/haproxyconf.txt -c // check configuration
haproxy -f /etc/haproxy/haproxy.cfg // run

Markdown

Images

Alt text 

nginx

sudo service nginx restart // restart service

Configuration file: /etc/nginx/sites-available

Symlink conf file: ln -s /etc/nginx/sites-available/eg.conf /etc/nginx/sites-enabled/eg.conf

Redis

redis-server // start redis
redis-cli // start redis CLI

Rails

gem install bundler // install bundle
rvm osx-ssl-certs update all //Update RVM certifcates

Rails Routing Guide

HTTP Verb Path Controller#Action Used for
GET /photos photos#index display a list of all photos
GET /photos/new photos#new return an HTML form for creating a new photo
POST /photos photos#create create a new photo