Skip to content

Instantly share code, notes, and snippets.

View davewasmer's full-sized avatar

Dave Wasmer davewasmer

View GitHub Profile
@davewasmer
davewasmer / KinveyCollection.js
Created March 12, 2012 22:49 — forked from bhang/KinveyCollection.js
KinveyCollection
// User submission model
var UserSubmissionModel = Backbone.Model.extend({
// Backbone looks for 'id' by default
// However, MongoDB uses '_id' so we need to override it
idAttribute: '_id',
// Add a Basic Auth header to authenticate with Kinvey
sync: function(method, model, options) {
var self = this;
options.beforeSend = function(jqXHR) {
@davewasmer
davewasmer / gist:2036695
Created March 14, 2012 14:06
Visualize Hacker News
javascript:(function(n,j,l,k,m,p,i,o)%7Bif(!(m=n.jQuery)%7C%7Cl>m.fn.jquery%7C%7Ck(m))%7Bp=j.createElement(%22script%22);p.type=%22text/javascript%22;p.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+l+%22/jquery.min.js%22;p.onload=p.onreadystatechange=function()%7Bif(!i&&(!(o=this.readyState)%7C%7Co==%22loaded%22%7C%7Co==%22complete%22))%7Bk((m=n.jQuery).noConflict(1),i=1);m(p).remove()%7D%7D;j.documentElement.childNodes%5B0%5D.appendChild(p)%7D%7D)(window,document,%221.7.1%22,function(e,c)%7Bvar%20b=e(e(%22table%20table%22).get(1)).find(%22tbody%20tr%5Bstyle%5D%22);function%20f(h)%7Bvar%20k,g,l,m,j,n,i;k=h.prev();g=k.find(%22span%22).text();l=g.split(%22%20%22)%5B0%5D*1;m=k.text().split(%22%20%22)%5B4%5D;j=k.text().split(%22%20%22)%5B5%5D;n=null;if(j===%22minutes%22%7C%7Cj===%22minute%22)%7Bn=1%7Dif(j===%22hours%22%7C%7Cj===%22hour%22)%7Bn=60%7Dif(j===%22days%22%7C%7Cj===%22day%22)%7Bn=60*24%7Di=(m*n)/60;return%7Bpoints:l,time:i%7D%7Dfunction%20d(h,g)%7Breturn(h-1)/Math.pow((g+2),1.5)%7Dfunction%20a(
@davewasmer
davewasmer / Download Coffeescript Todos
Created March 28, 2012 16:44
Downloading Jason Giedymin’s Coffeescript port of the famous Backbone Todos app
$ git clone https://github.com/JasonGiedymin/backbone-todojs-coffeescript
@davewasmer
davewasmer / hack.sh
Created April 2, 2012 20:45 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@davewasmer
davewasmer / flat-boostrap-buttons.css
Created September 21, 2012 18:57
Flat Bootstrap buttons - no gradients, use only the flat colors from the variables.less file
.btn-primary { background: @btnPrimaryBackground; }
.btn-info { background: @btnInfoBackground; }
.btn-success { background: @btnSuccessBackground; }
.btn-warning { background: @btnWarningBackground; }
.btn-danger { background: @btnDangerBackground; }
.btn-inverse { background: @btnInverseBackground; }
.btn-primary:hover { background: @btnPrimaryBackgroundHover; }
.btn-info:hover { background: @btnInfoBackgroundHover; }
.btn-success:hover { background: @btnSuccessBackgroundHover; }
.btn-warning:hover { background: @btnWarningBackgroundHover; }
@davewasmer
davewasmer / .gitignore
Created January 18, 2013 23:15
My standard starting gitignore
# Generated files
# Node
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sankey Diagram</title>
<style>
@import url(../style.css?20120521);
#chart {
height: 500px;
}
<html>
<head>
<title>Cyclic Sankeys</title>
<style type="text/css">
#chart {
height: 500px;
}
.node rect {
cursor: move;
# ...
module.exports = ->
output = new stream.Transform(objectMode: true)
output._transform = (file, enc, callback) ->
# Pass this file along (do this *before* finding dependencies to preserve load order)
output.push(file)
@davewasmer
davewasmer / analyze-sass.rb
Created May 14, 2014 16:57
Sass Variable Visitor
require 'sass'
sass_engine = Sass::Engine.for_file('styles/app.scss', {load_paths: ['styles'], syntax: :scss})
tree = sass_engine.to_tree
class MyVisitor < Sass::Tree::Visitors::Base
def visit_variable(node)
@environment ||= Sass::Environment.new
var = @environment.var(node.name)