Skip to content

Instantly share code, notes, and snippets.

Ready to ship.

John C. Bland II johncblandii

Ready to ship.
View GitHub Profile
johncblandii / MergeAndBreakIntoFiles.macro
Created October 21, 2016 07:11
Microsoft Word macro to merge the current document and split each section into individual files
View MergeAndBreakIntoFiles.macro
Sub MergeAndBreakIntoFiles()
' Merges the current document and splits each section into individual files
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
.DataSource.ActiveRecord = wdFirstRecord
.Execute Pause:=False
View AnalyticsHelper.rb
require 'mixpanel-ruby'
class AnalyticsHelper
def initialize
@@tracker = Rails.application.secrets.mixpanel_token
def track user_id, action, properties=nil
Rails.logger.debug "Tracking: #{action}"
@@tracker.track(user_id, action, properties || {})
johncblandii / gist:b50a4136dfb9db283794
Last active August 29, 2015 14:21
AWS Opworks Custom JSON - Postgres, Nginx tweak, Sidekiq
View gist:b50a4136dfb9db283794
"deploy": {
"short_app_name_here": {
"database": {
"adapter": "postgresql",
"type": "postgresql"
"sidekiq": {
johncblandii / gist:7106916
Last active December 26, 2015 06:19
This shows how to use Preferences.m/h.
View gist:7106916
// Add this to the top of your class
#import "Preferences.h"
// Add this in your method to get the preference, where desired; the constant comes from Preferences.h
NSString *preference = [Preferences getUserPreference:PREFERENCE_NAME_HERE];
johncblandii / Preferences.h
Last active December 26, 2015 06:19
This is a header file with static methods for saving user defaults. It goes with:
View Preferences.h
#import <Foundation/Foundation.h>
#define PREFERENCE_NAME_HERE @"someUniquePreferenceNameHere"
@interface Preferences : NSObject
#pragma mark Preferences
+(void)setUserPreference:(id)value forKey:(NSString*)key;
johncblandii / Preferences.m
Created October 22, 2013 19:34
This is a class with static methods for saving user defaults.
View Preferences.m
#import "Preferences.h"
@implementation Preferences
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
return [defaults valueForKey:forKey];
johncblandii / gist:6234768
Created August 14, 2013 19:39
Git: Remove merged branches from master
View gist:6234768
git branch -r --merged upstream/master | grep origin | grep -v origin/master | sed 's/ *origin\///' | xargs -I% echo git push origin :%
johncblandii / authentication_channel.js
Created April 26, 2013 04:59
An example Angular channel service. It abstracts the event dispatch/subscribe to make it easier to implement/use. Here are some pub/sub best practices:
View authentication_channel.js
* AuthenticationChannel
* Usage (from within a controller):
AuthenticationChannel.onSetPin($scope, function(pin){
console.log("Pin set to ", pin);
//anywhere else in your code base
AuthenticationChannel.setPin(1234567); //set the pin
johncblandii / gist:5243328
Created March 26, 2013 05:19
A basic AngularJS directive with support for Windows 8 animations.
View gist:5243328
var myApp = angular.module("MyApp", []);
myApp.directive("calendarDay", function () {
var linker = function (scope, element, attrs) {
element.bind("mousedown", function () {
element.bind("mouseup", function () {
johncblandii / gist:5240310
Created March 25, 2013 20:15
A simple input[type=range] directive for AngularJS. There is an issue databinding to value changes:
View gist:5240310
var myApp = angular.module("myApp", []);
myApp.directive("rangeChange", function ($rootScope) {
var linker = function (scope, element, attrs) {
var updateScope = function () {
//may need to scope.$apply here
element.bind("change", updateScope);
updateScope(); //get the default value