Skip to content

Instantly share code, notes, and snippets.

View fabiokr's full-sized avatar

Fabio Kreusch fabiokr

View GitHub Profile

Keybase proof

I hereby claim:

  • I am fabiokr on github.
  • I am fabiokr (https://keybase.io/fabiokr) on keybase.
  • I have a public key whose fingerprint is 45B2 ADBB D9C9 89CC 4EC0 3B1E 71D8 FFF7 14DE 4EDF

To claim this, I am signing this object:

/** SELECT VALUES FOR SECTION 'Vanity Tops' AND FILTER 'AVAILABLE_COLORS' **/
SELECT VALUE AS NAME,
VALUE AS VALUE,
Count(VALUE) AS COUNT
FROM (SELECT product_id,
VALUE,
position
FROM (SELECT pa.product_id AS product_id,
pa.position AS position,
Substr(pa.VALUE,Instr(pa.VALUE,'~') + 1,Length(pa.VALUE)) AS VALUE
@fabiokr
fabiokr / rails_3_list_of_entities.rb
Created August 15, 2011 19:48
Retrieve a list of Rails 3 Controllers (or any other entities)
# Replace "app/controllers" for the kind of thing you are looking for
# A list of available items can be found in rails/railties/lib/rails/engine/configuration.rb#line39
Rails.configuration.paths["app/controllers"].expanded.inject([]) do |controllers, dir|
controllers += Dir["#{dir}/**/*_controller.rb"].map do |file|
file.gsub("#{dir}/", "")
.gsub(".rb", "")
.camelize
.constantize
end
diff --git a/lib/moo_moo/base.rb b/lib/moo_moo/base.rb
index 43ed22a..f20a36e 100644
--- a/lib/moo_moo/base.rb
+++ b/lib/moo_moo/base.rb
@@ -2,6 +2,29 @@ module MooMoo
class Base
attr_reader :host, :key, :user, :pass, :port
+ # Register an api service for the current class.
+ #
E, [2012-02-21T20:30:12.434214 #4624] ERROR -- : app error: Net::HTTPOK#read_body called twice (IOError)
E, [2012-02-21T20:30:12.434323 #4624] ERROR -- : /home/fabio/.rvm/rubies/ruby-1.9.3-p0-perf/lib/ruby/1.9.1/net/http.rb:2704:in `read_body'
E, [2012-02-21T20:30:12.434383 #4624] ERROR -- : /home/fabio/dev/----/---/lib/---/net_http_client.rb:45:in `each'
E, [2012-02-21T20:30:12.434442 #4624] ERROR -- : /home/fabio/.rvm/gems/ruby-1.9.3-p0-perf/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:46:in `each'
E, [2012-02-21T20:30:12.434501 #4624] ERROR -- : /home/fabio/.rvm/gems/ruby-1.9.3-p0-perf/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:424:in `each'
E, [2012-02-21T20:30:12.434557 #4624] ERROR -- : /home/fabio/.rvm/gems/ruby-1.9.3-p0-perf/gems/actionpack-3.2.1/lib/action_dispatch/middleware/body_proxy.rb:27:in `method_missing'
E, [2012-02-21T20:30:12.434613 #4624] ERROR -- : /home/fabio/.rvm/gems/ruby-1.9.3-p0-perf/gems/rack-1.4.1/lib/rack/body_proxy.rb:26:
<% semantic_navigation :main do |n| %>
<%= n.group 'Media' do %>
<%= n.item 'Image Gallery', :link => '/media/images', :highlights_on => '/media/videos' %>
<%= n.item 'Videos', :link => '/media/videos', :disabled_if => proc { true } %>
<%= n.item 'Contact Us' # auto links to the contact_us_path if it exists %>
<% end %>
<% end %>
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
class Model
# model has a country_code column which stores in ISO format
def country
I18n.t(country_code)
end
end
irb
require 'uri'
require 'faraday'
uri = URI.parse("http://www.google.com.br")
response = Faraday.new(:url => uri) do |c|
c.params = {:a => "b"}
end.get.body
@fabiokr
fabiokr / countries_iso_and_international_phone_codes.csv
Created March 12, 2012 14:46
ISO Country codes and international phone numbers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Country;ISO;International Phone
Afghanistan;AF;93
Aland Islands;AX;358
Albania;AL;355
Algeria;DZ;231
American Samoa;AS;684
Andorra;AD;376
Angola;AO;244
Anguilla;AI;1
Antarctica;AQ;