Skip to content

Instantly share code, notes, and snippets.

@kessler
kessler / linux net settings
Created July 31, 2013 15:09
linux net settings
echo ec2-user soft nofile 999999 >> /etc/security/limits.conf
echo ec2-user hard nofile 999999 >> /etc/security/limits.conf
echo root soft nofile 999999 >> /etc/security/limits.conf
echo root hard nofile 999999 >> /etc/security/limits.conf
echo net.core.rmem_max = 33554432 >> /etc/sysctl.conf
echo net.core.wmem_max = 33554432 >> /etc/sysctl.conf
echo net.ipv4.tcp_rmem = 4096 16384 33554432 >> /etc/sysctl.conf
echo net.ipv4.tcp_wmem = 4096 16384 33554432 >> /etc/sysctl.conf
echo net.ipv4.tcp_mem = 786432 1048576 26777216 >> /etc/sysctl.conf
@branneman
branneman / better-nodejs-require-paths.md
Last active June 24, 2025 22:40
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@ndhu
ndhu / phantomjsGoogleSearch
Created January 8, 2014 23:02
phantomjs. example on how to search google, collect links of search result and scrape multiple pages of the search result
/**
* Created by andy hulstkamp
*/
var webpage = require("webpage"),
fs = require("fs");
var debug = false,
pageIndex = 0,
allLinks = [],
@twokul
twokul / hidden-classes-in-js-and-inline-caching.md
Last active August 18, 2025 13:08
Hidden classes in JavaScript and Inline Caching

Hidden classes in JavaScript and Inline Caching

Knowing how internals work is always a good. Pretty much for everything. Cars, trains, computers, you name it. It gives you an insight on what happens under the hood. You also act/react differently based on this knowledge.

As you might have guessed, it’s also true for web development. Knowledge of CSS transitions allows you to achieve better performance and not to use JavaScript in most cases. Knowledge of V8 internals allows you to write more performant JavaScript code. So let’s talk about V8 a little.

A little about V8

V8 is a JavaScript engine built by Google. Firefox built SpiderMonkey, Opera built Carakan and Microsoft built Chakra. One very important difference between V8 and other JavaScript engines is that V8 doesn’t generate any intermediate code. It compiles JavaScr

@kessler
kessler / sub
Last active September 14, 2017 21:42
launch sublime text from terminal with current directory or with argument
#!/bin/sh
sub="/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
target=$1
if [[ -z $target ]]
then
target=$(pwd)
fi
@kessler
kessler / iptables_off
Created June 28, 2014 16:46
iptables off
#!/bin/sh
sudo /etc/init.d/iptables save
sudo /etc/init.d/iptables stop
sudo chkconfig iptables off
sudo /etc/init.d/ip6tables save
sudo /etc/init.d/ip6tables stop
sudo chkconfig ip6tables off
@kessler
kessler / node_timers_example1.js
Created July 4, 2014 15:00
simple node.js timers examples
setTimeout(function() {
console.log('queue a print AFTER a second')
}, 1000)
setInterval(function() {
console.log('queue a print EVERY second')
}, 1000)
setImmediate(function() {
console.log('queue a print in the next event loop tick but after IO tasks are done')
@kessler
kessler / async_recursion_example.js
Created July 4, 2014 15:07
async recursion example
var count = 0
var countWithDelay = 0
function recurse() {
console.log('recurse: %d', count)
if (count++ === 100) return
setImmediate(recurse)
}
@kessler
kessler / awsNodeBase.sh
Last active August 29, 2015 14:03
aws node base
echo "downloading scripts"
curl https://gist.githubusercontent.com/kessler/6122814/raw/002f1f919b937fd067a36f1a3b47050e4a3645e4/linux%20net%20settings > netchakra.sh
chomd +x netchakra.sh
curl https://gist.githubusercontent.com/kessler/5885063/raw/38f201ff740b25782bc04d3af11b4f3823478b4d/install-node > install-node.sh
chmod +x install-node.sh
curl https://gist.githubusercontent.com/kessler/6412374/raw/7b088bbeaf36ac845a6c2b6950d0e9f4d8d2d6b8/install-zeromq > install-zmq.sh
chmod +x install-zmq.sh
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active June 23, 2025 13:24
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront