Skip to content

Instantly share code, notes, and snippets.

@ilyakatz
ilyakatz / factory_girl_cache.rb
Created August 20, 2012 21:20 — forked from sobrinho/factory_girl_cache.rb
Object caching for factory girl
module FactoryGirl
module Strategy
class Cache
def association(runner)
runner.run(:cache)
end
def result(evaluation)
r = Repository.instance.read(evaluation)
if r
@ilyakatz
ilyakatz / before_compile_assets.rb
Created November 30, 2012 20:47
Selective compilation
last_revision = run "cat #{current_path}/REVISION"
assets_modified = run "git diff --name-only #{last_revision} | grep '/assets/' | wc -l"
if assets_modified.output.to_i > 0
info "#{assets_modified} asset files changed detected. Compiling assets"
`cd #{release_path} && PATH=#{release_path}/ey_bundler_binstubs:$PATH #{environment} rake assets:precompile RAILS_GROUPS=assets"`
else
info "No asset changes detected. Copying assets from previous"
current = shared_path + '/assets'
@ilyakatz
ilyakatz / eydeploy.rb
Created December 12, 2012 16:46
Selective skip of asset compilation
#You'll need to add an eydeploy.rb with this file in either your root directory or in the config directory
module EY
module Serverside
class Task
def app_needs_assets_when_changed?
assets_modified = run "git diff --name-only #{last_revision} | grep '/assets/' | wc -l"
if assets_modified.output.to_i > 0
# Call the original method to preserve behaviour.
test:
solr:
hostname: localhost
port: 8994
log_level: WARNING
development:
solr:
hostname: localhost
port: 8993
@ilyakatz
ilyakatz / routes.rb
Created January 4, 2013 21:28
script to determine all controllers in challengepost
def add_controllers(routes, all_controllers)
routes.each do |route|
requirements = route.requirements
controller_name = requirements[:controller]
action = requirements[:action]
if controller_name
all_controllers << "#{controller_name.camelize}Controller##{action}"
end
end
end
#base on http://ariejan.net/2011/09/24/rspec-speed-up-by-tweaking-ruby-garbage-collection
class DeferredGarbageCollection
MEM_FREE_FOR_GC_THRESHOLD = (ENV['MEM_FREE_FOR_GC_THRESHOLD'] || 500).to_f
@@last_gc_run = Time.now
def self.start
GC.disable if MEM_FREE_FOR_GC_THRESHOLD > 0
end
<!--
1. /System/Library/LaunchDaemons/nginx.plist
2. to load: sudo launchctl load -F /System/Library/LaunchDaemons/nginx.plist
3. to unload: sudo launchctl unload /System/Library/LaunchDaemons/nginx.plist
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Phone = #777
ISDN = 0
Password = yourpassword
Username = XXX-XXX-XXXX
Modem = /dev/ttyUSB1
Baud = 921600
Stupid Mode = on
@ilyakatz
ilyakatz / chrubuntu12.04.md
Last active December 17, 2015 05:59
html5 video

Ubuntu 12.04 on Samsung ChromeBook

Prerequisites

  • perform system update
    • if you do it later it will ask for all kind of permissions to override various config files
    • change password for root
      • default password is user

###Fix trackpad sudo apt-get install git

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" update ack command to be able to search through the gem files
:autocmd BufEnter * call SetCurrentGemHome()
function! SetCurrentGemHome()
call UpdateGemPath()
:command! -nargs=* AckGems execute 'Ack' <q-args> $GEM_PATH
endfunction
function! UpdateGemPath()
let $GEM_PREFIX=system("rbenv prefix")