Skip to content

Instantly share code, notes, and snippets.

View garth's full-sized avatar

Garth Williams garth

View GitHub Profile
@garth
garth / SetIssueToResolved.sql
Last active August 29, 2015 14:04
JIRA issue resolution fixes
-- be sure to find out what the actual issues status number is for your workflow
update [jira].[dbo].[jiraissue]
set RESOLUTION = 10000, RESOLUTIONDATE = GETDATE()
where issuestatus = 10002 and resolution is null
@garth
garth / emberViewExtension.js
Created December 30, 2013 16:01
Add support for keyboard shortcuts in emberjs views. Include keymaster.js and emberViewExtension.js and then see the example usage.
// enable keyboard shortcuts in views
Ember.View.reopen({
bindKey: function (shortcut, action) {
var controller = this.controller;
window.key(shortcut, function () {
controller.send(action);
});
},
unbindKey: function (shortcut) {
window.key.unbind(shortcut);
@garth
garth / Gruntfile.js
Created November 13, 2013 15:06
Grunt task to wait for a port to become open
'use strict';
var portscanner = require('portscanner');
var port = 3001;
module.exports = function (grunt) {
grunt.registerTask('waitForPort', 'Waits until a port is open', function() {
grunt.log.write('Waiting to the development server to come online...');
var done = this.async();
@garth
garth / private.xml
Created October 21, 2013 18:39
To use a UK PC keyboard with a mac. Install UK layout (http://liyang.hu/osx-british.xhtml) and select PC British (105 alt) in keyboard settings. Then install KeyRemap4MacBook (https://pqrs.org/macosx/keyremap4macbook/index.html.en). Add the following to the private xml and select Fix Euro, PC Style End/Home #2 and PC Style PageUp/PageDown.
<?xml version="1.0"?>
<root>
<item>
<name>Fix Euro</name>
<identifier>private.fix_euro</identifier>
<autogen>__KeyToKey__ KeyCode::KEY_4, VK_OPTION, KeyCode::KEY_2, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L</autogen>
</item>
</root>
@garth
garth / runner.js
Created October 9, 2013 14:01
A PhantomJS test runner for qunit that includes a built in web server to host the JavaScript files and auto generate test.html This is especially useful when working in complex environment where running up a full web server during your automated build process might be difficult, since PhantomJS hosts and executes the tests without any external d…
var system = require('system');
var fs = require('fs');
if (system.args.length !== 2) {
console.log('Usage: runner.js website-base-path');
phantom.exit(1);
}
var basePath = system.args[1];
var outputFile = basePath + '/test.html';
@garth
garth / _input_text.hbs
Last active February 16, 2017 19:56
Example code for emberjs form validation. Working example can be seen here http://jsbin.com/ifARet/4
<label class="control-label"
{{bind-attr for="view.inputField.elementId"}}>
{{view.label}}
</label>
{{input
typeBinding="view.type"
class="form-control"
placeholderBinding="view.placeholder"
valueBinding="view.value"
viewName="inputField"}}
@garth
garth / data_access.js
Created September 13, 2013 08:15
I had lots of problems getting ember data (1.0.0-beta.2) to work our back end services. After many hours of debugging I decided to write this hold us over until ember data stabilizes.
App.DataAccess = Ember.Object.create({
namespace: 'api',
cache: {},
getTypeName: function (type) {
return type.toString().match(/\w+$/);
},
isId: function (query) {
return typeof query === 'string' || typeof query == 'number';
@garth
garth / app.js
Created December 19, 2012 09:45
Packaging javascript with asset-rack example code
window.App = Ember.Application.create({})
require('./applicationController')
@garth
garth / clientAccess-lookup.js
Created November 30, 2012 20:44
Using Emberjs code on the server side with Nodejs
// enable emberjs globally
GLOBAL.Ember = { lookup: GLOBAL }
require('./vendor/ember/ember-runtime')
// define the client App object
GLOBAL.App = Ember.Application.create({})
// include ember models
require('./public/js/login')
@garth
garth / snockets-debug.coffee
Created November 22, 2012 19:49
Use snockets to package javascript files for debug output (with //@ sourceURL)
#entry point for js/coffee dependency tree
rootfile = 'root.js'
#get the file names and content
files = snockets.getCompiledChain rootfile, { async: false }
#package each file in eval with trailing //@ sourceURL
scripts = []
for file in files
script = file.js.replace(/\\/g, '\\\\').replace(/\n/g, '\\n').replace(/'/g, '\\\'')