Régis Gaidot rgaidot

View bye.sh
1 2 3
#!/bin/bash
kill -9 `ps ax | grep "$1" | awk '{print $1}'` &2>/dev/null
echo "byebye $1 :-)"
View Gemfile
1 2 3 4 5 6 7
source :rubygems
 
gem "actionpack", "~> 4.0"
gem "railties", "~> 4.0"
gem "tzinfo"
 
gem "thin"
View cpustatus.sh
1 2 3 4 5 6 7 8 9 10
#!/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"
View gist:5403026
1 2 3 4 5 6 7 8 9 10
(($) ->
$.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
View 0_README.md

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.

View sinatra-memcacher.rb
1 2 3 4 5 6 7 8 9 10
# 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
View simple-rails-template.rb
1 2 3 4 5 6 7 8 9
#
# Simple Rails Template
#
# e.g: rails new myapp -d mysql -m http://.../simple-rails-template.rb
#
# Enjoy !
#
# ~ @rgaidot
#
View elasticoverflow.rb
1 2 3 4 5 6 7 8 9 10
# =======================================================
# 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
# ------------
#
View lastfm-very-simple-recommender.rb
1 2 3 4 5 6 7 8 9 10
# 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'
View gist:792451
1 2 3 4 5 6 7 8 9 10
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):
Something went wrong with that request. Please try again.