Skip to content

Instantly share code, notes, and snippets.

@xecutioner
xecutioner / asset_silence.rb
Created March 23, 2012 04:50
Silence Assets pipeline in server log
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
@xecutioner
xecutioner / README.md
Created October 28, 2012 14:21 — forked from briangonzalez/README.md
img2boxshadow - a ruby script to convert images to CSS [http://codepen.io/briangonzalez/details/AvrGI#pen-details-tab]

img2boxshadow.rb

a ruby script to convert images to CSS (box-shadows)

Installation

gem install rmagick    # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse
@xecutioner
xecutioner / Wikimeida_extraction.md
Last active August 29, 2015 13:57
Wikimedia article extractions

STEP 1: Use media labs tool to generate doc based xml from the wikipedia dump.


  • Get the latest copy of the articles from wikipedia download page.
> wget http://download.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles.xml.bz2
awk 'BEGIN { system("mkdir -p splitted/sub"++j) }
/<doc/{x="F"++i".xml";}{
if (i%5==0 ){
++i;
close("splitted/sub"j"/"x);
system("mkdir -p splitted/sub"++j"/");
}
else{
print > ("splitted/sub"j"/"x);
@xecutioner
xecutioner / git
Last active August 29, 2015 14:01
useful git gists
# GIT REMOVE FILE FROM ALL BRANCHES
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch contents.sql' \
--prune-empty --tag-name-filter cat -- --all
# GIT REMOTE BRANCH FETCH AND CREATE
git checkout --track origin/daves_branch
@xecutioner
xecutioner / tricks
Created May 25, 2015 11:01
Rails Tricks
#Migrate back but a specific verison only
rake db:migrate:down VERSION=20150406100828
[6/18/15, 2:44:59 PM] Kapil Nakhwa: s3 = AWS::S3.new
bucket = s3.buckets.create('dns-compat-bucket-name')
[6/18/15, 2:45:33 PM] Kapil Nakhwa: s3 = AWS::S3.new(
:access_key_id => 'YOUR_ACCESS_KEY_ID',
:secret_access_key => 'YOUR_SECRET_ACCESS_KEY')
bucket = s3.buckets['my-bucket'] # no request made

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@xecutioner
xecutioner / rspec_model_testing_template.rb
Last active May 29, 2017 07:19 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@xecutioner
xecutioner / git tricks
Last active August 16, 2016 09:28
git tricks
Remove merged branch
git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
Git log of code snippet
git log -S'the line from your file' -- path/to/your/file.txt