Skip to content

Instantly share code, notes, and snippets.

module Pyrite
module Dsl
# Wait for a specific element, the page to load
# or an AJAX request to return
def wait_for(element)
case element
when :page_load
browser.wait_for_page_to_load 10
when :ajax
browser.wait_for(:wait_for => :ajax, :javascript_framework => Pyrite.js_framework)
module Delayed
class Worker
def handle_failed_job(job, error)
ExceptionNotifier.notify(error, :data => {:session => job.attributes})
job.last_error = error.message + "\n" + error.backtrace.join("\n")
say "* [JOB] #{name} failed with #{error.class.name}: #{error.message} - #{job.attempts} failed attempts", Logger::ERROR
reschedule(job)
end
end
@chrisvariety
chrisvariety / oinkplus.user.js
Created April 6, 2011 17:46
Fix for myspace april 6th, 2011
// ==UserScript==
// @name OiNKPlus
// @author Indieana AKA interonaut, indieana@mailpuppy.com
// @namespace http://www.myspace.com/interonaut
// @description Enables easy artist discovery by adding similar artists, tags, short bio and last.fm & Myspace player to torrent details pages.
// @include *waffles.fm/details.php*
// @include *88.80.6.249/details.php*
// @include *what.cd/torrents.php?id*
// @include *what.cd/artist.php?id*
// @include *stmusic.org/details.php*
@chrisvariety
chrisvariety / Gemfile
Created June 3, 2011 19:53
heroku redis test on cedar
gem 'redis_on_heroku'
@chrisvariety
chrisvariety / oinkplus.user.js
Created July 15, 2011 01:19
oinkplus 18 w/ myspace fixed
// ==UserScript==
// @name OiNKPlus
// @author Indieana AKA interonaut, indieana@mailpuppy.com
// @namespace http://www.myspace.com/interonaut
// @description Enables easy artist discovery by adding similar artists, tags, short bio and last.fm & Myspace player to torrent details pages.
// @include *waffles.fm/details.php*
// @include *88.80.6.249/details.php*
// @include *what.cd/torrents.php?id*
// @include *what.cd/artist.php?id*
// @include *libble.com/torrents.php?id*
@chrisvariety
chrisvariety / production.rb
Created May 2, 2012 13:49
Rack Domain redirect
XXX.configure do
require 'rack_domain_redirect'
config.middleware.insert 0, Rack::DomainRedirect
end
// Templating
// Adds the method "twirl" to every view to render its mustache template into itself
// Assumes views are keeping templates in: options.templates.tmpl_name
// twirl() -> renders options.template
// twirl(tmpl_name) -> renders options.templates.tmpl_name
_.extend(Backbone.View.prototype, {
twirl: function(tmpl_name) {
We have some public endpoints that are undocumented as you noticed. There are two of them, the first records Autocomplete Selections (in the dropdown) and the second records clicks on full-text search results (from the results page). The difference is very subtle since we try to keep the URLs short (/pas vs. /pc).
Autocomplete Selections:
/api/v1/public/analytics/pas
Full-text Clicks:
/api/v1/public/analytics/pc
There are a couple of ways to use these. The one that is leveraged by the JS libraries is a little more difficult since it requires use of the Swiftype internal document ID. The other way uses the document type's slug and the document's external_id. Here are example calls for that:
// from underscore.js
var throttle = function(func, wait) {
var context, args, timeout, result;
var previous = 0;
var later = function() {
previous = new Date;
timeout = null;
result = func.apply(context, args);
};
return function() {

Keybase proof

I hereby claim:

  • I am speedmanly on github.
  • I am sync (https://keybase.io/sync) on keybase.
  • I have a public key whose fingerprint is 90CF 5660 3150 874B BAB1 507D D844 74D3 2939 950A

To claim this, I am signing this object: