Alberto Perdomo albertoperdomo

View extend.rb
1 2 3 4 5 6 7 8 9 10
module MyAttributes
@@attributes = []
 
def my_accessor(field)
@@attributes << field
attr_accessor(field)
end
 
def my_attributes
@@attributes
View configuration.rb
1 2 3 4 5 6 7 8 9 10
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
attr_accessor :app_server
 
def app_server
@app_server_config ||= AppServer.new
yield @app_server_config if block_given?
@app_server_config
end
end
View binding_exercise.rb
1 2 3 4 5 6 7 8 9 10
def counter(start=0, increment=1)
count = nil
Proc.new do
count = count ? count+increment : start
end
end
 
result = counter(2,3)
 
puts result.call #2
View gems.md
View xvfb
1 2 3 4 5 6 7 8 9 10
DISPLAY=:99
XVFB=/usr/bin/Xvfb
XVFBARGS="$DISPLAY -ac -screen 0 1024x768x16"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
/sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
View 960_plain_small_example.html
1 2 3 4 5 6 7 8 9
// HTML using 960.gs
<body>
<div class="container_16">
 
// more stuff
 
<div class="grid_4">
Sidebar
</div>
View select_city_show_and_hide_autocomplete.js
1 2 3 4 5 6 7 8
// Snippet by @ayosec on IM - Thx ayose! :)
 
 
//:ruby
//= form.input :city_id, :as => :string, :input_html => { :value => resource.city_id }
 
//:javascript
jQuery(function() { city_autocompleter("#resource_city_id", "#{escape_javascript resource.localized_city_long_name || params[:city]}") });
View accent_query_translate_using_translate.rb
1 2 3 4 5 6 7 8 9 10
#Así he implementado tu propuesta como scope:
 
named_scope :normalized_name_begins_with, lambda { |term|
map = [
"âãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮñÑçÇüÜ".mb_chars,
"aaaaaaaaaaaaaaaeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuunnccuu"]
 
# ActiveSupport::Multibyte::Chars#tr broken?
adapted_word = "%#{term.mb_chars.split(//).map {|e| (p = map[0].index(e)) ? map[1][p,1] : e.to_s }.join.downcase}%"
{
View env.rb
1 2 3 4 5 6 7 8 9 10
Before('@selenium') do
if ENV["SELENIUM_HEADLESS"] == 'true'
require "headless"
@headless = Headless.new
@headless.start
end
end
 
After('@selenium') do
@headless.destroy if @headless.present?
View autocomplete_scenario_at_start.feature
1 2 3 4 5 6 7
Feature: Cool AJAX autocomplete
Scenario: Autocomplete city
When I fill in "City" with "Madr"
Then I should see "Madrid, Spain"
When I follow "Madrid, Spain"
Then the field "City" should contain "Madrid, Spain"
Something went wrong with that request. Please try again.