Skip to content

Instantly share code, notes, and snippets.

View onyxrev's full-sized avatar

Daniel Connor onyxrev

View GitHub Profile
//= require ../../app/assets/javascripts/lib/polyfills
//= require_tree ./templates
//= require_tree ./frontend/templates
//= require_tree ./backend/templates
window.env = 'test';

Keybase proof

I hereby claim:

  • I am onyxrev on github.
  • I am danconnor (https://keybase.io/danconnor) on keybase.
  • I have a public key whose fingerprint is 3E5D 33CF 44C7 CCCC 6FDA 1844 2F4A 04F5 9A92 FFC5

To claim this, I am signing this object:

@onyxrev
onyxrev / Rakefile
Created April 14, 2015 22:28
Crazy SSH forwarding for Centurion through gateway
require 'yaml'
task :deploy do
servers_config = YAML::load( File.open( './config/servers.yml' ) )
task :staging do
servers = servers_config["staging"].values.flatten
# forward the docker port for each server to localhost
port_forwards = []
@onyxrev
onyxrev / image-size-detector.js
Created June 11, 2014 01:59
image size detector for use in determining the size of image that may or may not be loaded (in lieu of img.load)
// this imageSizeDetector works in lieu of img.onload
(function(jQuery){
jQuery.fn.imageSizeDetector = function(callback){
var $image = this;
var width = 0;
var height = 0;
var pollCount = 0;
var callback = callback;
var interval = setInterval(function(){
@onyxrev
onyxrev / application_controller.rb
Created March 1, 2014 22:16
General hackery with API-based auth and Devise
class ApplicationController < ActionController::Base
# ...
private
# from https://gist.github.com/josevalim/fb706b1e933ef01e4fb6
def authenticate_user_from_token!
email = params[:email].presence
user = email && User.where(email: email).first
@onyxrev
onyxrev / select2_helper.rb
Created October 14, 2013 04:11
Select2 search query and selection for Capybara
# usage:
# select2_choose("#some_element_id_with_select2_attached", :query => "Santa", :choose => "Santa Monica, California")
# NOTE: just make sure your 'choose' is unique in your results set
module Select2Helper
def select2_choose(id, options)
page.execute_script %Q{
i = $('#s2id_#{id} .select2-offscreen');
i.trigger('keydown').val('#{options[:query]}').trigger('keyup');
}
@onyxrev
onyxrev / jquery.ajax_io_patch.js
Last active December 19, 2015 16:29
Code snippet for AJAX I/O niceties like following redirects and passing callback URLs.
(function(){
jQuery.ajaxSetup({
/* this ugly shit is to ensure that Rails gets its happy little CSRF tokens */
'beforeSend': function(xhr) {
var token = $("meta[name='csrf-token']").attr("content");
xhr.setRequestHeader("X-CSRF-Token", token);
// since the anchor bit of the URL isn't sent by the
// browser, it's not available for the rails app in
// request.referrer. since we use the anchor bit of the