Skip to content

Instantly share code, notes, and snippets.

View rjz's full-sized avatar
👋
Hey there!

RJ Zaworski rjz

👋
Hey there!
View GitHub Profile
@rjz
rjz / retina-scaling.js
Created November 25, 2012 19:00
Scaling images for Retina Displays
/**
* Provide support for retina-specific image elements and background styles
* see: http://blog.rjzaworski.com/2012/11/scaling-images-for-retina-displays/
*/
(function (doc) {
var opts = {
find: /(.+)(\.\w{3,4})$/,
replace: '$12x$2',
@rjz
rjz / yabb.js
Created December 9, 2012 22:34
Yet Another Backbone Application
(function (window) {
var app = {
defaults: {
layout: "#layout"
},
init: function (opts) {
var options = _.extend({}, this.defaults, opts);
var template = $(options.layout).text();
@rjz
rjz / say.js
Created January 12, 2013 01:38
// say('hello')('world') & say('hello')('again')
function say (what) {
var words = this instanceof Array ? this : [],
bound = function (what) { return say.call(words, what); }
words.push(what);
bound.toString = function () { console.log(words.join(' ')) };
return bound;
}
# `factory` implements test fixtures as object factories.
factory = (fixture) ->
defaults = if _.isFunction(fixture) then fixture() else fixture
(klass, attrs) ->
if _.isFunction(klass) # build it
new klass(_.extend {}, defaults, attrs)
elseif _.isObject(klass) # no klass, just attrs
_.extend {}, defaults, klass
else #
defaults
@rjz
rjz / Gruntfile.js
Created May 31, 2013 22:48
Boilerplate Gruntfile
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// set up config
grunt.initConfig({
@rjz
rjz / gist:5873695
Created June 27, 2013 03:18
Rails default test_helper.rb @maiab
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
@rjz
rjz / grunt-ejsifier.js
Last active December 19, 2015 10:09 — forked from cookrn/_readme.md
Grunt task for client-side EJS
// Concat EJS templates for use in client-side application
// Based on https://gist.github.com/cookrn/3001401
//
// Supports features found in `_.template()` -- EJS extras not included!
//
var path = require('path');
module.exports = function (grunt) {
'use strict';
@rjz
rjz / hello_world.rs
Last active December 24, 2015 04:39
trait Filter {
fn apply(&self, s: &str) -> ~str;
}
struct HelloFilter;
impl Filter for HelloFilter {
fn apply(&self, s: &str) -> ~str { "Hello, " + s }
}
@rjz
rjz / stdin-and-fs-stream.js
Created March 12, 2014 05:18
Streaming from stdin or a file
// Depends on `through`
//
// $ npm install through
//
// Usage:
//
// $ echo 'hello' | node stdin-and-fs-stream.js
// $ echo 'hello' > tmp && node stdin-and-fs-stream.js tmp
//
var fs = require('fs'),
@rjz
rjz / ternary.coffee
Created March 14, 2014 00:33
CoffeeScript ternaries
# Docco must have missed the `0&+` operator...
e = ['truthiness', 'falsitude'][0&+false]
console.log e