Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
@lukemelia
lukemelia / buffered_proxy.js
Last active May 5, 2016 20:47
Buffered Proxy, extracted from Yapp codebase
var empty, get, set,
__hasProp = {}.hasOwnProperty;
get = Ember.get;
set = Ember.set;
empty = function(obj) {
var key;
for (key in obj) {
if (!__hasProp.call(obj, key)) continue;
@qrush
qrush / gist:5301799
Created April 3, 2013 14:41
spring clean your git repos!
# remove any bad refs
git remote prune origin
# pipe into bash and auto-delete any branches that have been merged into master!
git log master --pretty=format:'%d' | grep '^ (origin' | tr -d ' ()' | sed 's/origin\//git push origin :/'
// Override DS.Adapter.didFindQuery only so that we can change the
// loader.populateArray function. Unfortunately, we can't just twiddle
// the populateArray function and let _super do the work. A hook would be nice.
didFindQuery: function(store, type, payload, recordArray) {
var loader = DS.loaderFor(store);
// ========================================
// Here's the only difference!
//
if (type.toString() === 'App.Photo') {
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active August 25, 2026 18:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@CodeOfficer
CodeOfficer / validators.js
Created January 17, 2013 16:02
Validators for ember-data
var get = Ember.get;
DS.Model.reopen({
validate: function() {
if (get(this, 'isDeleted')) {
return;
}
get(this, 'validators').forEach(function(validator) {
validator.fn.call(this, validator.meta.key(this.constructor), get(this, validator.attribute), validator.options);
}, this);
@wycats
wycats / ideas.md
Last active December 10, 2015 19:08

Router

// blogs.handlebars (and blogs/index.handlebars)
match("/blogs").to("blogs", function(match) {
  // blogs/starred.handlebars
  match("/starred").to("starred");
  // blog.handlebars (and blog/index.handlebars)
  match("/:blog_id").to("blog", function(match) {
    // posts.handlebars (and posts/index.handlebars)
@tomdale
tomdale / gist:4004913
Created November 2, 2012 23:10
Per-Type Adapters Proposal

Per-Type Adapter Hooks

Requirements

Many existing JSON APIs are not consistent between types. As JSON endpoints grew organically and were built by different engineers at different times, the style in which records are represented can vary wildly.

Historically, we have asked adapter authors to rely on the fact that the type of record is provided to all adapter hooks (either by passing a type argument, or by passing a record

@scottburton11
scottburton11 / gist:3222152
Created August 1, 2012 00:58
Audio Compression for Voiceover

About compression

Audio compression is used to reduce the dynamic range of a recording. Dynamic range is the difference between the loudest and softest parts of an audio signal. It was originally used to guard against defects when cutting wax and vinyl phonograph records, but generally became useful as a way of increasing the loudness of an audio recording without achieving distortion.

The goal of most compression applications is to increase the amplitude of the softest parts of a recording, without increasing the amplitude of the loudest parts.

Compressor anatomy

Compressors generally all have the same conceptual parts. However, not all compressors present variable controls for all parts to the user. If you don't see all of your compressor's controls here, there's a chance it either has a fixed value (and no control), or is named something else:

@trek
trek / unit.js
Created July 22, 2012 02:40
Run your mocha unit tests suite via casper.js
// get a Casper object.
// See http://casperjs.org/
var casper = require('casper').create();
// this will be evaluated inside the context of the window.
// See http://casperjs.org/api.html#casper.evaluate for notes on
// the difference between casper's running environment and the
// DOM environment of the loaded page.
function testReporter(){
// casper is webkit, so we have good DOM methods. You're
@n1k0
n1k0 / kw-positions.js
Created July 15, 2012 08:50
CasperJS script to retrieve keyword occurence positions within a given page
var casper = require('casper').create();
var positions = [];
var kw = 'JSON';
casper.start('http://phantomjs.org/', function() {
var pageHeight = this.evaluate(function() {
return document.body.scrollHeight;
});
if (pageHeight < 1) {
this.echo('no page height', 'ERROR').exit();