This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mechanize' | |
def prompt(label, echo = true) | |
`stty -echo` unless echo | |
$stdout.print "#{label}: " | |
$stdout.flush | |
$stdin.readline.strip | |
ensure | |
unless echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Format columns in the Cucumber style | |
input = STDIN.read | |
margin_left = input =~ /\A(\s+)\S/ && $1 | |
rows = input.split("\n").map {|line| line.strip.scan(/\|([^|]+)/).map {|column| column.first.strip } } | |
column_widths = rows.transpose.map {|column| column.map {|c| c.size }.max } | |
rows.each do |row| | |
print margin_left |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from: any@example.com | |
body: "Invalid mail" | |
include_source: true | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Put this file in ~/.vim/plugin/local_vimrc.vim | |
" When open a file (buffer) this script will find a .vimrc in the file's directory and in its parents. | |
function! LoadLocalVimrc() | |
let paths = split(expand("%:p:h"), "/") | |
while len(paths) > 0 | |
call add(paths, ".vimrc") | |
let source_name = "/" . join(paths, "/") | |
if filereadable(source_name) && $MYVIMRC != source_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map = [ | |
"âãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮñÑçÇüÜ".mb_chars, | |
"aaaaaaaaaaaaaaaeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuunnccuu" | |
] | |
# ActiveSupport::Multibyte::Chars#tr broken? | |
word = "anything" | |
adapted_word = "%#{word.mb_chars.split(//).map {|e| (p = map[0].index(e)) ? map[1][p,1] : e.to_s }.join.downcase}%" | |
Post.where("lower(translate(title, '#{map[0]}', '#{map[1]}')) like #{Post.connection.quote word}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone git://gist.github.com/582351.git html_entities | |
... | |
$ cd html_entities/ | |
$ wget http://www.w3.org/2003/entities/2007xml/unicode.xml | |
... | |
$ ruby html_entities.rb > entities.rb | |
$ ruby html_entities.rb plain > entities.dat | |
$ ls -sh entities.* | |
28K entities.dat 68K entities.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
begin | |
require "readline" | |
rescue LoadError | |
STDERR.puts "No readline found" | |
end | |
load "Rakefile" | |
Rake::Task["environment"].invoke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Ayose Cazorla | |
# Public Domain | |
# | |
# Normalize a lot of videos using ffmpeg and normalize-audio (both available as Debian packages) | |
# | |
# HRC on tha house... | |
AMPLITUDE="-12dBFS" | |
def say(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To be used with http://github.com/setepo/asset-pocket | |
# | |
# require 'clousure_compressor' | |
# compressor :clousure, :handler => ClousureCompressor.new | |
# | |
# js "public/javascripts/application.js" do | |
# compress :clousure | |
# use "app/views/js/*" | |
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/application', __FILE__) | |
module Kernel | |
def run(test_file) | |
Process.waitpid(fork do | |
$: << File.dirname(__FILE__)+"/../test/" | |
load test_file |
OlderNewer