Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
@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

@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 = [],
@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

@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
@kessler
kessler / install-node
Last active December 19, 2015 02:39
amazon ec2 node setup / install script
#!/bin/sh
NODE_BRANCH=v0.10.38-release
sudo yum install -y make git gcc-c++
echo 'sleeping for 2 seconds now...'
sleep 2
git clone https://github.com/joyent/node.git
cd node
@kessler
kessler / install-redis.sh
Last active December 19, 2015 02:28
install-redis.sh
sudo yum install gcc
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
sudo make install
sudo mkdir /etc/redis
sudo mkdir /var/redis
sudo cp redis.conf /etc/redis/6379.conf
@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active July 22, 2025 10:47
Backend Architectures Keywords and References