Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am handerson on github.
  • I am heathanderson (https://keybase.io/heathanderson) on keybase.
  • I have a public key whose fingerprint is 69FE B984 7C01 0847 BB07 5CE5 36F7 C6C8 8A01 EA2C

To claim this, I am signing this object:

@handerson
handerson / combox.js
Last active August 29, 2015 14:03
Basic Select/Input Combo box
// Add a class of "combox" to a select element to activate
function clonePosition(elementToMove, elementToClone){
var $elementToClone = $(elementToClone);
var position = $elementToClone.position();
var top = position.top;
var left = position.left;
var width = $elementToClone.width() - 40;
$(elementToMove).css({"position": "absolute", "top": top, "left": left, "width": width});
var HighResolutionTimer = window.HighResolutionTimer = window.HighResolutionTimer || (function() {
var HighResolutionTimer = function(options) {
this.timer = false;
this.total_ticks = 0;
this.start_time = undefined;
this.current_time = undefined;
@handerson
handerson / codeclimate_averages.rb
Last active September 4, 2015 03:02
Calculates an organization's average test coverage & gpa from codeclimate
require 'net/http'
require 'json'
token = ''
uri = URI('https://codeclimate.com/api/repos?api_token=' + token)
response = Net::HTTP.get(uri)
repos = JSON.parse(response)
test_coverage = []
@handerson
handerson / jquery.scroll_to.js
Created June 14, 2010 14:45
jQuery plugin for a simple scroll to animation
// scroll to animation
// example usage: $('.scroll_to_here').scrollTo();
jQuery.fn.scrollTo = function(speed) {
if(speed === undefined ){
speed = 'slow';
}
$('html,body').animate({scrollTop: this.offset().top},speed);
};
@handerson
handerson / jquery.has_default_value.js
Created June 14, 2010 14:45
jQuery plugin that clears and restores a field's default value
// clears and restores a field's default value
// example usage (js): $('input.has_default').hasDefaultValue();
// example usage (html): <input class="has_default" default="This is displayed by default" type="text"/>
jQuery.fn.hasDefaultValue = function() {
function supports_input_placeholder() {
var i = document.createElement('input');
return 'placeholder' in i;
}
if(!supports_input_placeholder()){
@handerson
handerson / getUrlVars.js
Created July 7, 2010 23:53
Get URL Parameters values with jQuery
// from http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
@handerson
handerson / monkey_patch_sql2005_limit.rb
Created August 2, 2011 00:32
monkey-patch for SQLServerAdapter to support SQL Server 2005-style pagination
# monkey-patching SQLServerAdapter to support SQL Server 2005-style pagination
# inspired by
# - http://alexle.net/archives/tag/mislav-will_paginate-sqlserver-2005
# - http://www.sqlservercentral.com/articles/T-SQL/66030/
# - http://stackoverflow.com/questions/4871523/sql-server-2008-r2-pagination/4871591#4871591
# - https://gist.github.com/335683
# place the following at the bottom of environment.rb:
# require "#{RAILS_ROOT}/lib/monkey_patch_sql2005_limit.rb"
@handerson
handerson / Base File.sublime-settings
Created August 15, 2011 19:17
My Sublime Text 2 settings file
{
"color_scheme": "Packages/Color Scheme - Default/Novel.tmTheme",
"font_size": 12,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"rulers": [80],
"font_face": "Inconsolata",
"word_wrap": true,
"wrap_width":80
}
@handerson
handerson / .gitignore
Created September 2, 2011 14:37
My standard git ignore file for Ruby on Rails or Phonegap (or pretty much all projects)
# RoR/Padrino
log/**/*
api/log/**/*
tmp/**/*
api/tmp/**/*
bin/*
vendor/gems/*
!vendor/gems/cache/
.sass-cache/*
*.sqlite3