Skip to content

Instantly share code, notes, and snippets.

View hemanth's full-sized avatar
🐜
🧘‍♂️

Hemanth HM hemanth

🐜
🧘‍♂️
View GitHub Profile
@hemanth
hemanth / reqUrl.js
Created July 2, 2012 17:06
A function I made that wraps the node http.request function to make it a little more friendly. In my case I am using it for API route testing.
// module dependencies
var http = require('http'),
url = require('url');
/**
* UrlReq - Wraps the http.request function making it nice for unit testing APIs.
*
* @param {string} reqUrl The required url in any form
* @param {object} options An options object (this is optional)
@hemanth
hemanth / lismo2vcf.rb
Created July 2, 2012 16:51 — forked from takuya/lismo2vcf.rb
Lismoのアドレス帳をVCFに変換する ref: http://qiita.com/items/a0c921fbef3f94bbbe24
require 'rubygems'
require 'kconv'
require 'csv'
require 'vpim'
$KCODE='u'
#Authors:: takuya_1st
#Copyright:: @takuya_1st
#License:: GPL
class CSV
## CSVファイルを読み込んで一行目を見出し行として、全部をハッシュに読み込む
@hemanth
hemanth / command.sh
Created July 2, 2012 13:10 — forked from felixge/command.sh
Bash stuff for fighting a weak DOS attack
# Here a few bash one-liners that helped me analyze / fight a weak DOS attack against debuggable.com. Mostly for future reference.
# The attacker was opening lots of tcp connections without sending data, I believe it's called a SYN flood, see: http://tools.ietf.org/html/rfc4987#section-3.2
# Step 0: Check what is going on at port 80
$ netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c
# Step 1: Increase the number of available fds
$ ulimit -n 32000
# Step 2: Restart your webserver, for me:
@hemanth
hemanth / ebooks.md
Created July 1, 2012 10:27 — forked from roidrage/ebooks.md
Self-published and awesome
@hemanth
hemanth / gist:3027168
Created July 1, 2012 06:35 — forked from jurka/gist:3027104
Installing supervisor under ubuntu
#run as sudo
apt-get install python-setuptools curl
easy_install supervior
curl https://raw.github.com/gist/176149/88d0d68c4af22a7474ad1d011659ea2d27e35b8d/supervisord.sh > /etc/init.d/supervisord
#to run it
chmod +x /etc/init.d/supervisord
#adding to autostart
$(function () {
var article_root = $("article");
var search_api = "https://www.googleapis.com/customsearch/v1element";
var apikey = "AIzaSyCVAXiUzRYsML1Pv6RwSG1gunmMikTzQqY";
var cseid = "004387629570218579707:w1sg4iph0mc";
var query = location.hash.match(/^\#q=([^&]+)/)[1];
document.title = "'" + query + "' の検索結果 - 開発な日々";
var result_url = [search_api, "?key=", apikey, "&rsz=large&num=8&cx=", cseid, "&q=", encodeURI(query), "&callback=?"].join("");
$("input[name='q']").val(query);
$.getJSON(result_url, function (data) {
@hemanth
hemanth / gist:3027037
Created July 1, 2012 05:56 — forked from Gregg/gist:968534
Code School Screencasting Framework

Screencasting Framework

The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.

Why you should care about screencasting?

You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.

  1. Communicating more effectively - At Envy Labs we produce screencasts for our clients all the time. Whether it's demoing a new feature or for a presentation for an invester, they're often much more effective and pleasent than a phone call or screen sharing.
@hemanth
hemanth / one-liners.md
Created June 28, 2012 14:38 — forked from KL-7/one-liners.md
Ruby one-liners

One-liners

Reverse every line:

Input file:

$ cat foo
qwe
123

bar

@hemanth
hemanth / gist:3010278
Created June 28, 2012 09:44
Create an array from Range in node
Array.prototype.range = function(str) {
var inclusive = str.indexOf("...") > -1;
var p = str.split( ((inclusive) ? "..." : "..") );
p[0] = parseInt(p[0]), p[1] = parseInt(p[1]) - (( inclusive ) ? 0 : 1);
var n = []; for ( var i=p[0]; i<=p[1]; i++ ) n.push(i); return n;
}
console.log( [].range("1...20") );
// prints