Skip to content

Instantly share code, notes, and snippets.

function gco($branch){
git checkout $branch
}
@sclarson
sclarson / sensitiveCd.ps1
Created September 21, 2014 13:18
Case sensitive cd/set-location in powershell 3
function GetCaseSensitivePath{
param($pathName)
$pathExists = Test-Path($pathName)
if (-Not $pathExists){
return $pathName
}
$directoryInfo = New-Object IO.DirectoryInfo($pathName)
if ($directoryInfo.Parent -ne $null){
@sclarson
sclarson / notSRP.js
Created June 10, 2014 15:54
Sometimes JS is beautiful, sometimes it is this.
function determineDateInYesMoveAndUpperCaseFirstWord(yesMove) {
var retVal = yesMove;
if (yesMove.charAt(0) != null
&& !isNaN(parseInt(yesMove.charAt(0),10))) {
var parsedTime;
if (yesMove.indexOf('/') > 0) {
if (yesMove.split('/').length < 3) { // split is one higher than the count of things split on
parsedTime = new moment(yesMove, 'MM/DD');
} else {
@sclarson
sclarson / findDifferences.js
Created May 12, 2014 16:29
Modified deep compare of JS objects... definitely not as nice as the way clojurescript handle mutation...
function findDifferences(objectA, objectB, onlyOwnProperties) {
var propertyChanges = [];
var objectGraphPath = ["this"];
(function(a, b) {
if (a.constructor == Array) {
// BIG assumptions here: That both arrays are same length, that
// the members of those arrays are _essentially_ the same, and
// that those array members are in the same order...
for (var i = 0; i < a.length; i++) {
objectGraphPath.push("[" + i.toString() + "]");

Keybase proof

I hereby claim:

  • I am sclarson on github.
  • I am sclarson (https://keybase.io/sclarson) on keybase.
  • I have a public key whose fingerprint is 484B BD70 B867 5566 1432 D767 34C6 8AFA 2F03 7396

To claim this, I am signing this object:

@sclarson
sclarson / output
Created March 7, 2014 21:29
Converting timezones to stupid abbreviations
US/Alaska, DOUBLECHECKPLZ
US/Aleutian, DOUBLECHECKPLZ
US/Arizona, DOUBLECHECKPLZ
US/Central, DOUBLECHECKPLZ
US/Eastern, DOUBLECHECKPLZ
US/Hawaii, DOUBLECHECKPLZ
US/Michigan, DOUBLECHECKPLZ
US/Mountain, DOUBLECHECKPLZ
US/Pacific, DOUBLECHECKPLZ
US/Samoa, DOUBLECHECKPLZ
@sclarson
sclarson / gist:9375931
Created March 5, 2014 20:29
All user activity YouTrack
created by: scl2 or commented: scl2 or updated by: scl2 or Assignee: scl2 or reported by: scl2
function ConvertToFormAndSubmit(databag, url, inputName) {
var index = 0;
var form = document.createElement('form');
form.setAttribute("method", "post");
form.setAttribute("action", url);
if (databag instanceof Array) {
for (index = 0; index < databag.length; index++) {
for (var prop in databag[index]) {
@sclarson
sclarson / httpCollect.js
Created December 21, 2013 15:48
nodeschoo.io's http collect
var http = require('http');
var total = 3;
var result = new Array();
function decrementAndPrint(element, data){
result[element] = data;
total -= 1;
if (total == 0){
console.log(result[0]);
console.log(result[1]);
var stuff = '';
var query = '';
$($('table')[0]).find('tr').each(function(){
tds = $(this).find('td');
stuff += 'public ' + $(tds[1]).text() + ' ' + $(tds[0]).text() + ' {get; private set;} \n';
query += ', ' + $(tds[0]).text();
});