Skip to content

Instantly share code, notes, and snippets.

View aitor's full-sized avatar
👊
Working!

Aitor García Rey aitor

👊
Working!
View GitHub Profile
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>ul.buttongroup</title>
<style>
ul.buttongroup {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
display: inline-block;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Nice Buttons</title>
<style>
* { margin: 0; padding: 0; }
ul {
padding: 20px;
width: 80px;
float: left;
@aitor
aitor / gist:627266
Created October 14, 2010 23:17 — forked from mort/gist:627118

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 - manuel@simplelogica.net - 2010

  1. Virginity

require 'md5'
class Chargify::HooksController < ApplicationController
protect_from_forgery :except => :dispatch
before_filter :verify, :only => :dispatch
EVENTS = %w[ test signup_success signup_failure renewal_success renewal_failure payment_success payment_failure billing_date_change subscription_state_change subscription_product_change ].freeze
def dispatch
event = params[:event]

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

#!/usr/bin/env ruby
# encoding: UTF-8
#
# LearnRubyByExample:
#
# Ruby is a highly expressive programming language.
# Testing software is an expressive way to communicate how it works.
#
# In the middle of a night awake for allergy and insomnia, and some days after the 1st _why day,
# I've tried to combine Ruby and testing to help teaching ruby with some goals in mind:
## 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.
A backup from http://sites.google.com/site/redcodenl/creating-shazam-in-java-1 just in case
----
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?
@aitor
aitor / wadus.rb
Created July 2, 2010 10:53 — forked from porras/wadus.rb
def wadus(wadus = nil, options = {})
puts "wadus = #{wadus.inspect}"
puts "options = #{options.inspect}"
end
wadus
# wadus = nil
# options = {}
# OK
# Export your Wordpress posts to Tumblr (also allows to delete some.)
# Author: Alexandre Solleiro <alex@webcracy.org>
# How-to:
# 1. Export your Wordpress posts (http://en.blog.wordpress.com/2006/06/12/xml-import-export/)
# 2. Edit the information below to match your settings
# 3. To import, type "ruby wordpress2tumblr.rb --run" in the command line
# 4. To delete some posts, type "ruby wordpress2tumblr.rb --delete 1,2,3,4" where 1,2,3,4 are post numbers. (Be careful not to use spaces between IDs)
# Edit these
WP_EXPORT_PATH = "./wordpress.2009-09-14.xml" # path to the Wordpress Export file