Skip to content

Instantly share code, notes, and snippets.

View jbasdf's full-sized avatar

Justin Ball jbasdf

View GitHub Profile
@jbasdf
jbasdf / Ember TextField With Arrow Keys
Created February 25, 2014 04:13
Ember Textfield with arrow bindings
{{ view App.Textfield
class="form-control"
placeholderBinding="view.prompt"
valueBinding="view.value"
viewName="inputField"
arrow-up="arrowUp"
arrow-down="arrowDown"
}}
@jbasdf
jbasdf / Ember arrow keys
Created February 25, 2014 04:12
Ember bind arrow keys
App.Textfield = Ember.TextField.extend({
init: function() {
this._super();
this.on("keyUp", this, this.interpretKeyEvents);
},
interpretKeyEvents: function(event){
var map = TM.Textfield .KEY_EVENTS;
var method = map[event.keyCode];
@jbasdf
jbasdf / ember-textfield
Created February 25, 2014 04:08
Ember Textfield
{{ view Ember.Textfield
class="form-control"
placeholderBinding="controller.prompt"
valueBinding="controller.value"
onEvent="keyPress"
action="typing"
}}
@jbasdf
jbasdf / inactivity-warning.js
Created January 2, 2014 23:14
Javascript for Ember inactivity component
App.InactivityWarningComponent = Ember.Component.extend({
active: false,
inactiveTimeout: 12000000, // Amount of time before we redirect to the sign in screen - the session should have expired by this point. (20 minutes)
warningTimeout: 30000, // Amount of time the user has to perform an action before the last keep alive fires - 30 seconds
timeout: 1170000, // 19.5 minutes. We want to be less than the 20 minute timeout to be sure the session is renewed.
didInsertElement: function(){
//if($('meta[name="in-development"]').attr('content')){ return; } // Uncomment and add a meta tag to your head if you want to avoid session timeout in development
var context = this;
@jbasdf
jbasdf / inactivity-warning.hbs
Created January 2, 2014 23:09
Handlebars template for Ember inactivity warning component.
<div class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button {{action 'close'}} type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="tmModalLabel">Inactivity Warning</h4>
</div>
<div class="modal-body">
You will be logged out in 30 seconds.
</div>
@jbasdf
jbasdf / chosen.jquery.js
Created October 10, 2013 15:40
Chosen modified to provide a clean search text callback.
// Chosen, a Select Box Enhancer for jQuery and Prototype
// by Patrick Filler for Harvest, http://getharvest.com
//
// Version 1.0.0
// Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com
// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
// This file is generated by `grunt build`, do not edit it by hand.
(function() {
@jbasdf
jbasdf / ember_chosen.js
Created October 7, 2013 18:34
Ember.Select using Chosen
App.Chosen = Ember.Select.extend({
multiple: false,
width: '95%',
disableSearchThreshold: 10,
searchContains: true,
attributeBindings:['multiple', 'width', 'disableSearchThreshold', 'searchContains'],
didInsertElement: function(){
this._super();
@jbasdf
jbasdf / ember_models.rake
Created October 1, 2013 23:31
Generate models for Ember Data 1.0.0 beta using Ruby on Rails Schema.
namespace :ember do
desc "Build ember models from schema"
task :models => :environment do
# Change these values to fit your project
namespace = 'App' # The Ember application's namespace.
# The directory where ember models will be written. We drop them
# in the tmp directory since we might not want an ember model for every table in the
@jbasdf
jbasdf / ember_models.rake
Created September 28, 2013 17:46
Create Ember.js models from Rails Schema
namespace :ember do
desc "Build ember models from schema"
task :models => :environment do
# Change these values to fit your project
namespace = 'App' # The Ember application's namespace.
output_dir = File.join(Rails.root, "app/assets/javascripts/common/models") # The directory where ember models will be written
schema_file = File.join(Rails.root, 'db/schema.rb')
@jbasdf
jbasdf / scan_cameras.rb
Created June 24, 2013 00:00
Output Camera Models for iPhoto
#!/usr/bin/env ruby
require 'rubygems'
require 'exifr'
require 'fileutils'
require 'logger'
class PictureScanner
def self.scan_files(source_dir)
cameras = {}