Skip to content

Instantly share code, notes, and snippets.

@ilyakatz
ilyakatz / gist:1590356
Created January 10, 2012 18:22
see the full real path from the symbolic link
#!/usr/bin/env python
import os,sys
print os.path.realpath(sys.argv[1])
@ilyakatz
ilyakatz / mouseflow_with_rails.rb
Created March 1, 2012 21:45
Mouseflow session support with Rails
require 'net/http'
require 'uri'
class Admin::MouseflowController < ApplicationController
#these are optional if you using authentication and ssl
skip_before_filter :authenticate_login!
def ssl_required?
false
@ilyakatz
ilyakatz / .gitconfig
Created June 26, 2012 15:12
Sample .gitconfig file
[user]
name = YOUR_NAME
email = YOU_EMAIL
[credential]
helper = osxkeychain
[core]
excludesfile = /Users/[YOURNAME]/.gitignore_global
quotepath = false
[help]
autocorrect = 1
@ilyakatz
ilyakatz / pre-commit.bash
Created July 10, 2012 22:25
Disable commits to master
#!/bin/bash
if [[ `git symbolic-ref HEAD` == "refs/heads/master" ]]
then
if [[ ! -f /tmp/master_commit ]]
then
echo "*************************"
echo "CANNOT COMMIT TO MASTER!"
echo "To override this behavior"
echo "touch /tmp/master_commit"
@ilyakatz
ilyakatz / mouseflow.js
Created July 12, 2012 21:39
Safe mouseflow script inclusion
(function () {
var msf_script = document.createElement('script');
msf_script.type = 'text/javascript';
msf_script.src =
('https:' == document.location.protocol ? 'https://' : 'http://') +
'cdn.mouseflow.com/projects/ba141427-dfd0-4d3a-acbe-37df41b6c8e0.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(msf_script, s);
})();
@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