Skip to content

Instantly share code, notes, and snippets.

@spacious
spacious / gist:d8d90ce630904f04a61d84d120508298
Created April 23, 2018 19:12
Optimising NginX, Node.JS and networking for heavy workloads
https://engineering.gosquared.com/optimising-nginx-node-js-and-networking-for-heavy-workloads
# sysctl
https://github.com/spheromak/sysctl-cookbook
/etc/sysctl.conf
net.ipv4.ip_local_port_range='1024 65000'
net.ipv4.tcp_tw_reuse='1'
@spacious
spacious / Dog.js
Created December 5, 2015 21:46
JS prototype inheritance pattern examples
// https://medium.com/@PitaJ/javascript-inheritance-patterns-179d8f6c143c#.36nqv16pb
// Object.create, top-level factory, prototype post-declaration
function Animal(type){
var animal = Object.create(Animal.prototype);
animal.type = type;
return animal;
}
Animal.isAnimal = function(obj, type){
if(!Animal.prototype.isPrototypeOf(obj)){
@spacious
spacious / basic-lift.js
Last active November 11, 2015 19:07
basic lift
// code incomplete, example only
Just.prototype.ap = function(m) {
return m.map(this.value);
};
Nothing.prototype.ap = () => { return this }
function lift2(f, a1, a2){
@spacious
spacious / Sparse Login Example
Created October 11, 2013 21:22
Example of a login with Sparse
// This code would be on any PHP page handling the login form
// Create a User suitable for logging in
$loggingInUser = new \Sparse\User(array('username'=>$_POST['username'],'password'=>$_POST['password']));
// Make actual login API call
$loggingInUser->logIn();
// This will be true if it worked
if($loggingInUser->authenticated()){