Skip to content

Instantly share code, notes, and snippets.

View csaunders's full-sized avatar

Christopher Saunders csaunders

View GitHub Profile
@csaunders
csaunders / LongPageBug.html
Created April 20, 2011 14:58
Long page bug in jQuery Mobile?
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
</head>
<body>
<!-- NOTE: How to replicate bug -->
@csaunders
csaunders / gist:962800
Created May 9, 2011 16:10
Toolbar link issue
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
</head>
<body>
<div data-role="page" id="page1">
<div data-role="header"><h1>One</h1></div>
function reverse(arr) {
var start = 0, end = arr.length - 1;
while(start < arr){
var tmp = arr[start]
arr[start] = arr[end]
arr[end] = tmp;
++start, --end;
}
}
@csaunders
csaunders / gist:972779
Created May 15, 2011 00:39
Alter Table syntax
MigrationSet migrations = new MigrationSet(){{
version(1);
add( new CreateTable("table1", "c", "d", "e") );
version(2);
add(
new AlterTable()
{{
table("table1");
addColumn("f");
}});
@csaunders
csaunders / spine.ajax.prefix.js
Created June 17, 2011 14:28
Ajax Prefixes and Find by ajax query if Spine.Model doesn't exist locally.
(function(Spine, $){
if( typeof Spine.Model.Ajax === "undefined") { throw "This plugin is really intended for use with Ajax driven models"; }
var Model = Spine.Model;
Model.extend({
find: function(id) {
record = this.records[id];
if( !record) {
var self = this;
self.ajaxPrefix = self.singletonPrefix();
$.ajax({
@csaunders
csaunders / 1_this.clj
Created September 24, 2011 02:55
Parsing RTM Responses
(defn get-lists
"Calls the rtm api to retrieve lists, returning the attributes from the xml"
[state]
(if-let [list-xml (xml/to-xml (api/rtm-lists-getList state))]
(for [x (xml-seq list-xml) :when (= :list (:tag x))]
(:attrs x))))
@csaunders
csaunders / LayoutParams.java
Created December 11, 2011 23:41
I can haz layout params?
LinearLayout roundedCell = new LinearLayout(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
int drawableId = -1;
if(rounded.equals("top")) {
drawableId = R.drawable.list_view_heading_list;
layoutParams.setMargins(0, 0, 0, 1);
} else if(rounded.equals("bot")) {
drawableId = R.drawable.list_view_footer_list;
layoutParams.setMargins(1, 0, 0, 0);
}
prod = ShopifyAPI::Product.find(6)
before = prod.variants.collect{|v| "#{v.position} - #{v.option1}"}
prod.variants[0].position = 3
prod.variants[2].position = 1
prod.variants.collect(&:save)
prod = ShopifyAPI::Product.find(6)
after = prod.variants.collect{|v| "#{v.position} - #{v.option1}"}
# Apply to Shopify API #
Interested in working at Shopify? Don't use that form, you're a
developer and can clearly do better than that!
Instead you can apply to Shopify via our application API. Of course,
for the extra effort you will be given a higher priority than those
who simply apply via the webform.
# How? #
@csaunders
csaunders / found_it.sql
Created November 6, 2012 12:34
How do I shot web?
-- kick them to the curb unless they look like mick jagger
delete from measurements as m where m.id
in
(
-- This finds all of our duplicate measurements
select id from measurements
inner join (
select min(id) minid, keg_id, volume from measurements
group by keg_id, volume
having count(1) > 1