Skip to content

Instantly share code, notes, and snippets.

View alessioalex's full-sized avatar

Alexandru Vlăduţu alessioalex

View GitHub Profile
@alessioalex
alessioalex / APPNAME
Created July 4, 2011 06:12 — forked from shimondoodkin/APPNAME
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28

(a gist based on the old toolmantim article on setting up remote repos)

To collaborate in a distributed development process you’ll need to push code to remotely accessible repositories.

This is somewhat of a follow-up to the previous article setting up a new rails app with git.

For the impatient

Set up the new bare repo on the server:

@alessioalex
alessioalex / mail.rb
Created August 8, 2011 19:44 — forked from vivien/mail.rb
Sample script for the mail gem.
#!/usr/bin/env ruby
require "mail"
require "optparse"
imap_opts = {
:address => "imap.gmail.com",
:port => 993,
:enable_ssl => true
}
@alessioalex
alessioalex / routes.js
Created October 15, 2011 15:01 — forked from tj/routes.js
Express routes
var app = require('../app');
console.log();
app.routes.all().forEach(function(route){
console.log(' \033[90m%s \033[36m%s\033[0m', route.method.toUpperCase(), route.path);
});
console.log();
process.exit();
@alessioalex
alessioalex / command.sh
Created October 29, 2011 19:42 — 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:
@alessioalex
alessioalex / stackoverflow_monitor.py
Created January 18, 2012 16:50 — forked from qiao/stackoverflow_monitor.py
Monitor for new questions on StackOverflow
#!/usr/bin/env python
# Monitor for new questions on StackOverflow
# Author: Xueqiao Xu <xueqiaoxu@gmail.com>
import time
import json
import gzip
import pprint
import urllib
import urllib2
@alessioalex
alessioalex / .gitignore
Created April 7, 2012 15:58 — forked from bergie/.gitignore
Node.js email handling examples
config.json
reading-image.png
@alessioalex
alessioalex / gist:3306787
Created August 9, 2012 18:24 — forked from fxsjy/gist:3291755
Memcached in JavaScript based on Node.JS
//author: Sun, Junyi (weibo.com/treapdb)
//usage: node --nouse-idle-notification --expose-gc --max-old-space-size=8192 memcached.js
var config ={
port: 11211,
max_memory: 100 // default 100M bytes
}
var net = require('net');
var LRU = function (max) { // this LRU implementaion is based on https://github.com/chriso/lru
@alessioalex
alessioalex / client.js
Created August 15, 2012 09:41
viewDidResize
function ZmgcClient() {
var personPath = "m 1.4194515,-160.64247 c 33.5874165,0 60.8159465,-25.97005 60.8159465,-58.00952 0,-32.0404 -27.22755,-58.0114 -60.8159465,-58.0114 -33.5883965,0 -60.8159415,25.971 -60.8159415,58.0114 0,32.0404 27.228527,58.00952 60.8159415,58.00952 z m 81.9575765,26.25762 C 70.531608,-146.64352 55.269688,-153.983 0.08110256,-153.983 c -55.19742156,0 -70.08915856,7.96609 -82.28062656,19.59815 -12.197359,11.62926 -8.081167,135.7024419 -8.081167,135.7024419 L -63.292733,-59.848397 -46.325227,122.37766 2.6291765,29.116913 48.308878,122.37766 64.467298,-59.848397 91.457218,1.3175919 c 0,-8e-4 4.76917,-123.4484419 -8.08019,-135.7024419 z";
if (! (this instanceof arguments.callee)) {
return new arguments.callee(arguments);
}
var self = this;
this.init = function() {
self.setupBayeuxHandlers();
if ($('#viz').length > 0) {