Skip to content

Instantly share code, notes, and snippets.

Ready to ship.

John C. Bland II johncblandii

Ready to ship.
Block or report user

Report or block johncblandii

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
johncblandii / MergeAndBreakIntoFiles.macro
Created Oct 21, 2016
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 Aug 29, 2015
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 Dec 26, 2015
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 Dec 26, 2015
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 Oct 22, 2013
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 Aug 14, 2013
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 Apr 26, 2013
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 Mar 26, 2013
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 Mar 25, 2013
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
You can’t perform that action at this time.