Skip to content

Instantly share code, notes, and snippets.

View paxswill's full-sized avatar

Will Ross paxswill

View GitHub Profile
@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
@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 / 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}
#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 / 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;
}
@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 / 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 / test_rand.c
Created October 5, 2011 00:26
Demonstrate the dangers of calling rand() without calling srand().
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
/*
* Require C99
*/
#if __STDC_VERSION__ < 199901L
#error C99 Required
@paxswill
paxswill / tiny-bubble.c
Created November 4, 2011 06:41
Tiny BubbleSort
/*
This breaks a number of rules, and probably won't work with systems with non-32bit ints
Minimal form (180 chars):
main(){int n,*s,i=0,j,t;scanf("%d",&n);s=malloc(n);while(i<n)scanf("%d",s+i++);while(--i)for(j=0;j<i;)if(s[j]>s[++j]){t=s[--j];s[j]=s[++j];s[j]=t;}while(i<n)printf("%d ",s[i++]);}
Standard(ish) form:
*/
main(){
int n,*s,i=0,j,t;
@paxswill
paxswill / ansi-color.rb
Created November 9, 2011 16:03
ansi-color Homebrew Formula
class AnsiColor < Formula
url 'http://ansi-color.googlecode.com/files/ansi-color-0.6.tar.gz'
version '0.6'
homepage 'http://code.google.com/p/ansi-color/'
md5 '7f55561eb9c88bb56f51a86f12bff75c'
def install
# This package is a bit special, and probably requires manual staging/installation
end
end