This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sessions | |
irb(main):001:0> s = "mystring" | |
=> "mystring" | |
irb(main):002:0> irb s | |
irb#1(mystring):001:0> size | |
=> 8 | |
> IRB::ReadlineInputMethod::HISTORY.to_a # prints session history |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bidding_pb2 | |
rq = bidding_pb2.BidResponse() | |
f = open('bid_response.bin', "rb") | |
rq.ParseFromString(f.read()) | |
print(rq) | |
f.close() | |
rq = bidding_pb2.BidRequest() | |
f = open('bid_request.bin', "rb") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Primer on representing non-printable characters in Lua code | |
function assert_equal(a, b) | |
if a ~= b then | |
error(a .. ' is not equal to ' .. b) | |
end | |
end | |
-- Escape sequences in string use decimal character codes, i.e. | |
assert_equal('\97\98\99', 'abc') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Swap Alt and Cmd keys. | |
keycode 37 = Control_L | |
keycode 133 = Alt_L Meta_L | |
keycode 64 = Super_L | |
keycode 108 = Super_R | |
keycode 134 = Alt_L Meta_L | |
keycode 108 = Control_R Multi_key | |
clear Shift | |
clear Lock | |
clear Control |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import realtime_bidding_proto_pb2 | |
msg = realtime_bidding_proto_pb2.BidRequest() | |
f = open('bid_request.bin', "rb") | |
msg.ParseFromString(f.read()) | |
f.close() | |
print msg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
smart_resource_url # => show || index || parent || root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'factory_girl_rails' | |
require 'rspec' | |
require 'rspec-rails' | |
require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example) | |
include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user` | |
def reload_factories! | |
FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences | |
# FactoryGirl.instance_variable_set(:@sequences, nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hoptoad < ActiveResource::Base | |
self.site = "https://your_account.airbrake.io" | |
class << self | |
@@auth_token = 'your_auth_token' | |
def find(*arguments) | |
arguments = append_auth_token_to_params(*arguments) | |
super(*arguments) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Resque.info | |
> Resque::Failure::Redis.count | |
> Resque::Failure::Redis.instance_eval { all(count - 1, 1) } # => last 1 failure | |
> Resque::Failure::Redis.requeue(0) | |
> Resque::Failure::Redis.clear |