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 / my_test_spec.rb
Created March 28, 2014 01:43
How to run tests as if CanCan was loaded into the system.
before(:all) do
module CanCan; end
end
# ... test as if CanCan exists
after(:all) do
Object.send(:remove_const, :CanCan)
end
u = User.find(4)
=> #<User id: 4, .... >
u.save!
ActiveRecord::RecordInvalid: Validation failed: Path has already been taken
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/protected_attributes-1.0.5/lib/active_record/mass_assignment_security/associations.rb:109:in `create_record'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/protected_attributes-1.0.5/lib/active_record/mass_assignment_security/associations.rb:94:in `create!'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.3/lib/active_record/associations/builder/singular_association.rb:27:in `create_namespace!'
from /home/git/gitlab/app/observers/user_observer.rb:14:in `after_save'
from /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observing.rb:352:in `update'
@anlek
anlek / application.css.scss
Last active August 29, 2015 14:22
Adding Bootstrap to Rails 3+
//MAKE SURE YOU RENAME THE FILE TO application.css.scss (adding .scss)
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
@anlek
anlek / Node.js
Created June 8, 2015 23:03
Stress Testing Simple apps. Node VS Sinatra (On a macbook pro 15" Mid 2012)
ab -k -c 10 -n 100 http://localhost:1337/
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software:
Server Hostname: localhost
@anlek
anlek / cucumber.log
Created March 11, 2010 00:41
Issue when running cucumber with subdomains
Processing SessionController#new (for 127.0.0.1 at 2010-03-10 19:39:54) [GET]
Account Load (0.3ms) SELECT * FROM `accounts` WHERE (`accounts`.`subdomain` = 'example') LIMIT 1
Redirected to http://www.org/signin
Filter chain halted as [:fetch_account] rendered_or_redirected.
Completed in 13ms (DB: 13) | 302 Found [http://example.org/signin]
Processing SessionController#new (for 127.0.0.1 at 2010-03-10 19:39:54) [GET]
Rendering template within layouts/session
Rendering session/new
@anlek
anlek / account.feature
Created March 11, 2010 05:51
Issues with Cucumber and Subdomains when submitting a form. Found out that it was due to Capybara not playing well with subdomains
Scenario: Admin should be able to login to any account
Given I login as "admin@example.com" with password "1234" to subdomain "microsoft"
Then I should see "Signed in successfully"
And the subdomain should be "microsoft"
alias reload='. ~/.bashrc'
alias ea="$EDITOR ~/bin/dotfiles/bash/aliases && reload"
alias ee="$EDITOR ~/bin/dotfiles/bash/env && reload"
alias eh="$EDITOR ~/bin/dotfiles/bash/heroku && reload"
# Processes
alias tu='top -o cpu'
alias tm='top -o vsize'
# Projects
THIS DOCUMENT MOVED TO http://chneukirchen.github.com/rps/
AND http://github.com/chneukirchen/rps
= Ruby Packaging Standard
The aim of this document is two-fold. First, to specify a common
structure of how a Ruby package distributed as source (that is, but
not limited to, development directories, version-controlled
repositories, .tar.gz, Gems, ...) should conform to.
NoMethodError in Chapter_requests#show
Showing app/views/chapter_requests/show.html.haml where line #3 raised:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?
Extracted source (around line #3):
class UsersController < ApplicationController
#only showing new, but you'll most likely have index, show, edit, destroy and all those
def new
@user = current_group.users.new
end
def create
@user = current_group.users.new(params[:user])