Skip to content

Instantly share code, notes, and snippets.

@rgaidot
rgaidot / gist:792451
Created January 23, 2011 21:24
Entity Extraction using NLTK
import nltk
text = """Barack Hussein Obama II (born August 4, 1961) is the 44th and current President of the United States. He is the first African American to hold the office. Obama previously served as a United States Senator from Illinois, from January 2005 until he resigned after his election to the presidency in November 2008."""
sentences = nltk.sent_tokenize(text)
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences]
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences]
chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True)
def extract_entity_names(t):
# This script just get the latest tracks of your friends on Last.fm and recommends those more popular.
# It's all based on a conversation between @mort, @rochgs, @littlemove and me (mainly by @mort)
# INSTRUCTIONS
# 1. Install lastfm gem: https://github.com/youpy/ruby-lastfm/
# gem install lastfm
# 2. Get a Last.fm API Key on http://www.lastfm.es/api
require 'lastfm'
@rgaidot
rgaidot / elasticoverflow.rb
Created May 4, 2011 00:10 — forked from karmi/elasticoverflow.rb
Importing and searching RSS with ElasticSearch and Tire
# =======================================================
# Importing and searching RSS with ElasticSearch and Tire
# =======================================================
#
# This script downloads, parses and indexes Stackoverflow RSS feed with ElasticSearch
# via the [Tire](https://github.com/karmi/tire) Rubygem.
#
# Requirements
# ------------
#
@rgaidot
rgaidot / simple-rails-template.rb
Created August 23, 2011 12:48
Simple Rails Template
#
# Simple Rails Template
#
# e.g: rails new myapp -d mysql -m http://.../simple-rails-template.rb
#
# Enjoy !
#
# ~ @rgaidot
#
@rgaidot
rgaidot / sinatra-memcacher.rb
Created April 4, 2012 13:52 — forked from mralex/sinatra-memcacher.rb
Simple memcached helper for Sinatra.
# Activate in a modular Sinatra app:
#
# register Sinatra::Memcacher
# set :memcacher_enabled, true
# set :memcacher_expiry, 86400
# Cache an action:
#
# get '/' do
# cache "index" do
@rgaidot
rgaidot / 0_README.md
Created September 15, 2012 01:31 — forked from josevalim/0_README.md
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

(($) ->
$.instagramPictures = (el, options) ->
base = this
base.$el = $(el)
base.el = el
base.photos = {}
base.$el.data "instagramPictures", base
base.init = ->
base.options = $.extend({}, $.instagramPictures.defaultOptions, options)
alert "The jQuery Instagram plugin need an access token" if typeof (base.options.accessToken) is "undefined" or base.options.accessToken is null
#!/bin/bash
# cpustatus
#
# Prints the current state of the CPU like temperature, voltage and speed.
# The temperature is reported in degrees Celsius (C) while
# the CPU speed is calculated in megahertz (MHz).
function convert_to_MHz {
let value=$1/1000
echo "$value"
@rgaidot
rgaidot / Gemfile
Created February 16, 2014 03:28
Ruby on Rails Lightweight
source :rubygems
gem "actionpack", "~> 4.0"
gem "railties", "~> 4.0"
gem "tzinfo"
gem "thin"
#!/bin/bash
kill -9 `ps ax | grep "$1" | awk '{print $1}'` &2>/dev/null
echo "byebye $1 :-)"