Skip to content

Instantly share code, notes, and snippets.

@lifuzu
lifuzu / gitemail
Created April 13, 2016 17:11
Update email and user name in the git history
git filter-branch -f --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "origin@email.address" -o "$GIT_AUTHOR_EMAIL" = "origin2@email.address" ];
then
GIT_AUTHOR_NAME="User Name";
GIT_AUTHOR_EMAIL="new@mail.address";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
var http=require("http");
http.createServer(function(req,res){
res.writeHead(200,{"Content-Type":"text/plain"});
res.end("Hello World\n");
}).listen(9124,"localhost");
console.log("The sweet thing is running on http://localhost:9124");
@lifuzu
lifuzu / eventlet.py
Created March 9, 2016 22:26
eventlet python script to setup a hello world web server disabled log (http://lifuzu.com/blog/2014/01/05/performance-analysis-of-gevent-eventlet-and-nodejs)
$ cat eve.py
import eventlet
from eventlet import wsgi
class Logger(object):
def info(self,*args,**kwargs):
pass
def debug(self,*args,**kwargs):
pass
@lifuzu
lifuzu / geve.py
Created March 9, 2016 22:24
gevent python script to setup a hello world web server disabled log (http://lifuzu.com/blog/2014/01/05/performance-analysis-of-gevent-eventlet-and-nodejs)
$ cat geve.py
import gevent
from gevent import wsgi,pool
#the application to handle the response
def app(environ,start_response):
start_response("200 OK",[("Content-Type","text/plain")])
return "Hello World\n"
if __name__=="__main__":
print "The sweet thing is running on http://localhost:8912/"
pool=gevent.pool.Pool() #A pool of greenlets.Each greenlets runs the above defined function app for a client request
@lifuzu
lifuzu / sysctl.log
Created March 9, 2016 22:21
sysctl log on mac osx for evaluation python and nodejs
$ sysctl -A
user.cs_path: /usr/bin:/bin:/usr/sbin:/sbin
user.bc_base_max: 99
user.bc_dim_max: 2048
user.bc_scale_max: 99
user.bc_string_max: 1000
user.coll_weights_max: 2
user.expr_nest_max: 32
user.line_max: 2048
user.re_dup_max: 255
@lifuzu
lifuzu / cccapstone_question_3.2_task2.txt
Created February 17, 2016 19:18
Cloud Computing Capstone Question 3.2 Solution for Task2
USE mykeyspace;
SELECT * FROM task1_part2_group3_2 WHERE origin = 'BOS' AND through = 'ATL' AND dest = 'LAX' AND first_date = '03/04/2008';
SELECT * FROM task1_part2_group3_2 WHERE origin = 'PHX' AND through = 'JFK' AND dest = 'MSP' AND first_date = '07/09/2008';
SELECT * FROM task1_part2_group3_2 WHERE origin = 'DFW' AND through = 'STL' AND dest = 'ORD' AND first_date = '24/01/2008';
SELECT * FROM task1_part2_group3_2 WHERE origin = 'LAX' AND through = 'MIA' AND dest = 'LAX' AND first_date = '16/05/2008';
$ bash question3_2.sh
origin | through | dest | first_date | delay
--------+---------+------+------------+-------
@lifuzu
lifuzu / cccapstone_question_2.3_task2.txt
Last active February 17, 2016 19:16
Cloud Computing Capstone Question 2.3 Solution for Task2
USE mykeyspace;
SELECT origin, dest, carrier, average FROM task1_part2_group2_3 WHERE origin = 'LGA' AND dest = 'BOS';
SELECT origin, dest, carrier, average FROM task1_part2_group2_3 WHERE origin = 'BOS' AND dest = 'LGA';
SELECT origin, dest, carrier, average FROM task1_part2_group2_3 WHERE origin = 'OKC' AND dest = 'DFW';
SELECT origin, dest, carrier, average FROM task1_part2_group2_3 WHERE origin = 'MSP' AND dest = 'ATL';
$ bash question2_3.sh
origin | dest | carrier | average
--------+------+---------+---------
@lifuzu
lifuzu / cccapstone_question_2.2_task2.txt
Created February 17, 2016 19:14
Cloud Computing Capstone Question 2.2 Solution for Task2
USE mykeyspace;
SELECT origin, dest, average FROM task1_part2_group2_2 WHERE origin IN ('SRQ', 'CMH', 'JFK', 'SEA', 'BOS');
$ bash question2_2.sh
origin | dest | average
--------+------+---------
BOS | ONT | 0
BOS | SWF | 0
BOS | GGG | 2
@lifuzu
lifuzu / cccapstone_question_2.1_task2.txt
Created February 17, 2016 19:12
Cloud Computing Capstone Question 2.1 Solution for Task2
USE mykeyspace;
SELECT origin, carrier, average FROM task1_part2_group2_1 WHERE origin IN ('SRQ', 'CMH', 'JFK', 'SEA', 'BOS');
$ bash question2_1.sh
origin | carrier | average
--------+---------+---------
BOS | PA (1) | 4.7603
BOS | ML (1) | 5.7604
BOS | TZ | 7.4525
@lifuzu
lifuzu / cccapstone_question_1.2_task2.txt
Created February 17, 2016 19:08
Cloud Computing Capstone Question 1.2 Solution for Task2
========= 2016-02-17 14:03:00 =========
+-------+------------------+
|carrier| avg_delay|
+-------+------------------+
| "HA"|3.8480866979955883|
| "9E"| 5.108409199808337|
| "WN"| 6.573501153936092|
| "F9"| 6.647087408127316|
| "NW"| 7.351961775245797|
| "OO"| 7.906498902139751|