Skip to content

Instantly share code, notes, and snippets.

View paxswill's full-sized avatar

Will Ross paxswill

View GitHub Profile
@paxswill
paxswill / NSString+Cons.h
Created August 12, 2011 18:50
And time for another episode of Stupid Obj-C Tricks! In this episode, we combine C varargs with Obj-C dynamic method resolution to hack together a cons like construct for strings. Explanation: http://paxswill.com/blog/2011/08/14/nsstring-cons/
//
// NSString+Cons.h
// NSStringCons
//
// Created by Will Ross on 8/12/11.
// Copyright (c) 2011 Naval Research Lab. All rights reserved.
//
#import <Foundation/Foundation.h>
@paxswill
paxswill / JCITree.h
Created July 21, 2011 13:41
JCITree, a quick tree structure in Obj-C
@interface JCITree : NSObject {
@private
id value;
NSMutableArray *leaves;
JCITree *parent;
}
@property (retain) id value;
@property (retain, readonly) NSMutableArray *leaves;
@property (assign, readonly) JCITree *parent;
-(void)setValue:(id)aValue atIndex:(NSInteger)index;
@paxswill
paxswill / fizzbuzz-recursive-bit.c
Last active September 25, 2015 16:48
FizzBuzz with recursion and no multiplication or division
#include <stdio.h>
#include <stdbool.h>
int addDigitsHex(int num);
void recursiveFizzBuzz(int start, int end);
int main (int argc, char const *argv[]) {
recursiveFizzBuzz(1, 100);
return 0;
}
#include <string>
using namespace std;
// So here I'll define a struct that will go in the linked list
typedef struct person{
string name;
int age;
};
@paxswill
paxswill / complexity.c
Created April 1, 2011 05:40
Dropping from quadratic to linear complexity
/*
In computer science, algorithmic complexity is represented by something called
Big-Oh notation. Writing O(1) means a function will take the same amount of
time no matter how large the input is, ie: it is constant. O(n) means it will
take linear time, for example if you double the amount of input, the time taken
to perform that function will also double. Other common complexities are O(n^2),
O(log(n)), and O(n log(n)). Note, in most cases the logarithm is log base 2.
The following functions basically split a list of numbers in the following way:
{0, 1, 2, 3, 4, 5, 6, 7}
@paxswill
paxswill / libimobiledevice config.log
Created February 17, 2011 18:14
This is the config.log of imobiledevice
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libimobiledevice configure 1.0.3, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/libimobiledevice/1.0.3 --without-swig
## --------- ##
## Platform. ##
@paxswill
paxswill / calendar.sh
Created October 28, 2010 11:50
This formats a single days worth of events. Note that I have two UUIDs from my calendars in here, replace with ones from your calendar.
#!/bin/bash
#Get the date command
#DATE_CMD_LOC=`which date`
DATE_CMD_LOC=/bin/date
#Build the date command strings
START_DATE_CMD="$DATE_CMD_LOC -v+$1d +%Y-%m-%d\ 00:00:01\ -0500"
END_DATE_CMD="$DATE_CMD_LOC -v+$1d +%Y-%m-%d\ 23:59:59\ -0500"
#echo $START_DATE_CMD
#echo $END_DATE_CMD