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 / all_knowing_string.swift
Created January 14, 2015 04:07
All Knowing Strings - Strings that are all value of strings at all times. This shouldn't be taken seriously.
class AllKnowingString { } // Nothing but a placeholder, afterall it's all values of strings at all times so it needs no values.
func ==(lhs: AllKnowingString, rhs: String) -> Bool {
return true
}
func ==(lhs: String, rhs: AllKnowingString) -> Bool {
return true
}
@bbuck
bbuck / Crash Report
Created September 2, 2014 21:00
Crash report generated from iOS.
This is an issue that I myself have been receiving as well. The system log reports the app suffered from a "stack overflow" and this is the full crash report:
Incident Identifier: 9257266D-D764-463A-AB0B-43425E58C276
Hardware Model: iPhone6,1
Process: [Application Name] [996]
Version: 37 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2014-09-02 15:52:48.058 -0500
# Load ActiveRecord tasks
include ActiveRecord::Tasks
DatabaseTasks.database_configuration = YAML.load(File.open(Laeron.root.join("config", "database.yml")))
DatabaseTasks.db_dir = "db"
DatabaseTasks.migrations_paths = "db"
ActiveRecord::Base.configurations = DatabaseTasks.database_configuration
ActiveRecord::Base.establish_connection(Laeron.env)
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
@bbuck
bbuck / shitty_detection.js
Created May 19, 2014 17:03
User Agent sniffing for mobile operating systems.
var ua = navigator.userAgent.toLowerCase(),
isPhone = /iphone|android/i.test(ua),
isTablet = /ipad|android/i.test(ua),
isiOS = /iphone|ipod|ipad/i.test(ua),
isAndroid = /android/i.test(ua);
@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;
@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
# 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)
+ (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];
}
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);