Skip to content

Instantly share code, notes, and snippets.

View supervisor.conf
; 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
View flatten.js
function flatten(arr) {
return arr.reduce( (flat, toFlatten) => {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
console.log( flatten([[1,2,[3]],4]) );
View Instagram API.md

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

View iterate-folder.sh
# 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
View haproxy.md

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

View nginx.md

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

View redis.md

Redis

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

View rails.md

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
View rust.md

Rust

Rust setup

I'm using Atom (on a fairly speedy machine, VS Code has some solid plugin support too) with:

  • atom-beautify (with rustfmt installed, cargo install rustfmt) * language-rust * linter + linter-rust (using cargo check, cargo install cargo-check) * you-complete-me (but YCM is not fun to install, so I'd recommend the racer plugin, both require the Rust source cloned and installed somewhere)

1.\ You need to cargo install racer and add the bin to your path
2.\ Clone the Rust source of your version of Rust, and add that to your path
3.\ Install the plugin and set the paths in Atom

You can’t perform that action at this time.