This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster'); | |
var http = require('http'); | |
var numCPUs = require('os').cpus().length; | |
if (cluster.isMaster) { | |
// Fork workers. | |
for (var i = 0; i < numCPUs; i++) { | |
cluster.fork(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# don't forget to update your port tree first | |
sudo port selfupdate | |
# install coffee script using macport | |
sudo port install nodejs | |
node -v | |
# install npm - the Node Package Manager | |
git clone http://github.com/isaacs/npm.git | |
cd npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~ | |
sudo apt-get update | |
sudo apt-get install unzip curl python-software-properties -y | |
#sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" | |
sudo add-apt-repository ppa:ferramroberto/java | |
sudo apt-get update | |
sudo apt-get install sun-java6-jre sun-java6-plugin -y | |
curl -O http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.4.tar.gz -o elasticsearch.tar.gz | |
tar -zxvf elasticsearch.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nano /mnt/pk.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd ~/ | |
mkdir /opt/redis | |
RedisVersion=2.6.11 | |
wget http://redis.googlecode.com/files/redis-$RedisVersion.tar.gz | |
tar -zxvf redis-$RedisVersion.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zlib = require "zlib" | |
exports.deflate = (str = "", callback) -> | |
buffer = new Buffer str, "utf8" | |
zlib.deflate buffer, (err, str) -> | |
str = str.toString "binary" if str? | |
callback?(err, str) | |
exports.inflate = (str = "", callback) -> | |
buffer = new Buffer str, "binary" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Q3. | |
"1 2 3 4 5 6 [7] 6 5 4 3 2 1 [0] 1 2 [3] 2 1 0 [-1] 0 1 2 3 4 [5] [4] 5 6" | |
def pingpong(n): | |
"""Return the nth element of the ping-pong sequence. | |
>>> pingpong(7) | |
7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"caret_extra_width": 2, | |
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Ocean.tmTheme", | |
"default_line_ending": "unix", | |
"draw_white_space": "all", | |
"font_face": "Source Code Pro", | |
"font_size": 16, | |
"ignored_packages": | |
[ | |
"Vintage" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var arr = [6, 5, 3, 1, 8, 7, 2, 4]; | |
function merge(left, right) { | |
var li = 0, | |
ri = 0, | |
arr = []; | |
while (li < left.length && ri < right.length) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var arr = [6, 5, 3, 1, 8, 7, 2, 4]; | |
function partition(arr, lp, rp) { | |
var middle = Math.floor((lp + rp) / 2), | |
pivot = arr[middle], | |
temp; | |
while (lp <= rp) { |
OlderNewer