Skip to content

Instantly share code, notes, and snippets.

View troystribling's full-sized avatar

Troy Stribling troystribling

  • San Francisco, CA
View GitHub Profile
@troystribling
troystribling / gist:2941424
Created June 16, 2012 14:10
GPUImage Blending Mode example
- (UIImage*)blendedImage {
GPUImagePicture* bluredImage = [[GPUImagePicture alloc] initWithImage:self.filterImage];
GPUImageFilterGroup* blurFilterGroup = [[GPUImageFilterGroup alloc] init];
GPUImageFilter* colorOverlayfilter = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:@"WhiteColorOverlay"];
GPUImageGaussianBlurFilter* gaussainBlur = [[GPUImageGaussianBlurFilter alloc] init];
[gaussainBlur setBlurSize:3.0f];
[blurFilterGroup addFilter:colorOverlayfilter];
[blurFilterGroup addFilter:gaussainBlur];
@troystribling
troystribling / DataManager.h
Created November 19, 2012 03:12
Simple Core Data wrapper. Supports background access.
#import <Foundation/Foundation.h>
#import "NSManagedObject+DataManager.h"
@interface DataManager : NSObject
@property (nonatomic, strong, readonly) NSManagedObjectModel* managedObjectModel;
@property (nonatomic, strong, readonly) NSManagedObjectContext* managedObjectContext;
@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator* persistentStoreCoordinator;
@property (nonatomic, strong) NSURL* modelURL;
@property (nonatomic, strong) NSString* persistantStoreName;
@troystribling
troystribling / RememberMeAuthStrategy.scala
Last active January 1, 2017 08:32
Scalatra 2.2 Sentry implemented for username/password and cookie authentication.
package lib
import org.scalatra._
import org.scalatra.util.RicherString._
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
import org.scalatra.auth.{ScentrySupport, ScentryStrategy}
import net.iharder.Base64
import java.util.Locale
import io.Codec
@troystribling
troystribling / scala.vim
Created June 15, 2013 22:37
Fix for synatstic flagging local imports as errors. in file .vim/janus/vim/tools/syntastic/syntax_checkers/scala.vim
1 "============================================================================
2 "File: scala.vim
3 "Description: Syntax checking plugin for syntastic.vim
4 "Maintainer: Rickey Visinski <rickeyvisinski at gmail dot com>
5 "License: This program is free software. It comes without any warranty,
6 " to the extent permitted by applicable law. You can redistribute
7 " it and/or modify it under the terms of the Do What The Fuck You
8 " Want To Public License, Version 2, as published by Sam Hocevar.
9 " See http://sam.zoy.org/wtfpl/COPYING for more details.
10 "
@troystribling
troystribling / post-commit
Last active December 21, 2015 02:18
lolcommits .git/hooks/post-commit running zsh and rvm
#!/bin/zsh
source "$HOME/.rvm/scripts/rvm"
lolcommits --capture
@troystribling
troystribling / eeprom_objects.h
Created March 23, 2014 17:06
Simple CRUD for storing objects using Arduino EEPROM library.
#include <EEPROM.h>
#include <Arduino.h>
#include "log.h"
template <class T> class EEPROMObject {
public:
EEPROMObject(uint16_t _offset, uint8_t _maxObjects) : offset(_offset), maxObjects(_maxObjects){};
uint16_t create(uint8_t& index, const T& value);
uint16_t update(uint8_t index, const T& value);
uint16_t read(uint8_t index, T& value);
@troystribling
troystribling / gist:42ec640f10317267139f
Created March 23, 2014 17:47
BlueCap Characteristic Profile Xcode Snippet
[serviceProfile createCharacteristicWithUUID:<#UUID#>
name:<#name#>
andProfile:^(BlueCapCharacteristicProfile* characteristicProfile) {
characteristicProfile.properties = CBCharacteristicPropertyRead | CBCharacteristicPropertyWrite;
[characteristicProfile serializeObject:^NSData*(id data) {
return nil;
}];
[characteristicProfile afterDiscovered:^(BlueCapCharacteristic* chararacteristic) {
}];
[characteristicProfile deserializeData:^NSDictionary*(NSData* data) {
@troystribling
troystribling / ProtocolAssociatedType.swift
Last active April 28, 2022 20:55
A swift protocol with associated type used as type parameter in generic function
protocol Thing {
typealias argType
func doit(val:argType) -> argType
}
class IntThing : Thing {
func doit(val: Int) -> Int {
return val + 1
}
}
@troystribling
troystribling / gist:95811ad507dc877d98ee
Created July 31, 2014 02:52
Find all paths to climb a digital mountain
(ns climbing
(:require [clojure.string :as string])
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; part a ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Each mountain block has 2 children it follows that for a mountain of size n
; the total paths will equal total number of block sequences from top to base
; taking one from each row which is given by p=2^(n-1)
(defn simple-path-count
@troystribling
troystribling / Notify.swift
Created November 23, 2014 16:53
UIAlertControllerExtensions and Notification handler
import UIKit
class Notify {
class func resetEventCount() {
eventCount = 0;
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
}
class func withMessage(message:String) {