Skip to content

Instantly share code, notes, and snippets.

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 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 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 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 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
You can’t perform that action at this time.