Skip to content

Instantly share code, notes, and snippets.

var recursivelyOrderKeys = function(unordered) {
// If it's an array - recursively order any
// dictionary items within the array
if (Array.isArray(unordered)) {
unordered.forEach(function (item, index) {
unordered[index] = recursivelyOrderKeys(item);
});
return unordered;
}
@staxmanade
staxmanade / UIImage+FailFast.h
Created February 12, 2015 17:01
Fail Fast and assert when [UIImage imageNamed:name] cannot load an image
//
// UIImage+FailFast.h
//
// Created by Jason Jarrett on 2/11/15.
// Copyright (c) 2015 Jason Jarrett. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIImage (FailFast)
@staxmanade
staxmanade / forEach.js
Last active August 29, 2015 14:12
forEach implementation on the JavaScript Object
Object.prototype.forEach = function(callback) {
var key = 0;
for (key in this) {
if (this.hasOwnProperty(key)) {
if (callback.call(this, key, this[key]) === false) {
break;
}
}
}
return this;
@staxmanade
staxmanade / merge-wrapper.js
Last active December 1, 2018 02:45
JS & SH merge wrappers
#!/usr/bin/env node
'use strict';
/*
#!/bin/bash
#
# Wrapper script for git mergetool
# This requires ~/.gitconfig file to have
# the following (adjusting for paths):
#
# [merge]
{% assign series = '' %}
{% assign thisPost = nil %}
{% for post in site.posts %}
{% if post.url == page.url %}
{% assign series = post.series %}
{% assign thisPost = post %}
{% endif %}
{% endfor %}
{% assign count = '0' %}
<html dir="<$BlogLanguageDirection$>">
<head>
<title>301 Moved Permanently</title>
<noscript>
<ItemPage><Blogger><meta http-equiv="refresh" content="0,url=http://staxmanade.com/blog/<$BlogItemNumber$>"></Blogger></ItemPage>
<MainOrArchivePage><meta http-equiv="refresh" content="0,url=http://staxmanade.com"></MainOrArchivePage>
</noscript>
<script type="text/javascript">
document.location.href = '<ItemPage><Blogger>http://staxmanade.com/blog/<$BlogItemNumber$></Blogger></ItemPage><MainOrArchivePage>http://staxmanade.com</MainOrArchivePage>';
</script>
@staxmanade
staxmanade / downloadableGitHubFiles.js
Created February 21, 2014 22:41
downloadable github files
/*
*
* The hope was to be able to drag out of the browser files from github onto the file system.
* I thought I saw the prototype work correctly once, but can't get it working anymore :(
*
*
*
*
* License: Make It Work: ( someone help me make this work )
*
@staxmanade
staxmanade / Podcasts.opml
Last active January 2, 2016 21:48
OPML of the current podcasts I'm listening to. These are not in any particular order. I'm using the [Downcast](https://geo.itunes.apple.com/us/app/downcast/id393858566?mt=8&at=10lPYJ) iPhone app and set it to 2x speed for twice the listening throughput! (Unless an interviewee has a strong accent).
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Downcast Podcasts</title>
</head>
@staxmanade
staxmanade / ConvertJavaScriptToTypeScript.md
Last active February 14, 2019 06:56
Some notes on converting JS to TypeScript with the help of PowerShell

Convert an existing project to TypeScript?

Rename files from javascript to typescript

ls *.js -Recurse | foreach{ move-item $_ ($_.FullName.TrimEnd("js") + "ts") }

install grunt-typescript (There are other TypeScript packages out there but I tried this one and it worked)

npm install grunt-typescript --save-dev

@staxmanade
staxmanade / gist:6362371
Created August 28, 2013 05:16
Goofing around with TypeScript, interfaces, inheritance, generics etc...
interface IAmSomeInterface {
getNumber(): number;
}
interface IAmAGenericInterface<T extends IAmSomeInterface> {
getInstanceOfSomeInterface(id: number): T;
}
class ClassExtendingSomeInterface implements IAmSomeInterface {
getNumber() {