Skip to content

Instantly share code, notes, and snippets.

@mnbi
mnbi / convertDate.m
Created November 23, 2010 18:19
convert a RFC3339 date string into a NSDate object
#import <Foundation/Foundation.h>
// convert a RFC3399 date (& time) into a NSDate object
// NOTE: This function ignores fractions of a second in the RFC3339
// representation.
NSDate *getDateObject(NSString *rfc3339)
{
// Date and Time representation in RFC3399:
// Pattern #1: "YYYY-MM-DDTHH:MM:SSZ"
// 1
@alex-cellcity
alex-cellcity / Version.m
Created May 30, 2011 04:55
Runtime iOS Version Checking
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active July 24, 2024 15:28
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@mabdrabo
mabdrabo / sound_recorder.py
Created January 28, 2014 23:05
Simple script to record sound from the microphone, dependencies: easy_install pyaudio
import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "file.wav"
@MinceMan
MinceMan / JsonWrapper.java
Last active April 22, 2016 13:59
How to serialize and de-serialize an unknown class with GSON.
package com.example;
@JsonAdapter(JsonWrapperAdapter.class)
public class JsonWrapper {
private static final String classNameKey = "className";
private static final String wrappedObjectKey = "wrappedObject";
private final String className;
private final Object wrappedObject;
@kyleve
kyleve / Init.swift
Last active February 3, 2018 23:01
// Make initialization + configuration of mutable classes (such as views) easier.
@warn_unused_result
public func Init<Type>(value : Type, @noescape block: (object: Type) throws -> Void) rethrows -> Type
{
try block(object: value)
return value
}
func example()
{
@mikehaytm
mikehaytm / CocoaMethodsRaiseiOS9.txt
Last active January 6, 2016 14:09
Handle With Care: Cocoa methods and properties that may raise exceptions.
CLASS METHODS
+[AVCaptureDevice requestAccessForMediaType:completionHandler:]
+[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:]
+[HKCategorySample categorySampleWithType:value:startDate:endDate:]
+[HKCategorySample categorySampleWithType:value:startDate:endDate:device:metadata:]
+[HKCategorySample categorySampleWithType:value:startDate:endDate:metadata:]
+[HKCorrelation correlationWithType:startDate:endDate:objects:]
+[HKCorrelation correlationWithType:startDate:endDate:objects:device:metadata:]
+[HKCorrelation correlationWithType:startDate:endDate:objects:metadata:]
+[HKQuantitySample quantitySampleWithType:quantity:startDate:endDate:]