Skip to content

Instantly share code, notes, and snippets.

View anlek's full-sized avatar
💬
Writing code...

Andrew Kalek anlek

💬
Writing code...
View GitHub Profile
@anlek
anlek / Versions
Created June 2, 2011 16:59
Getting a bignum too big to convert into `long' (RangeError) when running Bundle install on your server? Here is how I solved it with the help from evan on the bundler IRC channel
ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-linux]
gem -v
1.8.5
bundle -v
Bundler version 1.0.14
@anlek
anlek / log.txt
Created May 26, 2011 04:35
mongoid output for creating an index.
Thu May 26 00:32:41 [conn2] building new index on { coordinates: "2d" } for example_com_development.offices
mem info: before index start vsize: 2565 resident: 20 mapped: 80
Thu May 26 00:32:41 [conn2] external sort root: /usr/local/var/mongodb/_tmp/esort.1306384361.1156987600/
Thu May 26 00:32:41 [conn2] d->nIndexes was 3
Thu May 26 00:32:41 [conn2] IndexDetails::kill(): couldn't drop ns example_com_development.offices.$coordinates_2d
Thu May 26 00:32:41 [conn2] insert example_com_development.system.indexes exception 13026 geo values have to be numbers: { 0: null, 1: null } 6ms
class UploadController < ApplicationController
def admission
@all=Upload.all
params[:upload]['item'] += "_#{Time.now.to_i}" if params[:upload]['item'].present?
#doing Time.now.to_i will give you better results for filenames then to_s
@upload=Upload.new(params[:upload])
#@upload.uploaded_at = Time.now #This should happen automagically though
if @upload.save
flash[:notice]="File uploaded successful,please wait for processing "
else
@anlek
anlek / application.rb
Created January 6, 2011 16:24
external.config
c = Configuration.new
c.instance_eval(File.read('config_file.rb'))
@anlek
anlek / paperclip_mongoid.rb
Created August 12, 2010 17:29
Put in your initialiers folder, allows paperclip to work with mongoid
module Paperclip
class << self
def logger #:nodoc:
Rails.logger
end
end
end
module Mongoid::Document::Extensions
module InstanceMethods
@anlek
anlek / console
Created July 23, 2010 23:13
Issue found when running bundle install
ubuntu /var/www/staging.example.com/current: sudo gem install bundler --pre
Successfully installed bundler-1.0.0.beta.9
1 gem installed
Installing ri documentation for bundler-1.0.0.beta.9...
Installing RDoc documentation for bundler-1.0.0.beta.9...
#^#^# JUST to show I have the latest bundler installed #^#^#
ubuntu /var/www/staging.example.com/current: bundle install
Fetching source index for http://rubygems.org/
fatal: Not a valid object name 5ebc1d8
An error has occurred in git. Cannot complete bundling.
@anlek
anlek / console_output.rb
Created July 23, 2010 19:30
Error that is killing my ruby process using Mogoid and embedded documents
Loading development environment (Rails 3.0.0.beta4)
>> p = Product.first
=> #<Product _id: 4c49f114b57f98927c000001, name: "test", created_at: Fri Jul 23 19:44:22 UTC 2010, updated_at: Fri Jul 23 19:44:22 UTC 2010>
>> pu = Purchaser.new(:name => 'bob')
=> #<Purchaser _id: 4c49f26fb57f989391000001, name: "bob">
>> p.purchasers << pu
=> [#<Purchaser _id: 4c49f26fb57f989391000001, name: "bob">]
>> p.save
src/tcmalloc.cc:353] Attempt to free invalid pointer: 0x225330
@anlek
anlek / Gemfile
Created July 21, 2010 19:01
Issues with bundler
source 'http://rubygems.org'
gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'credit_card_validator'
#Database stuff
gem "bson_ext"
gem 'mongoid', :git => 'git://github.com/durran/mongoid.git', :require => 'mongoid'
Using RSpec
Loading Spork.prefork block...
- Spork Diagnosis -
-- Summary --
config/application.rb
config/boot.rb
config/environment.rb
config/initializers/app_settings.rb
config/initializers/backtrace_silencers.rb
config/initializers/compass.rb
~/rails_apps/example.com% rails c
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from <class:Railtie> at /Users/andrew/.rvm/gems/ruby-1.9.2-head@example/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
/Users/andrew/.rvm/gems/ruby-1.9.2-head@example/gems/bson-1.0.3/lib/bson/bson_c.rb:24:in `serialize': keys must be strings or symbols (TypeError)
from /Users/andrew/.rvm/gems/ruby-1.9.2-head@example/gems/bson-1.0.3/lib/bson/bson_c.rb:24:in `serialize'
from /Users/andrew/.rvm/gems/ruby-1.9.2-head@example/gems/mongo-1.0.3/lib/mongo/cursor.rb:364:in `construct_query_message'
from /Users/andrew/.rvm/gems/ruby-1.9.2-head@example/gems/mongo-1.0.3/lib/mongo/cursor.rb:346:in `send_initial_query'
from /Users/andrew/.rvm/gems/ruby-1.9.2-head@example/gems/mongo-1.0.3/lib/mongo/cursor.rb:324:in `refill_via_get_more'
from /Users/andrew/.rvm/gems/ruby-1.9.2-head@example/gems/mongo-1.0.3/lib/mongo/cursor.rb:319:in `num_remaining'
from /Users/andrew/.rvm/gems/ruby-1.9.2-head@example