Skip to content

Instantly share code, notes, and snippets.

View bittersweetryan's full-sized avatar

Ryan Anklam bittersweetryan

View GitHub Profile
@bittersweetryan
bittersweetryan / .bash_profile
Last active December 21, 2015 05:48
Add GIT branch in OSX Terminal. Add this code to the end of your ~/.bash profile.
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@bittersweetryan
bittersweetryan / gist:6142060
Last active December 20, 2015 13:49
Tips and Tricks for testing JavaScript

#JavaScript Unit Testing Tips and Tricks#

###Please add your your tips and tricks for unit testing JavaScript as comments to this gist. I'll pull them into the main text and credit your contribution.###


  • Create/use snippits to scaffold testing methods ( i.e. if you are using BDD scaffold describe and it methods)
  • Write tests with the same care as production code
  • DRY. Factor out repeated code into methods
@bittersweetryan
bittersweetryan / gist:6104269
Last active December 20, 2015 08:59
This trick will dynamically load NPM tasks instead of having to load them manually.
/*
first install matchdep via NPM: npm-install matchdep --save-dev
then replace all of your grunt.loadNpmTasks( 'taskname' ) code with the following line:
*/
//dynamically load tasks
require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks );
; (function ($, _, Backbone, nmConnect) {
var createReportView = Backbone.View.extend({
el: '#CreateReportSection',
initialize: function() {
var selectPagesContainer = $('#SelectPagesContainer');
var invstCheckbox = selectPagesContainer.find('[id$=InvstCheckbox]');
var insuranceCheckbox = selectPagesContainer.find('[id$=InsuranceCheckbox]');
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Jacob Rus</string>
<key>comment</key>
<string>Created by Jacob Rus. Based on ‘Slate’ by Wilson Miner</string>
<key>name</key>
<string>Cowboy - Presentation</string>
var server = sinon.fakeServer.create();
server.respondWith(
'PUT',
'http://localhost/JavaScriptLogging.ashx.+',
[
200,
{ "Content-Type": "application/json" },
@bittersweetryan
bittersweetryan / gist:5876298
Created June 27, 2013 13:15
jQuery chaining formatting
$( '#selector')
.on('click', function(){
...
})
.on('mouseenter', function(){
...
});
<?
require_once '_header.php';
$db = $sql -> OpenSafeConnection(); //see below
$sql = "SELECT firstname FROM jobapplications WHERE firstname = ?";
$query = $db->prepare( $sql );
$name = 'Nicole';
var SubWidget = function( name ){
this.name = name;
this.messages = [];
};
var Widget = function(){
this.messages = [];
};
Widget.prototype.type='Widget';
var SubWidget = function( name ){
this.name = name;