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
@Abizern
Abizern / gist:836472
Created February 21, 2011 00:32 — forked from anonymous/gist:836413
Find and trash duplicate files
#!/usr/bin/python
import sys
import os
from collections import defaultdict
import hashlib
theRoot = '/Volumes/Stuff/Files/'
theTrashFolder = '/Volumes/Stuff/Trash/'
@Abizern
Abizern / Python3File.py
Created March 6, 2011 18:55
Skeleton Python3 file template
#!/usr/bin/env python3 -tt
"""
Module documentation.
"""
# Imports
import sys
#import os
# Global variables
@Abizern
Abizern / dct_weak.h
Created November 10, 2011 04:19 — forked from danielctull/dct_weak.h
ARC macros for weak references
#import <Availability.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_3
#warning "This library uses ARC which is only available in iOS SDK 4.3 and later."
#endif
#if !defined dct_weak && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0
#define dct_weak weak
#define __dct_weak __weak
#define dct_nil(x)
@Abizern
Abizern / uuidgen.m
Created December 20, 2011 11:51
A method that returns a UUID in an ARC environment.
- (NSString *)uuidString {
// Returns a UUID
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidStr = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
CFRelease(uuid);
return uuidStr;
}
@Abizern
Abizern / NSData+Base64.h
Created January 19, 2012 22:52
A category on NSData for coding and encoding Base64
//
// NSData+Base64.h
// base64
//
// Created by Matt Gallagher on 2009/06/03.
// Copyright 2009 Matt Gallagher. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software. Permission is granted to anyone to
@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)
@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 / 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 / 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 / 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>