Skip to content

Instantly share code, notes, and snippets.

View christocracy's full-sized avatar

Chris Scott christocracy

View GitHub Profile
Basel.mainPage = SC.Page.design({
// The main pane is made visible on screen as soon as your app is loaded.
// Add childViews to this pane for views to display immediately on page
// load.
mainPane: SC.MainPane.design({
childViews: [SC.TabView.design({
value: 'Welcome',
items: [{
title: 'Welcome', value: 'welcome'
// ==========================================================================
// Project: Basel - mainPage
// Copyright: ©2010 My Company, Inc.
// ==========================================================================
/*globals Basel */
// This page describes the main user interface for your application.
Basel.mainPage = SC.Page.design({
// The main pane is made visible on screen as soon as your app is loaded.
desc "modulate <theme> <hue> <saturation> <lightness>", "Modulate a theme. Specify h, s, l as floats, eg: 1.5"
def modulate(theme, hue, saturation, lightness)
ExtJS::Theme.each_image {|img|
path = img.filename.split('/')
filename = path.pop
dir = path.pop
say_status("modulate", File.join(dir, filename))
ExtJS::Theme.write_image(img.modulate(lightness.to_f, saturation.to_f, hue.to_f), File.join(ExtJS::Theme["theme_dir"], theme))
}
gsub_file(File.join(ExtJS::Theme["theme_dir"], theme, "defines.sass"), /\$hue:\s?(.*)/, "$hue: #{(hue.to_f-1)*180}")
@christocracy
christocracy / foo.js
Created October 19, 2010 18:33
foo.js
/**
* @class Foo
* @singleton
*/
Foo = (function() {
return {
/**
* getFoo
*/
getFoo: function() {
@christocracy
christocracy / gist:673761
Created November 12, 2010 05:22
Ext.CompositeElement extension to intelligently cluster dom-nodes so they don't overlap. Good for un-cluttering dense markers on a map.
/**
* @class Ext.ux.PinOverlap
* An Ext.CompositeElement extension which intelligently moves dom-elements so they don't overlap each other.
* Created for clustering markers on a Map to not overlap. First picks the most efficient direction to move-off
* of overlapped element, keeping track of where it moved from. If it overlaps another, it'll back-track and attempt
* to move around the element based upon the MOVE_* CONSTANTS below. Eg.
*
* +---------------------------
* | +-------------------+
* | | |
/**
* Loads an array of {@Ext.data.Model model} instances into the store, fires the datachanged event. This should only usually
* be called internally when loading from the {@link Ext.data.Proxy Proxy}, when adding records manually use {@link #add} instead
* @param {Array} records The array of records to load
* @param {Boolean} add True to add these records to the existing records, false to remove the Store's existing records first
*/
loadRecords: function(records, add) {
if (!add) {
this.data.clear();
}
@christocracy
christocracy / ShopifyAPICallLimit.rb
Created May 14, 2011 15:24
Hacking ActiveResource::Connection for Shopify API in order to read HTTP response header 'http_x_shopify_api_call_limit'. Simply require this code after your gems have been loaded. Caveat emptor: This hack modifies a private method of AR::Connection; H
class ActiveResource::Connection
# HACK 1: Add an attr_reader for response
attr_reader :response
def request(method, path, *arguments)
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
payload[:method] = method
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
payload[:result] = http.send(method, path, *arguments)
end
@christocracy
christocracy / gist:977765
Created May 18, 2011 00:26 — forked from anonymous/gist:977666
Some ext code
/**
* @overview FeatureForm.js
* Collection of components related to Feature Forms
* @author Dave Lazar
*/
/**
* @namespace CCA.feature
*/
Ext.namespace('CCA.feature');
@christocracy
christocracy / base.rb
Created May 18, 2011 14:57
Redefine #find_every to stitch together large Shopify queries where count > 250 into multiple calls.
# Example usage
begin
rs = ShopifyAPI::Order.all
rescue ShopifyAPI::Limits::Error
# Not enough credits to execute this request. Queue to DJ here, perhaps??
end
##
# Redefines #find_every to automatically compose resultsets from multiple ShopifyAPI queries due to API limit of 250 records / request.
# Seemlessly stitches all requests to #all, #find(:all), etc, as if there were no LIMIT.
@christocracy
christocracy / heroku_dj.rb
Created May 20, 2011 04:47
Setting up DelayedJob Workers on Heroku using DataMapper hooks
if ENV["HEROKU_APP"]
# Spin-up workers when jobs are created
Delayed::Job.after :create do
workers_needed = [Delayed::Job.count + 1, MAX_CONCURRENT_WORKERS].min
@username = ENV['HEROKU_USERNAME']
@password = ENV['HEROKU_PASSWORD']
@app = ENV['HEROKU_APP']
client = Heroku::Client.new(@username, @password)
client.set_workers(@app, workers_needed)
puts "- Initialized Heroku workers for ZipDecoder"