Skip to content

Instantly share code, notes, and snippets.

View arthurnn's full-sized avatar
🟢
CI is passing

Arthur Nogueira Neves arthurnn

🟢
CI is passing
View GitHub Profile
@arthurnn
arthurnn / gist:3095790
Created July 12, 2012 04:37
vagrant 1.0.3 error log
Arthur-Nevess-MacBook-Pro:github arthurnn$ mkdir v
Arthur-Nevess-MacBook-Pro:github arthurnn$ cd v
Arthur-Nevess-MacBook-Pro:v arthurnn$ vagrant init lucid32 http://files.vagrantup.com/lucid32.box
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
Arthur-Nevess-MacBook-Pro:v arthurnn$ vagrant up
[default] Box lucid32 was not found. Fetching box from specified URL...
[vagrant] Downloading with Vagrant::Downloaders::HTTP...
@arthurnn
arthurnn / LoginActivity.java
Created September 4, 2012 19:02
Login example using 500px android sdk
public class LoginActivity extends Activity implements XAuth500pxTask.Delegate{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
XAuth500pxTask loginTask = new XAuth500pxTask(this);
loginTask.execute(getString(R.string.px_consumer_key), getString(R.string.px_consumer_secret),"username","pass");
}
1.9.3p194 :004 > UserSettings.first.updated_at
NoMethodError: undefined method `updated_at' for #<UserSettings:0x007fb2f085f2a0>
from /Users/arthurnn/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.12/lib/mongoid/attributes.rb:166:in `method_missing'
from (irb):4
from /Users/arthurnn/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.6/lib/rails/commands/console.rb:45:in `start'
from /Users/arthurnn/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.6/lib/rails/commands/console.rb:8:in `start'
from /Users/arthurnn/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.6/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
1.9.3p194 :005 > UserSettings.first.cache_key
1.9.3p194 :008 > Atm.create! :name => 'td'
=> #<Atm _id: 50da19f3803a9372a4000001, name: "td", _type: "Atm">
1.9.3p194 :009 > Item.create! :name => 'item'
=> #<Item _id: 50da19fb803a9372a4000002, name: "item", _type: "Item">
1.9.3p194 :010 > Item.all.map &:_type
=> ["Atm", "Item"]
1.9.3p194 :011 > Item.all
=> #<Mongoid::Criteria
selector: {}
options: {}
BSON::ObjectId.new
user system total real
10gen-mongo 0.910000 0.000000 0.910000 ( 0.920081)
moped 0.250000 0.000000 0.250000 ( 0.247459)
BSON::ObjectId.to_s
user system total real
10gen-mongo 5.920000 0.010000 5.930000 ( 5.929247)
moped 5.090000 0.010000 5.100000 ( 5.095296)
require "benchmark"
require 'moped'
require 'mongo'
include Mongo
@client = MongoClient.new('localhost', 27017)
@db = @client['mongo_benchmark']
@coll = @db['mongo10gen']
@coll.remove
class Order
include Mongoid::Document
field :state
field :sent_at, type: Time
field :number, type: Integer
index({ sent_at: 1 })
scope :sent, any_in(state: [:sent]).desc(:sent_at)
@arthurnn
arthurnn / i18n.rb
Last active December 14, 2015 10:09
module I18n
extend ActiveSupport::Concern
included do
attr_accessor :forced_locale
end
module ClassMethods
def i18n_field(*syms)
@arthurnn
arthurnn / deploy.rb
Last active December 14, 2015 18:29 — forked from mpelos/deploy.rb
Locaweb deploy capistrano script
require "bundler/capistrano"
set :application, "set your application name here"
set :user, "set your Locaweb's user"
set :server_addr, "set the Locaweb's server ip address or your ftp address"
set :deploy_to, "/home/#{user}/rails_app/#{application}"
set :rails_env, "production"
set :use_sudo, false
# Git settings
class FaviconLogosUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
version :favicon do
process :resize_to_fit => [32, 32]
process :convert => :ico
def full_filename(for_file)
"favicon.ico" if original_filename
end