Skip to content

Instantly share code, notes, and snippets.

class Deflater
def initialize app
@app = app
end
def call env
if acceptable_method?(env) && compress?(env)
Rack::Deflater.new(app).call env
else
app.call env
@tatey
tatey / gist:7226311
Last active December 26, 2015 22:49
Specifying a partnerId.
<a id="tbd-btn-1" href="#">Go with friends</a>
<script type="text/javascript" src="https://js.thebestday.com/v1.js"></script>
<script type="text/javascript">
var openModal = function() {
var plan = new theBestDay.widget.Plan({
title: "Surry Hills Lunch Time"
});
var modal = new theBestDay.widget.Modal();
/**
* @license AngularJS v1.2.0-rc.3
* (c) 2010-2012 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, document, undefined) {'use strict';
/**
* @description
*
@tatey
tatey / gist:7016801
Created October 16, 2013 23:30
bin/karma Binstub that runs our javascript suite when given no arguments.
#!/bin/sh
if [ "$#" -eq 0 ]; then
$(npm bin)/karma start $(cd "$(dirname "$0")"; pwd)/../spec/javascripts/karma.conf.js --single-run
else
$(npm bin)/karma $@
fi
@tatey
tatey / gist:7006140
Last active December 25, 2015 16:29
#!/usr/bin/env ruby
if ARGV.empty?
system "$(npm bin)/karma start #{File.expand_path('../../spec/javascripts/karma.conf.js', __FILE__) --single-run}"
else
system "$(npm bin)/karma #{ARGV.join(' ')}"
end
#!/bin/sh
if [ "$#" -eq 0 ]; then
karma start path/to/config/relative/to/this/file
else
karma $@
fi
if default = Rake.application.instance_variable_get('@tasks')['default']
default.prerequisites.clear
end
task default: ['spec', 'konacha:run']
@tatey
tatey / how_id_do_it_in_ruby.rb
Created October 15, 2013 23:55
I am writing a shell script and I want to reference a config file that's relative to the executing script.
File.expand_path('../../../path/to/config/from/this/file', __FILE__)
@tatey
tatey / 0_card.js
Last active December 25, 2015 12:09
app.factory('card', function(payment) {
card = function(attrs) {
this.errors = {};
return this;
};
card.prototype.isValid = function() {
if (!payment.validateCardNumber(this.number)) {
this.errors.number = 'invalid';
var MyClass = function() {
this.myAttribute = 1;
return this;
};
MyClass.classMethod = function() {
};
MyClass.prototype.instancMethod = function() {