Skip to content

Instantly share code, notes, and snippets.

View elia's full-sized avatar
🦆
quacking!

Elia Schito elia

🦆
quacking!
View GitHub Profile
#!/usr/bin/env ruby
require 'webrick/httpproxy'
require 'webrick/httpauth/digestauth'
require 'webrick/httpauth/userdb'
def ask question
STDOUT.print question
STDOUT.flush
gets.chomp
end
commit 1e4c620263077fa03b8fbc11104fde47d041f836
Author: Elia Schito <perlelia@gmail.com>
Date: Fri May 15 10:17:48 2009 +0200
Added Thor::IncludableModule to automagically transform module methods into thor ones.
diff --git a/lib/thor/includable_module.rb b/lib/thor/includable_module.rb
new file mode 100644
index 0000000..8cb821e
--- /dev/null
@elia
elia / .autotest
Created September 21, 2009 12:14
# this works only on macs...
Autotest.add_hook :ran_command do |autotest|
results = [autotest.results].flatten.join("\n")
examples = results.scan(/(\d+) examples?/).flatten.first.to_i || 0
failures = results.scan(/(\d+) failures?/).flatten.first.to_i || 0
pending = results.scan(/(\d+) pending/).flatten.first.to_i || 0
errors = results.scan(/(\d+) errors?/).flatten.first.to_i || 0
if [examples, failures, pending, errors].any?{|v| v > 0}
@elia
elia / git-prompt.sh
Created October 14, 2009 10:18
A minimalistic-colored-git-enabled bash prompt: gitdir ? "myproject:mybranch> " : "> "
#!/usr/bin/env bash
# coding: utf-8
# PROMPT
# more compact
# export PS1="\u@\h\w$ "
# export PS1=">: " # LOST style
# export PS1='> ' # Terminal Icon style
#
# BitFields provides a simple way to extract a values from bit fields,
# especially if they don't correspond to standard sizes (such as +char+, +int+,
# +long+, etc., see <tt>String#unpack</tt> for further informations).
#
# For example the Primary Header of the Telemetry Frame in the ESA PSS
# Standard has this specification:
#
#
# | TRANSFER FRAME PRIMARY HEADER |
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
module ChatClient
def post_init
@name = "anonymous_#{ChatClient.client_num+=1}"
@sid = ChatClient.channel.subscribe(method(:send_msg))
@buf = ''
require 'aws/s3'
class << AWS::S3
# The 3 S3 enpoints (http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RequestEndpoints.html).
ENDPOINTS = {
:us => 's3-us-west-1.amazonaws.com',
:asia => 's3-ap-southeast-1.amazonaws.com',
:europe => 's3-eu-west-1.amazonaws.com'
}
module SocketWithStats
attr_reader :read_bytes
def read *args
@read_bytes ||= 0.bytes
got = super
@read_bytes += args.first
return got
end
end
@elia
elia / elia-git-prompt.sh
Created April 6, 2011 10:18
"project-dir:branch-name> " in git repos, "> " everywhere else (both are colored).
# To include this custom prompt put this file in "~/bin/" and and put the
# following lines in "~/.profile".
#
# # Include Custom prompt
# . ~/bin/elia-git-prompt.sh
clear=$'\[\e[0m\]'
red=$'\[\e[31m\]'
green=$'\[\e[32m\]'
@elia
elia / Questions
Created August 11, 2011 15:12
Frozen Rails Give-away
Day job:
Your Rails contributions (if any):
What's your Ruby/Rail experience?:
How do you use GitHub?: