Skip to content

Instantly share code, notes, and snippets.

@bf4
bf4 / recruiter_wtf.txt
Created February 20, 2014 02:11
recruiter spam
From: Eldrich_AikonTech eldrich@aikontechnologiesinc.com
Subject: Immediate Role: Ruby and Rail Developer - CA
I hope you are doing well. Just writing to check your availability for new project. I have an opportunity for you. Please have a look at it and let me know your interest with your latest resume and following details ASAP.
Full Name:
Contact No. :
Email ID:
Work authorization (H1B/GC/Citizen):
Current Location (City, State):
@bf4
bf4 / colorize.rb
Last active August 29, 2015 13:56
ansi terminal colorize
# see https://github.com/rubychan/coderay/blob/master/lib/coderay/encoders/terminal.rb
# https://rubygems.org/gems/text-highlight
module Colorize
ESCAPE_CODES_PATTERN = Regexp.new('\e\[(?:\d;)?\d{1,2}m')
module ColorCode
module_function
def color(name, background=false)
number = case name
when 'black' then 30
when 'red' then 31
@bf4
bf4 / acts_as_slimgems.patch
Created March 14, 2014 21:53
acts as slimgems
diff --git a/Gemfile b/Gemfile
index 22bde6e..a429815 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,15 @@
source 'https://rubygems.org'
+require 'rubygems'
+def Gem.source_index
+ STDERR.puts "Guess who wants Gem.source_index? #{caller[0]}"
@bf4
bf4 / decode_this.txt
Created April 20, 2014 20:51
crazy jobs postings
http://chicago.craigslist.org/chc/eng/2994616197.html
Need highly skilled developers (Chicago)
Date: 2012-05-03, 4:52PM CDT
Reply to: see below
Too many unqualified candidates reply to our job postings, thus making the exceptional candidates hard to find. So, we've decided to raise the bar. We are looking for extraordinarily talented front-end developers (JavaScript/jQuery), Java Developers and Ruby on Rails developers. We provide credible access to many of the top tier interactive agencies, eCommerce companies, Financial firms, etc. in Chicago and nationwide. To apply for any of these positions you need to extract our contact info from the bottom of this ad. Once you decipher the code, send us a copy of your resume and we will contact you straight away. /* Must be authorized to work for any employer without restriction. No sponsorship. No telecommute */
/iw/wVOQboJrt13F26QK7BbtB/qq/gDmAPvWVW5WSiCp7nuxY5Em9vXKJpIK7r8Qp5Cu0PqAZsY/oavwTZE7rL+91wdu6uDDBadZ/tA/gA==
@bf4
bf4 / program.pdf
Last active August 29, 2015 14:00
RailsConf Program
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bf4
bf4 / bench.rb
Last active August 29, 2015 14:01
Benchmarking to_s vs. &&=. Result: &&= is faster
require 'benchmark/ips'
ENV = {}
Benchmark.ips do |x|
x.report("to_s, then to_s", "content_type = ENV['CONTENT_TYPE'].to_s.split(/\s*[;,]\s*/, 2).first.to_s.downcase")
x.report("to_s, then &&=", "content_type = ENV['CONTENT_TYPE'].to_s.split(/\s*[;,]\s*/, 2).first; content_type &&= content_type.downcase")
x.report("&&=, then &&=", "content_type = ENV['CONTENT_TYPE']; content_type &&= content_type.split(/\s*[;,]\s*/, 2).first; content_type &&= content_type.downcase")
end
@bf4
bf4 / airbrake_client.rb
Created May 21, 2014 19:17
Airbrake client api
#!/usr/bin/env ruby
#v3 api
#https://airbrake.io/api/v3/projects?key=KEY
#https://airbrake.io/api/v3/projects/PROJECT_ID/groups?key=KEY
#https://airbrake.io/api/v3/projects/PROJECT_ID/groups/GROUP_ID?key=KEY
#https://airbrake.io/api/v3/projects/PROJECT_ID/groups/GROUP_ID/notices?key=KEY
#https://airbrake.io/api/v3/projects/PROJECT_ID/groups/GROUP_ID/last-notice?key=KEY
#https://airbrake.io/api/v3/projects/PROJECT_ID/group-environments?key=KEY
#https://airbrake.io/api/v3/projects/PROJECT_ID/deploys?key=KEY
#https://airbrake.io/api/v3/projects/PROJECT_ID/deploys/GROUP_ID?key=KEY
@bf4
bf4 / server.sh
Created May 28, 2014 17:29
passenger server starting script
#!/usr/bin/env bash
# ./serve setup
# ./serve.sh start
# with jruby, can't daemonize so
# ./serve.sh start jruby
# TODO see if instead of checking for $2
# we can check if $RUBY_VERSION matches jruby
if [ ! -n "$1" ]
then
echo "Usage: ./serve.sh [start|stop|restart|status|setup]"
@bf4
bf4 / rails_background_sender.rb
Created June 22, 2014 19:35
Rails Mail background sender
module BackgroundSender
def self.serialize_mail(mail)
s = ""
# Mail#encoded strips bcc so we must add it manually
s << "Bcc: #{mail.bcc.join(", ")}\r\n" if mail.bcc.present?
s << mail.encoded
s
end
def self.deserialize_mail(serialized_mail)
@bf4
bf4 / ABOUT.md
Last active August 29, 2015 14:04
Bootstrap OSX Workstation Ruby/Homebrew/Git

Install as follows

\curl -sSL https://gist.github.com/bf4/38774a5e48660b264bde/download | \
  tar xzvf - --include '*setup' -O | bash