Skip to content

Instantly share code, notes, and snippets.

View venkatd's full-sized avatar

Venkat Dinavahi venkatd

View GitHub Profile
@venkatd
venkatd / episode.js
Created August 26, 2015 21:00
Behavior for jumping to the right place when you click on a time
$(document.body).ready(function(){
window.addEventListener("hashchange", forwardAudioForHash, false);
$("#simplecast-audio-player").bind("jPlayer_loadstart", forwardAudioForHash)
$("#simplecast-audio-player").bind("jPlayer_waiting", showLoading)
$("#simplecast-audio-player").bind("jPlayer_playing", hideLoading)
$("#simplecast-audio-player").bind("jPlayer_pause", hideLoading)
$('.player a.jp-loading').click(function(){
$("#simplecast-audio-player").jPlayer("pause", seconds);
});
ref.on("child_removed", function(snapshot) {
if (!resolved) {
return;
}
var record = store.getById(type, snapshot.name());
if (record !== null) {
store.deleteRecord(record);
}
}, _handleError);
Ember.StyleBinding = Ember.Mixin.create({
concatenatedProperties: ['styleBindings'],
styleBindings: [],
_attachStyleBindings: function() {
var properties = this.get('styleBindings');
// initialize getting properties so the observers start firing
this.getProperties(properties);
require 'spec_helper'
require 'device_auth/provider/basic'
require 'device_auth/provider/anonymous'
module DeviceAuth
describe API do
describe 'POST /api/v1/register' do
require 'spec_helper'
require 'device_auth/provider/basic'
require 'device_auth/provider/anonymous'
module DeviceAuth
describe API do
describe 'POST /api/v1/auth/register' do
development:
host: localhost
adapter: postgresql
encoding: utf8
database: reissued_development
pool: 5
username: venkat
password:
# Connect on a TCP socket. Omitted by default since the client uses a
var CustomFixtureAdapter = DS.FixtureAdapter.extend({
fixturesForType: function(type) {
if (!type.FIXTURES) {
type.FIXTURES = [];
}
return this._super(type);
},
createRecord: function() {
return this._super.apply(this, arguments);
},

Development

Top-down, what-if development

You want to write code from the top down. You start with the highest level code. Those one or two lines of code that will make everything work. Then you write what you would want and write your code that way. Because you are going top down, you're creating objects that don't exist and calling nonexistent methods on them. Doing this lets you define the usage before building the thing. Then you go down a level and repeat this process.

Your code as a product

You want to think of the methods you write, the objects you create, the APIs you design, and everything else as a product. Even if it's just you using it, imagine someone else will use it. This will lead to question such as

  • Does this name make sense? Or is it obvious?
  • How much work is it to use this? Am I creating an unnecessary burden on the user? Could I make this easier to use?
  • How would someone want this to work? Does it work the way they would want it? Can I move this a step further in th

What did I get done yesterday?

What's left for this week and what's my plan for today?

Am I on track to finish everything for this sprint? If not, why?

Anything that you need from others on the team that might have gotten lost?

Action steps

@venkatd
venkatd / jquery.event.special.imageload.js
Created September 17, 2011 19:51
jQuery image loaded special event
(function ($) {
function img_has_loaded(imgEl) {
var dfd = $.Deferred();
var img = new Image();
img.onload = function() {
if (!dfd.isResolved())
dfd.resolve();
}