Skip to content

Instantly share code, notes, and snippets.

View acnalesso's full-sized avatar

Antonio C Nalesso Moreira acnalesso

View GitHub Profile
@acnalesso
acnalesso / Gemfile , spec_helper.rb, and guardfile
Last active December 15, 2015 04:29
Spork to reload models when change is made, Using Guard, Spork, and RSpec
OS: Linux Debian Lenny
gem versions:
factory_girl_rails-4.2.1
spork-1.0.0rc3
guard-1.6.2
rails-3.2.9
rspec-rails-2.13.0
Gemfile:
@acnalesso
acnalesso / issue01
Last active December 15, 2015 10:09
Create your custom controller for CanCan to skip_authorization_check
rails version: 3.2.9
ruby 1.9.3p125 (2012-02-16 revision 34643)
devise 2.2.3
[i686-linux]
OS: Debian Linux Lenny(I know... gonna update to Squeeze)
Listening to: http://www.youtube.com/watch?v=ab5hLh_Nurg&feature=share&list=RD02EXf5tcjdO8s while programming :)
Controller:
class Guards::SessionsController < Devise::SessionsController
before_filter :authenticate_admin!
@acnalesso
acnalesso / gist:5651567
Created May 26, 2013 03:02
No such file or directory
Searching for binary rubies, this might take some time.
Installing requirements for debian, might require sudo password.
ruby-2.0.0-p195 - #configure
ruby-2.0.0-p195 - #download
ruby-2.0.0-p195 - #validate archive
ruby-2.0.0-p195 - #extract
ruby-2.0.0-p195 - #validate binary
ruby-2.0.0-p195 - #setup
Saving wrappers to '/home/nbit001/.rvm/wrappers/ruby-2.0.0-p195'...........
ruby-2.0.0-p195 - #importing default gemsets, this may take time......................
$ rvm install 1.9.3 --debug
1.9.3 - install
Searching for binary rubies, this might take some time.
Found remote file https://rvm.io/binaries/debian/6.0/x86_64/ruby-1.9.3-p429.tar.bz2
rvm_autolibs_flag=disabled
ruby-1.9.3-p429 - #configure
ruby-1.9.3-p429 - #download
Archive checksum matched, not downloading
Downloaded archive checksum matched.
$ rvm install 1.9.3 --with-gcc=gcc --debug | tee ~/Desktop/ruby1_9_output
1.9.3 - install
__rvm_setup_compile_environment_setup ruby-1.9.3-p429
rvm_autolibs_flag=disabled
__rvm_setup_compile_environment_requirements ruby-1.9.3-p429
__rvm_setup_compile_environment_osx_compiler ruby-1.9.3-p429
__rvm_setup_compile_environment_architectures ruby-1.9.3-p429
__rvm_setup_compile_environment_gcc47plus ruby-1.9.3-p429
__rvm_setup_compile_environment_bison ruby-1.9.3-p429
@acnalesso
acnalesso / rb2.0_output
Created May 27, 2013 21:33
mpapis: find /home/nbit001/.rvm/rubies/ruby-1.9.3-p429
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0/ruby
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0/ruby/dl.h
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0/ruby/version.h
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0/ruby/digest.h
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0/ruby/intern.h
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0/ruby/re.h
/home/nbit001/.rvm/rubies/ruby-2.0.0-p195/include/ruby-2.0.0/ruby/regex.h
@acnalesso
acnalesso / admin_controller_spec.rb
Created May 28, 2013 00:59
Good or Bad? Poor or Fine?
require 'spec_helper'
describe AdminController do
# Stubs out, returns true. Logged in as Admin
login(true)
describe 'GET' do
let(:admin) { mock_model(Admin) }
@acnalesso
acnalesso / asset.rb
Last active May 14, 2016 15:16
Create Paperclip thumbnails out of video files using avconv as ffmpeg is deprecated.
# app/model/
# Your model where you've defined has_attached_file
# Do not define :original in your styles
class Asset < ActiveRecord::Base
attr_accessible :position, :picture_cover, :asset
belongs_to(:assetable, :polymorphic => true)
has_attached_file :asset,
:styles => {
@acnalesso
acnalesso / output
Created July 16, 2013 09:16
impressionist_#96
FIRST_TIME
test_app$ rails g impressionist --orm active_record -f
invoke active_record
remove db/migrate/20130716090507_create_impressions_table.rb
create db/migrate/20130716091134_create_impressions_table.rb
create config/initializers/impression.rb
SECOND_TIME, impression.rb already exists
test_app$ rails g impressionist --orm active_record -f
@acnalesso
acnalesso / specs.watchr
Created September 20, 2013 21:10
watchr script to automate tests
#-*- ruby -*-
#
# MAKE SURE YOU CHANGE THE YOUR TESTS DIR
# AND YOUR LIB DIR
#
# Run me with:
# $ watchr specs.watchr