Skip to content

Instantly share code, notes, and snippets.

View bbuck's full-sized avatar
💻
working hard

Brandon Buck bbuck

💻
working hard
View GitHub Profile
@bbuck
bbuck / rack_static
Last active December 16, 2015 04:48
Generates a static rack application as recommended by Heroku for quick test deployments. Just save this on a *NIX box and make it executable (I use the named rack_static) and then use it via rack_static <name of app>
#!/usr/bin/env ruby
if ARGV.length < 1
puts "rack_static is a simplistic command line tool and is only usable on"
puts "*NIX systems -- 2013 Brandon Buck\n"
puts "Usage: rack_static <project_name>"
exit
end
# Define file contents
@bbuck
bbuck / Structure.js
Last active November 28, 2018 10:15
Evaluate DOM Structure quickly by injecting this JS class into a page and create a new instance on the parent element. Feel free to extend / etc.
// Created by Brandon Buck
// Placed into Public Domain
class Structure {
constructor(from, options = {}) {
this.options = Object.assign({}, Structure.defaultOptions, options);
this.fromEl = from;
this.structure = [];
this.process(this.fromEl);
}
@bbuck
bbuck / algorithm.rb
Last active January 3, 2016 04:39
Small Ruby Algorithm DSL
# Defines a simple DSL means for building an algorithm that follows a list of
# steps. Despite all algorithms being a simple set of steps that doesn't mean
# that this would be a prime solution for implementing said algorithm. This
# class is designed for implementing algorithms that follow a very defined set
# of steps with easy to comprehend mutations.
#
# The purpose of step definition is to force the person designed the algorithm
# to break each step down, ideally so that each step performs a single mutation
# and returns a new value. There is a means to managing a "state" for the
# algorithm for more complex "moving parts" algorithms or just simply caching
@bbuck
bbuck / fuck_you.sh
Last active August 29, 2015 13:56
A personal rendition of the 'fuck you' rage quit console function (original here: https://gist.github.com/namuol/9122237)
function pidof() {
ps -Ac | grep -i $1 | awk '{ print $1 }'
}
function flip() {
perl -C3 -Mutf8 -lpe '$_=reverse;y/a-zA-Z.['\'',({?!\"<_;‿⁅∴\r/ɐqɔpǝɟƃɥıɾʞ|ɯuodbɹsʇnʌʍxʎzɐqɔpǝɟƃɥıɾʞ|ɯuodbɹsʇnʌʍxʎz˙],'\'')}¿¡,>‾؛⁀⁆∵\n/' <<< "$1"
}
function fuck() {
local to_kill=$(echo ${!#} | awk '{ print tolower($1) }')
@bbuck
bbuck / pbgist.sh
Last active August 29, 2015 13:56
function pbgist {
if [ $1 == "-p" ]; then
gist -pP -f $2 | pbcopy
else
gist -P -f $1 | pbcopy
fi
}
using UnityEngine;
public static class Physics2DExtensions {
public static void AddForce(this Rigidbody2D rigidbody2D, Vector2 force, ForceMode mode = ForceMode.Force) {
switch (mode) {
case ForceMode.Force:
rigidbody2D.AddForce(force);
break;
case ForceMode.Impulse:
rigidbody2D.AddForce(force / Time.fixedDeltaTime);
+ (NSString *)signString:(NSString *)paramString {
NSData *paramData = [paramString dataUsingEncoding:NSUTF8StringEncoding];
NSData *secretData = [kMessagePetzAPISecret dataUsingEncoding:NSUTF8StringEncoding];
NSMutableData *sigData = [NSMutableData dataWithLength:CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256, secretData.bytes, secretData.length, paramData.bytes, paramData.length, sigData.mutableBytes);
return [sigData hexadecimalString];
}
# Open SQLiteMan on the iOS simulator SQL DB
function ios_sql {
local IOS_VERSION;
local SQLITE;
DEFAULT_IOS_VERSION="7.0.3"
IOS_VERSION=${1:-$DEFAULT_IOS_VERSION}
echo $IOS_VERSION
SQLITE=$(find ~/Library/Application\ Support/iPhone\ Simulator/$IOS_VERSION -regex ".*\.sqlite" | head -1)
@bbuck
bbuck / Makefile
Created May 6, 2014 07:01
A sample dynamic array (very very very basic implementation in C.
CFLAGS=-Wall
CC=cc
all: arr_test
arr_test: array.c main.c
$(CC) $(CFLAGS) array.c main.c -o arr_test
clean:
rm -f arr_test
@bbuck
bbuck / ABRecordRefWrapper.m
Created May 15, 2014 20:10
A small wrapper for ABRecordRef values to take the logic out of doing some of the data fetches.
#import "ABRecordRefWrapper.h"
@interface ABRecordRefWrapper ()
@property (nonatomic) ABRecordRef person;
@property (strong, nonatomic) NSArray *numbersCache;
@property (strong, nonatomic) NSString *firstNameCache;
@property (strong, nonatomic) NSString *lastNameCache;