Skip to content

Instantly share code, notes, and snippets.

View johncblandii's full-sized avatar
🚢
Ready to ship.

John C. Bland II johncblandii

🚢
Ready to ship.
View GitHub Profile
@johncblandii
johncblandii / MergeAndBreakIntoFiles.macro
Created October 21, 2016 07:11
Microsoft Word macro to merge the current document and split each section into individual files
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
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 August 29, 2015 14:21
AWS Opworks Custom JSON - Postgres, Nginx tweak, Sidekiq
{
"deploy": {
"short_app_name_here": {
"database": {
"adapter": "postgresql",
"type": "postgresql"
}
}
},
"sidekiq": {
@johncblandii
johncblandii / gist:7106916
Last active December 26, 2015 06:19
This shows how to use Preferences.m/h.
// 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 December 26, 2015 06:19
This is a header file with static methods for saving user defaults. It goes with: https://gist.github.com/johncblandii/7106773.
#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 October 22, 2013 19:34
This is a class with static methods for saving user defaults.
#import "Preferences.h"
@implementation Preferences
+(id)getUserPreference:(NSString*)forKey
{
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
return [defaults valueForKey:forKey];
}
@johncblandii
johncblandii / gist:6234768
Created August 14, 2013 19:39
Git: Remove merged branches from master
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 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: http://eburley.github.io/2013/01/31/angularjs-watch-pub-sub-best-practices.html.
/**
* 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 March 26, 2013 05:19
A basic AngularJS directive with support for Windows 8 animations.
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 March 25, 2013 20:15
A simple input[type=range] directive for AngularJS. There is an issue databinding to value changes: https://github.com/angular/angular.js/pull/2085.
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
};