Skip to content

Instantly share code, notes, and snippets.

View lgs's full-sized avatar

Luca G. Soave lgs

View GitHub Profile
require 'rubygems'
require 'httparty'
require 'time'
require 'active_support'
File.read("#{ENV['HOME']}/.gitconfig").match(/token = (\w+)/)
TOKEN = $1
class Github
include HTTParty
CmdUtils.CreateCommand({
name: "delicious",
homepage: "http://ryan.codecrate.com/",
author: { name: "Ryan Sonnek", email: "ryan@codecrate.com"},
contributors: ["Ryan Sonnek"],
license: "MIT",
description: "Tags the current site using delicious",
icon: "http://delicious.com/favicon.ico",
help: "Save the current url to delicious with the tags input by the user. Any selected text on the page will be recorded as the note.",
@lgs
lgs / gist:73335
Created March 3, 2009 14:21 — forked from ombran/gist:27407
require 'open-uri'
require 'xmlrpc/client'
require 'rexml/document'
require 'digest/md5'
require 'rubygems'
require 'json'
class SBM
# 初期設定
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
require 'gruff'
class GitCommitGraph
Author = Struct.new(:name, :email)
Commit = Struct.new(:hash, :author, :time, :insertions, :deletions, :files_changed)
attr_accessor :time_spacing, :built, :repository, :since, :name, :commit_hash
attr_accessor :scale_type, :width, :height, :graph, :graph_type
require 'rubygems'
require 'benchmark'
require 'facets/dictionary'
require 'rbtree'
n = 1000000
Benchmark.bm do |x|
@h = Hash.new
x.report("Hash insert") { n.times do @h[rand(n)] = 1 end }
x.report("Hash access") { n.times do @h[rand(n)] end }
# NOTE: See further development and a gem at http://github.com/topfunky/basic_model
require 'couchrest'
##
# A minimal class to help use CouchDB and CouchRest with Rails.
#
# Provides dot notation access for all attributes, one level deep.
#
# note.title
@lgs
lgs / init.rb
Created April 21, 2009 21:10 — forked from jnewland/init.rb
# A Sinatra App as a Rails Plugin
#
# In your Edge Rails app:
#
# ruby script/plugin install git://gist.github.com/50625.git
require 'sinatra/base'
class SinatraRailsPlugin < Sinatra::Base
require 'sinatra/metal'
class SinatraMetal < Sinatra::Base
include Sinatra::Metal
get '/sinatra' do
'hello sinatra!'
end
end
require 'sinatra/metal'
class SinatraMetal < Sinatra::Base
include Sinatra::Metal
get '/sinatra' do
'hello sinatra!'
end
end