Skip to content

Instantly share code, notes, and snippets.

View kballenegger's full-sized avatar

Kenneth Ballenegger kballenegger

View GitHub Profile
@kballenegger
kballenegger / routes-deprecated.rb
Last active August 29, 2015 14:00
Overriding wrapping routes with a deprecation message.
require 'kenji'
module Kenji
class Controller
class << self
def routes_deprecated!(enabled = true)
if enabled
puts "Enabling deprecation for the following methods in #{self.name}:"
else
@kballenegger
kballenegger / react.js.wisp
Last active December 6, 2016 12:41
ReactJS macro in wisp
; note: this iteration doesn't work properly.
; looks like i don't understand exactly how react.js works for settings dom element properties
(set! exports {})
; react macros...
(defmacro hash-map-pairs
"make a hash map from its arguments. each argument is a tuple (key value)"
@kballenegger
kballenegger / quoth-api-spec.md
Last active August 29, 2015 13:57
Quoth API Spec

API Spec

Standard stuff

Every request should contain the following headers:

  • Quoth-Client: an user-agent type string, eg. Quoth-iOS 3.2
  • Quoth-Authentication: a json object, like this:
@kballenegger
kballenegger / CBJSONCollectionDescriptions.m
Last active August 29, 2015 13:57
Apple's default way of describing collections seriously blows. JSON is better.
//
// CBJSONCollectionDescriptions.m
// Chartboost
//
// Created by Kenneth Ballenegger on 3/12/14.
//
//
#import "CBJSONCollectionDescriptions.h"
#import <objc/runtime.h>
@kballenegger
kballenegger / xcode.crash
Created March 10, 2014 19:32
Xcode crashes on unit tests... wtf.
Process: Xcode [7919]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 5.0.1 (3335.6)
Build Info: IDEApplication-3335006000000000~3
Code Type: X86-64 (Native)
Parent Process: launchd [247]
Responsible: Xcode [7919]
User ID: 501
char *const kCBLocationAtStartupString = "startup";
// etc ...
typedef enum CBLocation {
CBLocationAtStartup = (char *const)"startup",
// etc.
} CBLocation;
void showInterstitial(CBLocation location) {
char *locationString = (char *)location;
@kballenegger
kballenegger / string-enums.m
Last active February 19, 2016 05:47
Strings as enum values
NSString *const kCBLocationAtStartupString = @"startup";
// etc ...
typedef NS_ENUM(NSString *, CBLocation) {
CBLocationAtStartup = kCBLocationAtStartupString,
// etc.
};
- (void)showInterstitial:(CBLocation)location {
NSString *locationString = (NSString *)location

Keybase proof

I hereby claim:

  • I am kballenegger on github.
  • I am kballenegger (https://keybase.io/kballenegger) on keybase.
  • I have the public key with fingerprint 4969 7FB5 BF5B 01D1 147A  8199 5918 07DB 6738 9DC3

To claim this, I am signing this object:

@kballenegger
kballenegger / ll-find-middle-node.c
Created February 14, 2014 05:09
Find the middle node in a linked list.
//
// File.c
//
//
// Created by Kenneth Ballenegger on 1/13/14.
//
//
#include <stdlib.h>
#include <stdio.h>
@kballenegger
kballenegger / stock-value.rb
Last active August 29, 2015 13:56
Script to more easily get an idea of the current value of your stock at a company.
require 'date'
require 'json'
# assume standard 4-year vesting
# ignores cliff
# ignores vesting periods, assumes daily. (watch out for this)
unless price = ARGV[1]
puts "Must pass in price as second arg..."
exit 1