Skip to content

Instantly share code, notes, and snippets.

View kylekellogg's full-sized avatar
👨‍💻
Doing my best

Kyle Kellogg kylekellogg

👨‍💻
Doing my best
View GitHub Profile
@kylekellogg
kylekellogg / cgrep.sh
Created March 10, 2014 18:27
Example for 34.18 (article is titled "Searching for Patterns Split Across Lines" and is in the sed chapter of the book) of "Unix Power Tools". If you can explain this in a way that is more sensible than the book, I would be extremely grateful.
#!/bin/sh
# cgrep - multiline context grep using sed
# Usage: cgrep [-context] pattern [file...]
n=3
case $1 in -[1-9]*)
n=`expr 1 - "$1"`
shift
esac
re=${1?}; shift
@kylekellogg
kylekellogg / f2j.sh
Created March 6, 2014 03:01
Cucumber (Gherkin) feature file to JIRA comment formatter. Takes a path to a single .feature file and will output the JIRA comment-friendly formatted version in the terminal.
#!/usr/bin/env bash
# Ensure only one file at a time
if [[ $# -ne 1 ]]
then
echo ""
echo "Usage $0 path/to/file.feature"
echo ""
exit 1
fi
@kylekellogg
kylekellogg / MKSampleViewController.m
Last active December 28, 2015 19:59
Sample ViewController.m for MyKarma SDK
#import "ViewController.h"
#import "MKInterstitialView.h"
@interface ViewController () <MKInterstitialViewDelegate>
@property (strong, nonatomic) MKInterstitialView *interstitialView;
@end
@implementation ViewController
@kylekellogg
kylekellogg / MKSampleAppDelegate.m
Created November 19, 2013 22:38
Sample AppDelegate.m for application using MyKarma SDK
#import "AppDelegate.h"
#import "MKManager.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[MKManager sharedManager] registerWithAppKey:@"APP KEY"
secret:@"APP SECRET"
successHandler:^(void) {
@kylekellogg
kylekellogg / InternetConnectivity.cs
Created September 24, 2013 14:18
A C# class for Unity3D to determine internet availability. Author is Andy Zupko (https://github.com/azupko).
public class InternetConnectivity : MonoBehaviour
{
public float maxTime = 5;
public float currentTime = 0;
const float successRetry = 20;
const float failRetry = 2;
public static bool hasConnection { get; private set; }
public void OnEnable() {
StartCoroutine( ConnectivityLoop() );
@kylekellogg
kylekellogg / js-timers
Created August 26, 2013 14:54
Simple example to display preserving reference of `this` with JS timers.
var a = new function() {
this.name = "testing";
this.do = function() {
console.log( "doing with " + this.name );
};
};
setTimeout( a.do.call( a ), 100 );
setTimeout( a.do, 100 );
@kylekellogg
kylekellogg / gooby pls
Last active October 8, 2015 06:08
gooby function for bash shell. Takes parameter pls to return fak you dolan. If pls is not set, will return wat?.
function gooby() {
if [ -n $1 ] && [ "$1" = "pls" ]
then
echo "fak you dolan"
else
echo "wat?"
fi
}