Skip to content

Instantly share code, notes, and snippets.

View alainravet's full-sized avatar

Alain Ravet alainravet

  • Braine l'Alleud, Belgium
View GitHub Profile
@alainravet
alainravet / cowsay_video_notes.txt
Created September 2, 2012 17:27
cowsay video notes
brew install cowsay
x = (<<'END')
don't escape the backslash, f.ex /\:/\
END
IO.popen(['cowsay', message]) do |process|
process.read
end
$ bundle init
@alainravet
alainravet / fixnum_to_lcd_matrix.rb
Created August 15, 2012 13:06
Fixnum#to_lcd_matrix
class Fixnum
def to_lcd_matrix(sep=' ')
segments_per_row_per_digit=[
' ._. ._. __. ._. ._. __. ._. ._.' .scan(/ (...)/).flatten,
' | | | ._| __| |_| |_. |_. _| |_| |_|' .scan(/ (...)/).flatten,
' |_| | |_. __| | ._| |_| ..| |_| ._|' .scan(/ (...)/).flatten
]
lcd_rows = [[],[],[]]
self.to_s.chars.each do |s|
digit = s.to_i
@alainravet
alainravet / output.txt
Created July 22, 2012 19:14
private_please : detect if a method can be made private
i - OUTSIDE CALL (calling this private method is normally forbidden)
a_method was called
i - INSIDE CALL
a_method was called
Process finished with exit code 0
@alainravet
alainravet / test_parallel_8core_iMac
Created September 9, 2011 22:34
test_parallel_8core_iMac
#!/bin/sh
bundle install | tail -1
rm log/test.lo* 2> /dev/null
rm log/cucumber.lo* 2> /dev/null
echo -----------------------------
echo TEST UNIT ...
echo -----------------------------
@alainravet
alainravet / the_jquer_code.js
Created February 9, 2011 18:14
limit the characters in a textarea + display 'n characters left'
$(document).ready(function() {
$('textarea.word_count').each(function(){
var maxlimit = parseInt($(this).attr('maxlength'));
// ...on page load
var length = $(this).val().length;
if(length >= maxlimit) {
$(this).val($(this).val().substring(0, maxlimit));
@alainravet
alainravet / bug_or_pending_test_case.rb
Created May 5, 2010 21:22
add pending tests to TestCAse
require 'test_helper'
module ActiveSupport
class TestCase < Test::Unit::TestCase
# Correct Usage :
# def test_ok_pending_1
# pending "feature 1 should do this ..."
# end
# with Daemons, extract the params. for the daemonized process
#
# Input :
# ["run", "--", "--source=/tmp/sour", "--archive=/tmp/arch"]
# ^ ^^^^^^^^^ ^^^^^^^^^
# | :source :archive
# the separator
#
# Output :
# {:source=>"/tmp/sour", :archive=>"/tmp/arch"}
@alainravet
alainravet / .bash_profile
Created March 21, 2010 20:41 — forked from bcardarella/.bash_profile
git completion
source ~/.git-completion.sh
alias gco='git co'
alias gci='git ci'
alias grb='git rb'
@alainravet
alainravet / setup_once.rb
Created November 30, 2009 18:33
test-unit setup_once/teardown_once
# Usage :
# --------
# require 'setup_once'
# class MyTest < Test::Unit::TestCase
# include SetupOnce
#
# def self.setup_once
# puts "doing one-time setup"
# end
#
require 'rubygems'
require 'parallel' #http://github.com/grosser/parallel
$stdout.sync = true # Auto-flush for interactive I/O
def slow_action
def fibo(n)
0 == n ? 0 :
1 == n ? 1 :