Skip to content

Instantly share code, notes, and snippets.

View mariozig's full-sized avatar

Mario Zigliotto mariozig

  • Intuit
  • San Mateo, CA
View GitHub Profile
## Issue:
NameError in Admin/tweetsController#index
undefined local variable or method `tweets' for #<Class:0x7fcbe98f68f0>
Rails.root: /home/rails/
Application Trace | Framework Trace | Full Trace
app/models/tweet.rb:23:in `add_tweets'
app/models/tweet.rb:15:in `update_twitter_account'
app/models/tweet.rb:9:in `update_tweets'
io@love:~/rails/m3$ git branch -a
admin
authlogic
inlineadmin
list
* master
remotes/origin/add_devise
remotes/origin/admin
remotes/origin/authlogic
remotes/origin/master
Padrino.after_load do
require 'will_paginate/view_helpers/base'
require 'will_paginate/view_helpers/link_renderer'
require 'will_paginate/finders/active_record'
WillPaginate::Finders::ActiveRecord.enable!
end
@mariozig
mariozig / gist:1268326
Created October 6, 2011 19:06
Sort an array of hashes
array_of_hashes = ModelOneAddress.all + ModelTwoAddress.all
array_of_hashes.sort_by { |hsh| hsh[:zip] }
@mariozig
mariozig / scoped friendly_id w sti.rb
Created October 8, 2011 20:05
scoped friendly_id w/ sti
## The setup
# This assumes you already have friendly_id in your gemfile and all that good stuff.
class Car < ActiveRecord::Base
# Slugs via FriendlyId
extend FriendlyId
friendly_id :name, :use => :scoped, :scope => :type
end
class Ford < Car
end
@mariozig
mariozig / gist:1428970
Created December 4, 2011 02:54
Install the mysql2postgres gem
mario@red demo $ git clone https://github.com/maxlapshin/mysql2postgres.git
Cloning into mysql2postgres...
cd myremote: Counting objects: 516, done.
remote: Compressing objects: 100% (269/269), done.
remote: Total 516 (delta 262), reused 486 (delta 237)
Receiving objects: 100% (516/516), 84.68 KiB, done.
Resolving deltas: 100% (262/262), done.
mario@red demo $ cd mysql2postgres/
# Optional: I use RVM and wanted to use ruby 1.9.2
mario@red mysql2postgres $ rvm ruby-1.9.2-p290
@mariozig
mariozig / gist:1428996
Created December 4, 2011 03:06
Create config
# No Config File
mario@red mysql2postgres $ ls -la | grep yml
mario@red mysql2postgres $ mysql2psql
/Users/mario/.rvm/gems/ruby-1.9.2-p290/gems/mysql2psql-0.1.0/lib/mysql2psql/config.rb:14:in `initialize': (Mysql2psql::ConfigurationFileInitialized)
No configuration file found.
A new file has been initialized at: /Users/mario/ruby/demo/mysql2postgres/mysql2psql.yml
Please review the configuration and retry..
# Aw yeah, there she is
@mariozig
mariozig / gist:1429007
Created December 4, 2011 03:10
Do da damn thing
mario@red mysql2postgres $ mysql2psql
Table creation 0 min, loading 7 min, indexing 0 min, total 7 min
@mariozig
mariozig / gist:1429030
Created December 4, 2011 03:19
Damn The Brew!
mario@red mysql2postgres $ mysql2psql
Assertion failed: (param->buffer_length != 0), function setup_one_fetch_function, file /tmp/homebrew-mysql-connector-c-6.0.2-SKcq/mysql-connector-c-6.0.2/libmysql/libmysql.c, line 3985.
Abort trap
posts = Post.all
Parallel.each(posts, :in_processes => 10) do |post|
post.title = post.title.downcase
post.save!
end
# Goes with
# http://ruby.zigzo.com/2012/01/29/the-parallel-gem-and-postgresql-oh-and-rails/