Skip to content

Instantly share code, notes, and snippets.

View lucasefe's full-sized avatar
💭
Busy building stuff

Lucas Florio lucasefe

💭
Busy building stuff
  • Community Phone
  • Buenos Aires, Argentina
  • X @lucasefe
View GitHub Profile
# encoding: utf-8
require 'mysql'
class Mysql::Result
def encode(value, encoding = "utf-8")
String === value && '1.9'.respond_to?(:force_encoding) ? value.force_encoding(encoding) : value
end
def each_utf8(&block)
each_orig do |row|
# encoding: utf-8
namespace :encoding do
task :update_files do
Dir.glob("{app,config,spec,test,lib,db,features}/**/*.{rb,rake}").each do |f|
add_encoding(f)
end
end
def add_encoding(file_name, encoding = 'utf-8')
if File.exist?(file_name)
# Everything you need to do to get started with Rails 2.3.8
#
# As of June 14th, 2010 @ 2:30 p.m. MST
#
# This gist now features instructions to get Rails 3 up and running with:
# - Ruby 1.8.7-p174
# - Bundler 0.9.26
# - Cucumber 0.8.0
# - Rspec 1.3.0 + Rspec-Rails 1.3.2
# - RVM
@lucasefe
lucasefe / watchr-runner.rb
Created July 29, 2010 14:55 — forked from rud/watchr-runner.rb
watchr for rails3
if __FILE__ == $0
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev"
exit 1
end
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def run(cmd)
puts(cmd)
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
module ThemeSupport
class RoutingTest < ActionController::TestCase
test "recognize stylesheets route" do
assert_recognizes(
{:controller => "theme_support/assets", :action => "index", :theme => "default", :asset => "app.css"},
{ :path => "/themes/default/stylesheets/app.css", :method => :get }
)
end
end
ENV["RAILS_ENV"] = "test"
$:.unshift File.dirname(__FILE__)
# loading internal rails app.
require "dummy_app/config/environment"
require "rails/test_help"
$:.unshift File.expand_path('../support', __FILE__)
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

Derailed

IMHO

#Preludio

Origen: PHP, VB, Crap Lang.

Ruby a través de Rails

@lucasefe
lucasefe / heroku-cli.rb
Created July 11, 2012 19:59
run commands on a single app context
# heroku-cli --app my-heroku-app
[ my-heroku-app ] >
# encoding: utf-8
require 'mechanize'
require 'csv'
START_URL = 'http://www.confreaks.com/events'
STDOUT.sync = true
agent = Mechanize.new
page = agent.get START_URL