Skip to content

Instantly share code, notes, and snippets.

View mort's full-sized avatar

Manuel González Noriega mort

View GitHub Profile
# 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 / 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
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");
.mouse{
position: absolute;
background-image: url('../images/cursor.png');
width: 15px;
height: 22px;
z-index: 100;
}
## 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\]"
require 'rubygems'
require 'wirble'
require 'hirb'
Wirble.init
Wirble.colorize
Hirb.enable
script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
## CAUTION: Very rough draft. A more complete and polished version will follow soon:
---
Kandypot es un sistema de karma social, implementado en forma de API HTTP para su uso desde/por toda clase de sitios basados en la interacción social. Tiene tres principios básicos:
- Recompensa: a las buenas acciones se les conceden premios. Estos premios son unidades de kandies.
- Aleatoriedad: No se recompensan todas las acciones, sino que se maneja un porcentaje de probabilidad que determina que a veces se otorga el premio, a veces no.
- Transferencia: si la buena acción implica a dos usuarios, y merece premio, se produce una transferencia de kandies del recompensado al otro usuario involucrado. Es decir, si yo dejo un comentario en un post tuyo, y mi comentario me hace ganar 10 kandies, un porcentaje de estos pasarán a ti.
# Activity streams' notifications to third parties are cool because they bring a feeling of a shared public space and increase the chance of serendipitous findings
# But too much information quickly becomes noise, and relevant bits of news can disappear among a tsunami of irrelevant (to me) "x did y with z'
# What we're trying to do here is going from deterministic notifications (stuff happens, stuff gets broadcasted) to stochastic ones (stuff happens, stuff may gets broadcasted)
# Thanks to the fantastic alea gem (http://github.com/linkingpaths/alea) by Linking Paths, the explanation is way longer than this very naive one liner implementation.
# TO-DO: experiment with varying the probabilities based on time thresholds (i.e. 100 similar notifications (same type / same originating user) in one hour have a 1% chance of showing up, 1 single notification in one hour has 100% chances of showing up)
def do_probabilistic_broadcast
# Always notify you of activity around your stuff
notify_owner
@mort
mort / Creating Shazam in Java
Created July 8, 2010 09:18
Creating Shazam in Java
A backup of http://sites.google.com/site/redcodenl/creating-shazam-in-java-1 just in case
Why is this necessary? Read http://sites.google.com/site/redcodenl/patent-infringement
Please fork, tweet about, etc.
----
Creating Shazam in Java
A couple of days ago I encountered this article: How Shazam Works
This got me interested in how a program like Shazam works… And more importantly, how hard is it to program something similar in Java?
# home
require 'lib/stairway'
oauth = Stairway::OAuth.new('4W3Wj1BO4T2Dglt9pNMl','5ctPK7n8V695rd1uVEPOKDcv2Ak3ptvCiplHH6Lk')
oauth.authorize_from_access('esxMpOTZxhvzCov3YzeP','nCkj2acM9HfXai6Wats5OULY0gymjIBnV39T9XJT')
traveler = Stairway::Traveler.new(oauth)
traveler.ping('54.19','-0.17')
# work
require 'lib/stairway'
oauth = Stairway::OAuth.new('ySsLWOjjLpi4W0E6sEHN','JRjIrhplCHOudJNN2dSoXyEjy1MsTUdUGaKqG88g')