Skip to content

Instantly share code, notes, and snippets.

View mariovisic's full-sized avatar

Mario Visic mariovisic

View GitHub Profile
@mariovisic
mariovisic / factory_girl.rb
Created March 22, 2013 04:56
Do not allow Factory Girl usage in unit tests.
# spec/support/factory_girl.rb
# This file is here to limit the use of factories to only integration tests and not unit tests.
#
# If you really want to use a factory you can add the tag :factories to a test
#
module FactoryGirlBlocker
mattr_accessor :disabled
def self.with_disabled
self.disabled = true
SSOServer::Application.config.session_store :active_record_store
ActiveRecord::SessionStore.session_class = UserSessionStore
@mariovisic
mariovisic / CORS.xml
Created February 10, 2013 08:57
CORS for fonts on AWS S3
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>https://www.desktoppr.co</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>315576000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@mariovisic
mariovisic / travis.rb
Created January 24, 2013 06:10
Travis Pro API error.
#!/usr/bin/env ruby
require 'travis/pro'
Travis::Pro.access_token = ENV['TRAVIS_ACCESS_TOKEN']
user = Travis::Pro::User.current
puts "Hello #{user.name}!"
# Get this error when running
# => gems/faraday-0.8.4/lib/faraday/response/raise_error.rb:8:in `on_complete': access denied (Travis::Client::Error)
@mariovisic
mariovisic / 0-readme.md
Created November 15, 2012 05:35 — forked from chendo/0-readme.md
Fast require patch for 1.9.3-p327
@mariovisic
mariovisic / Readme.md
Created November 7, 2012 10:10 — forked from jfirebaugh/gist:4007524
Installing Ruby 2.0.0-preview1 with RVM on OS X

Ruby 2.0.0-preview1 OSX RVM Install Instructions

First, make sure that you have the most recent rvm. Several bugs with 2.0.0-preview1 have recently been fixed.

Second, the openssl that comes with MacOS is too old for Ruby 2.0. You need to install a newer one with homebrew or the rvm pkg command.

brew update
@mariovisic
mariovisic / timer.rake
Created October 14, 2012 05:44
A rake task to display a rails rumble 2012 timer.
# lib/tasks/timer.rake
desc 'Opens a timer showing remaining rails rumble 2012 time'
task :timer => :environment do
seconds_remaining = Time.utc(2012, 10, 15).to_i - Time.zone.now.to_i
`open http://e.ggtimer.com/#{seconds_remaining}`
end
@mariovisic
mariovisic / graphite.md
Created September 24, 2012 01:09 — forked from caged/graphite.md
Installing Graphite on OS X Lion
@mariovisic
mariovisic / gist:3198197
Created July 29, 2012 12:00
Asset host benchmarking
# Using 4 different assets hosts (sharing cookies with frontend domain)
# 2.92, 2.39, 1.54, 1.51, 1.52, 1.50, 1.97, 2.03, 1.45, 1.96
1.7533333333 seconds average (Average of middle 6 scores)
# Using a single asset host (sharing cookies with frontend domain)
1.45, 1.34, 1.33, 1.17, 1.42, 1.72, 1.19, 1.26, 1.34, 1.17
1.3183333333 seconds average (Average of middle 6 scores)
# Using a single asset host with different domain (does not send cookies)
1.17, 1.15, 0.96, 0.85, 0.99, 0.93, 0.90, 0.95, 1.22, 1.18
@mariovisic
mariovisic / admin.rb
Created July 13, 2012 01:43
Mass assignment with roles
class Admin < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :remember_me, :name
attr_accessible :role, :as => :administrator
end