Skip to content

Instantly share code, notes, and snippets.

View imajes's full-sized avatar

James Cox imajes

View GitHub Profile
{
"status": "success",
"message": "",
"errors": {},
"activity": {
"uid": "R4LLUDAwWtIrqSWZc1BnTw",
"name": "Passage Proofreading: A Little Stranger on the Road (Fiction)",
"description": "Proofread a passage with eleven incorrect determiners and articles.",
"flags": [
"production"
" Section: Vim, Balloon Eval
" ------------------------
" balloon eval in ruby is really annoying
if has("balloon_eval") && has("unix")
set noballooneval
"set ballooneval
endif
main » DESIRED_CLASS
/price|product-price/i
main » node.attributes.values.map(&:to_s).first =~ DESIRED_CLASS
0
main » node.attributes.values.map(&:to_s).first =~ /price/
0
main » node.attributes.values.map(&:to_s).first == /price/
false
main » node.attributes.values.map(&:to_s).first == "price"
true
main » u = UserExperiment.find_by_email('---')
D, [2014-07-14T19:12:44.447225 #58587] DEBUG -- : UserExperiment Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."email" = '---' LIMIT 1
#<UserExperiment:0x000001021c8178> {
:id => 490,
:login => "imajes",
:email => "---",
:encrypted_password => "...",
:reset_password_token => "LdSS1bpDFTXyziEn7s_7",
:reset_password_sent_at => nil,
:remember_created_at => nil,
#!/bin/bash
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
git branch --track ${branch##*/} $branch
done
@imajes
imajes / gist:4314471
Created December 17, 2012 00:10
why i like awesome_print etc
(main)> magic = App.delegate.instance_variable_get('@magic_controller')
=> #<MagicController:0xc072f00>
(main)> ap magic.methods
[
[ 0] !() MagicController (NSObject)
[ 1] !=:(arg1) MagicController (NSObject)
[ 2] !~:(arg1) MagicController (NSObject)
[ 3] <<:(arg1) MagicController (UIViewController)
[ 4] <=>:(arg1) MagicController (NSObject)
[ 5]
@imajes
imajes / gist:4314310
Created December 16, 2012 23:46
Why I like awesome_print, rubymotion, etc..
(main)> magic = App.delegate.instance_variable_get('@magic_controller')
=> #<MagicController:0xc167ff0>
(main)> ap magic.methods
[
[ 0] !() MagicController (NSObject)
[ 1] !=:(arg1) MagicController (NSObject)
[ 2] !~:(arg1) MagicController (NSObject)
[ 3]
@imajes
imajes / test.rb
Created September 25, 2012 19:08
class Foo
class << self
attr_accessor :bar
end
def self.current_thing
@bar ||= calculate_current_thing
end
unless @_mGotData
# If the data starts with BOM, we know it is UTF
if data[0,3] == "\xEF\xBB\xBF":
# EF BB BF UTF-8 with BOM
@result = {"encoding"=> "UTF-8", "confidence"=> 1.0}
elsif data[0,4] == "\xFF\xFE\x00\x00":
# FF FE 00 00 UTF-32, little-endian BOM
@result = {"encoding"=> "UTF-32LE", "confidence"=> 1.0}
elsif data[0,4] == "\x00\x00\xFE\xFF":
# 00 00 FE FF UTF-32, big-endian BOM
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative