Skip to content

Instantly share code, notes, and snippets.

View mikebaldry's full-sized avatar

Michael Baldry mikebaldry

View GitHub Profile
input: testabc:abc AND x:'test abc' OR y:123 AND testing123:'something else'
expression
/ \
or <nil>
/ \________________
and \
/ \ and
testabc:abc x:'test abc' / \
y:123 testing123:'something else'
Random.unique do
.. stuff that uses Random.rand, but will always be unique numbers (if its been used before, it'll generate another) ...
end
@mikebaldry
mikebaldry / result
Created September 16, 2013 14:40
Rails asset_host failure
Failure/Error: expect(helper.image_url("blah.jpg")).to eq("http://this-is-a-test.com/assets/blah.jpg")
expected: "http://this-is-a-test.com/assets/blah.jpg"
got: "http://test.hosthttp://this-is-a-test.com/assets/blah.jpg"
(compared using ==)
def screenshot!
path = Tempfile.new(["ss", ".png"]).path
save_screenshot(path, full: true)
sleep 2
system("open #{path}")
sleep 1
end
def inspector!
page.driver.debug
def merge_json_params
body = request.body.read
request.body.rewind
params.merge!(ActiveSupport::JSON.decode(body)) if body != "" && request.format.json?
end
class Campaign < ActiveRecord::Base
has_many :daily_data
attr_accessible :start_date
def last_day_of_consecutive_daily_data
# meh
end
end
class Model
def duration=(value)
self.float_duration = process(value)
end
def duration
unprocess(self.float_duration)
end
end
checkToken: (token, cb) ->
@sql.query "SELECT id FROM users WHERE login = ? AND cti_token = ?", [@login, token], (err, result) ->
cb result.length == 1
class VersionDetection
constructor: (@persistentStorage, @callbacks) ->
execute: ->
installedVersion = this._parseVersion @persistentStorage["installedVersion"]
version = this._parseVersion this._getVersion()
return this._onInstalled(version) unless installedVersion
return if installedVersion.string == version.string
class ClickTracking
constructor: ->
@lastX = -1
@lastY = -1
this._hookEvent()
$(document).on "click", "*", (e) =>
this._trackClick(e)