Skip to content

Instantly share code, notes, and snippets.

View stakes's full-sized avatar
💯

Jay Stakelon stakes

💯
View GitHub Profile
@stakes
stakes / gist:c160b6c2348e77763f3e
Created August 20, 2014 19:23
Subwah + Polytropon Mashup REEEEEEMIX (Insert Airhorn Here)
/*!
*
* stagas - polytropon
*
*/
var transpose = 0;
// patterns
@stakes
stakes / User.rb
Created January 22, 2012 22:56
Feature Flags / Rails + Mongoid
class User
include Mongoid::Document
# herein might appear a metric shitton of fields
# but what you need to know for feature flags follows
field :feature_flags, :type => Hash, :default => {}
# likewise, this is only what you need for
@stakes
stakes / pre-commit
Created November 22, 2011 02:39
Jamm Them Assets
#!/usr/bin/env ruby
require 'jammit'
print "JAMMIT: Looking for changes to tracked assets... "
# take a look at the status before compression
status_before = %x[git status --porcelain --untracked-files=no]
# package changed assets
Jammit.package!
# now take a look at the status after compressing assets
@stakes
stakes / config.rb
Created November 1, 2011 04:23
Wordpress Compass Configuration
http_path = "/"
css_dir = "stylesheets"
sass_dir = "src/sass"
images_dir = "images"
javascripts_dir = "javascripts"
output_style = :compressed
@stakes
stakes / Termfile
Created November 1, 2011 03:00
Termfile for SASS/Compass + Coffeescript + Wordpress
window do
run 'cd wp-content/themes/<YOUR_THEME_NAME>'
run "compass watch"
tab do
run 'cd wp-content/themes/<YOUR_THEME_NAME>'
run "jitter src/coffeescript javascripts"
end
{"previous":{"collection":{"get_date":"2011-03-24","id":1,"theme_name":"Terrible 2s - Fact or Fiction?","collection_type":"top 9","url_slug":"terrible-2s-are-nutz","comment_cue":"Do you have a terrible 2?","description":"","status":"draft"}},"next":null}
$('.colorpicker').bind('click', function(evt) {
var tgt = $(this);
tgt.parent().prepend('<div id="colorpicker-overlay"></div>');
$('#colorpicker-overlay').farbtastic(function() {
// handle form update
tgt.val(this.color);
tgt.css('background-color', this.color);
// update object
CSTM.colors[tgt.attr('id')] = this.color;
@stakes
stakes / moarbetter.rb
Created March 2, 2011 02:25
More efficient?
# Creates finders
def serialized_finder(serialized, accessors)
accessors.keys.each do |k|
method_name = "find_by_#{k}"
define_singleton_method(method_name) do |val=nil|
a = []
a << self.all.select { |s|
s[serialized][k] == val
}
a unless a.empty?
@stakes
stakes / attribute_serializer.rb
Created February 24, 2011 20:11
Attribute Serializer with dynamic finders
module AttributeSerializer
module ActiveRecordExtensions
module ClassMethods
def serializeable(serialized, serialized_accessors={})
serialize serialized, serialized_accessors.class
serialized_attr_accessor serialized, serialized_accessors
@stakes
stakes / validation
Created January 18, 2011 07:49
form validation
$("#volly_form").validate({
errorPlacement: function(error) {
$("span.error_container").html("Please double-check that you\'ve filled in both fields and provided a U.S. area code and mobile number.");
},
submitHandler: function() {
var request_data = {
full_name: $('#new_volly_full_name').val(),
phone: $('#new_volly_phone').val()
};