Skip to content

Instantly share code, notes, and snippets.

Avatar
🚢
Ready to ship.

John C. Bland II johncblandii

🚢
Ready to ship.
View GitHub Profile
@johncblandii
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 = Mixpanel::Tracker.new Rails.application.secrets.mixpanel_token
end
def track user_id, action, properties=nil
Rails.logger.debug "Tracking: #{action}"
@@tracker.track(user_id, action, properties || {})
@johncblandii
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
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
johncblandii / Preferences.h
Last active Dec 26, 2015
This is a header file with static methods for saving user defaults. It goes with: https://gist.github.com/johncblandii/7106773.
View Preferences.h
#import <Foundation/Foundation.h>
#define PREFERENCE_NAME_HERE @"someUniquePreferenceNameHere"
@interface Preferences : NSObject
#pragma mark Preferences
+(id)getUserPreference:(NSString*)forKey;
+(void)setUserPreference:(id)value forKey:(NSString*)key;
@end
@johncblandii
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
+(id)getUserPreference:(NSString*)forKey
{
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
return [defaults valueForKey:forKey];
}
@johncblandii
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
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: http://eburley.github.io/2013/01/31/angularjs-watch-pub-sub-best-practices.html.
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
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 () {
WinJS.UI.Animation.pointerDown(element[0]);
});
element.bind("mouseup", function () {
WinJS.UI.Animation.pointerUp(element[0]);
@johncblandii
johncblandii / gist:5240310
Created Mar 25, 2013
A simple input[type=range] directive for AngularJS. There is an issue databinding to value changes: https://github.com/angular/angular.js/pull/2085.
View gist:5240310
var myApp = angular.module("myApp", []);
myApp.directive("rangeChange", function ($rootScope) {
var linker = function (scope, element, attrs) {
var updateScope = function () {
scope[attrs.rangeControl](element.val());
//may need to scope.$apply here
};
element.bind("change", updateScope);
updateScope(); //get the default value
};