Skip to content

Instantly share code, notes, and snippets.

View Abizern's full-sized avatar
🎧
Working from home

Abizer Nasir Abizern

🎧
Working from home
View GitHub Profile
context(@"when generating strings for uploading", ^{
it(@"should return the points as a string", ^{
NSString *pointsAsString = [_testPath pointsDataAsString];
expect([pointsAsString isKindOfClass:[NSString class]]).to.beTruthy();
});
it(@"can recreate the points from this string", ^{
NSString *pointsString = [_testPath pointsDataAsString];
NSData *pointsData = [NSData dataWithBase64EncodedString:pointsString];
expect(pointsData).to.equal(_testPath.points);
@Abizern
Abizern / reverse_words.hs
Created February 9, 2013 12:26
An improvement to my original solution to the Google Code Jam Problem - Reverse Words http://code.google.com/codejam/contest/351101/dashboard#s=p1
import Control.Monad
-- http://code.google.com/codejam/contest/351101/dashboard#s=p1
--
-- Compile with:
-- ghc -O reverse_words.hs
--
-- Run as:
-- ./reverse_words < input_file > output_file
--
-- Unless otherwise indicated, all modules used are either bundled with
@Abizern
Abizern / gcbare.rb
Last active December 10, 2015 01:34
Runs garbage collection on all the bare repositories in a directory. I have a load of backup repositories in my Dropbox. This makes it easier for me to tidy them all up periodically.
#!/usr/bin/env ruby
# A simple script that recurses through the current directory and runs
# git garbage collection on the bare repositories
# v1.0
# Current version available at https://gist.github.com/4358819
Dir.glob("**/*.git") do |dir|
working_dir = File.expand_path dir
puts "#{dir} being garbage collected."
@Abizern
Abizern / gist:4082492
Created November 15, 2012 23:51 — forked from pburleson/gist:4079642
Using WebKit to encode unescaped URL strings
- (NSURL)URLFromString:(NSString *)string;
{
static NSPasteboard *pboard;
if (!pboard) pboard = [[NSPasteboard pasteboardWithUniqueName] retain];
[pboard clearContents];
[pboard writeObjects:@[string]];
NSURL *result = [WebView URLFromPasteboard:pboard];
return result;
@Abizern
Abizern / reverse_words2.hs
Created October 31, 2012 09:15
A better solution to the Google Code Jam problem "Reverse Words"
module Main where
{-
Problem statement:
http://code.google.com/codejam/contest/351101/dashboard#s=p1
Run as a script with runghc, or compile with ghc --make -O2
input and output is by redirection;
@Abizern
Abizern / FakeNotificationCentre.h
Created July 30, 2012 11:56
Fake Notification Centre
//
// FakeNotificationCentre.h
//
// After Graham Lee
//
// Ghetto mock for unit testing.
#import <Foundation/Foundation.h>
@Abizern
Abizern / ReverseWords.hs
Created April 12, 2012 16:16
Solution to Google Code Jam puzzle "Reverse Words" in Haskell
module Main where
{-
- Problem Statement:
- http://code.google.com/codejam/contest/351101/dashboard#s=p1
-
- Usage either compile or use runhaskell / runghc
- Pass the input file as the sole command line argument
- Redirect output if you want the results to go in a file
-}
@Abizern
Abizern / NSDate+RandomDate.h
Last active June 7, 2017 12:24
Category on NSDate to return a random date in the same year as itself.
//
// NSDate+RandomDate.h
//
//
#import <Foundation/Foundation.h>
@interface NSDate (RandomDate)
- (NSDate *)randomDateInYearOfDate;
@Abizern
Abizern / pre-commit
Created March 12, 2012 19:00
pre-commit
#!/usr/bin/env sh
# Tidy up whitespace on commit.
# By-pass it with the --no-verify option to git commit
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@Abizern
Abizern / NSURL+ADNFileHelpers.h
Created January 22, 2012 16:42
A category on NSURL that returns a properly encoded URL for a file in the NSUserDomainMask
//
// NSURL+ADNFileHelpers.h
//
// Created by Abizer Nasir on 02/08/2011.
//
// Public Domain because I love you
#import <Foundation/Foundation.h>
@interface NSURL (ADNFileHelpers)