Skip to content

Instantly share code, notes, and snippets.

View mort's full-sized avatar

Manuel González Noriega mort

View GitHub Profile
## throw this at the top of your .bash_profile
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
.mouse{
position: absolute;
background-image: url('../images/cursor.png');
width: 15px;
height: 22px;
z-index: 100;
}
var sys=require('sys'), http = require('http');
var target = "jsconf";
var connection = http.createClient(80, "search.twitter.com");
var since = 0;
function getTweets() {
var request = connection.request('GET', "/search.json?q=" + target + "&since_id="+since, {"host": "search.twitter.com", "User-Agent": "NodeJS HTTP Client"});
request.addListener("response", function(response) {
var responseBody = "";
response.setEncoding("utf8");
@mort
mort / irbrc
Created September 21, 2010 08:33
require 'rubygems'
begin
# load wirble
require 'wirble'
# start wirble (with color)
Wirble.init
Wirble.colorize
rescue LoadError => err
# My first Thor script is a helper to the productivity strategy of having an
# specific /etc/hosts file that blocks Twitter, Facebook, porn sites, and other
# unwanted distractions, during certains time of the day.
# Copy of your regular hosts file to /etc/hosts.play
# Create a /etc/hosts.work file with all the blocked sites on it
# Use 'thor lets:do [work|play]' to switch to the desired mental context.
# 'work' and 'play' are orientative, use whichever keywords suit you best.
# Nothing keeps you from keeping n different 'contexts' around.
@mort
mort / gist:627118
Created October 14, 2010 21:45
A pattern language for reward systems in social web apps.

Below is a first draft of a typology of criteria used by social apps on their merits/badges/awards systems. It’s my intuition that’s there’s only a limited number of overarching principles sustaining such systems, and this list will try to catalog at least the most popular and easily found of those.

The methodology I’ll be using consists in revising available list of merits for different sites to try and detect the underlying patterns. For each pattern I provide a name, a description, notes if pertinent, relevant Foursquare examples, and a typical string literal associated to the badge.

Feedback, corrections, suggestions, and links to relevant literature will be greatly appreciated.

Manuel González Noriega - [email protected] - 2010

  1. Newbish

require 'sinatra'
get '/' do
params[:url] ||= 'http://www.arroyodesanservan.org/WEB/Ayuntamiento/saludaAlcalde.php'
@url = params[:url]
erb :index
end
@mort
mort / kandypot-node.js
Created November 4, 2010 13:48
Node.js + Redis pubsub + Websockets for kandypot.com.
// Really trivial. On new writes to the redis db, we push messages to a websocket channel
var sys = require("sys"), redis = require('./lib/redis-client'), ws = require("./lib/ws");
var pubsub = redis.createClient();
var clients = new Array();
ws.createServer(function (websocket) {
websocket.addListener("connect", function (resource) {
sys.debug("connect: " + resource);
client_id = resource.match(/apps\/([A-Za-z]+)\/timeline$/)[1];
@mort
mort / redis-ws-chat.js
Created December 8, 2010 00:43
Building on dealer.js (https://github.com/technoweenie/dealer.js) to experiment with Redis-based guest lists for websocket channels
var redisClient = require("redis-client"),
dealer = require("../lib"),
sys = require('sys'),
url = require('url')
var port = process.env['PORT'] || 3840
var redisConf = process.env['REDIS_URL'] || "redis://127.0.0.1:6379/0"
conn = dealer.create()
conn.server.listen(port)
@mort
mort / gist:923018
Created April 16, 2011 09:41
GPS tracking
require 'rubygems'
require 'serialport'
require 'redis'
port_str = '/dev/tty.iBT-GPS-SPPslave'
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE