Skip to content

Instantly share code, notes, and snippets.

View defagos's full-sized avatar

Samuel Défago defagos

View GitHub Profile
# ----------------------------------------------------------------
# Makefile for building PostgreSQL
#
# Copyright(C) 2010 Satoshi Nagayasu <satoshi.nagayasu@gmail.com>
# ----------------------------------------------------------------
PREFIX=/usr/local/pgsql90b1
POSTGRES=postgresql-9.0beta1
CONTRIBS=pgbench
JSClass *Dog = [JSClass newClass:@"Dog"
parent:[NSObject class]
properties:[NSArray arrayWithObjects:@"name",@"breed",nil]];
[Dog onClassMessage:@selector(dogWithBreed:)
do:^(id Self, NSString *breed) {
id instance = [[Self alloc] init];
[instance setBreed:breed];
return [instance autorelease];
}];
[Dog addClassProperty:@"kingdom" withValue:@"Animalia"];
@jonalter
jonalter / app.js
Created September 22, 2011 00:05
iOS: disable snapshot from being taken when app backgrounded (for security reasons)
// by Blain Hamon
var win = Ti.UI.createWindow({
backgroundColor : 'white',
orientationModes : [Ti.UI.PORTRAIT]
});
win.open();
var label = Ti.UI.createLabel({
text : 'No app event received. Make call while running app',
textAlign : 'center',
@Shilo
Shilo / UIImage+Additions.h
Created October 17, 2011 07:43
A UIImage category that will replace or remove colors. This allows multiple colors to be changed on a single image, until it has alpha values.
//
// UIImage+Additions.h
// Sparrow
//
// Created by Shilo White on 10/16/11.
// Copyright 2011 Shilocity Productions. All rights reserved.
//
#define COLOR_PART_RED(color) (((color) >> 16) & 0xff)
#define COLOR_PART_GREEN(color) (((color) >> 8) & 0xff)
@mikeash
mikeash / gist:1355671
Created November 10, 2011 18:28
Multiple return
// clang -W -Wall -Wno-unused-parameter -framework Foundation -fobjc-arc test.m
#import <Foundation/Foundation.h>
#define IDARRAY(...) ((id[]){ __VA_ARGS__ })
#define IDCOUNT(...) (sizeof(IDARRAY(__VA_ARGS__)) / sizeof(id))
typedef id (^Tuple)(int);
@mediabounds
mediabounds / floatsign.sh
Last active March 31, 2024 18:43
A small bash script to re-sign iOS applications.
# !/bin/bash
# Copyright (c) 2011 Float Mobile Learning
# http://www.floatlearning.com/
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
@steipete
steipete / iOSDocumentMigrator.m
Created December 6, 2011 15:21
Helps migrating documents between iOS <= 5.0 and >= 5.0.1 to comply with Apple's iCloud guidelines. Follow @steipete on Twitter for updates.
#include <sys/xattr.h>
/// Set a flag that the files shouldn't be backuped to iCloud.
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath {
u_int8_t b = 1;
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available.
+ (NSString *)legacyStoragePath {
@aemkei
aemkei / LICENSE.txt
Last active June 4, 2024 07:51 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@0xced
0xced / NSURLWithParameters.m
Last active December 20, 2018 10:54
How to (ab)use TWRequest to create a NSURL with parameters easily
{
NSURL *baseURL = [NSURL URLWithString:@"http://duckduckgo.com/"];
NSDictionary *parameters = @{ @"q" : @"TWRequest -site:apple.com" };
// With TWRequest: 1 line with **correct percent escaping**
NSURL *urlA = [[[[TWRequest alloc] initWithURL:baseURL parameters:parameters requestMethod:TWRequestMethodGET] signedURLRequest] URL];
// Without TWRequest: 10 lines with wrong percent escaping (http://www.openradar.me/6546984)
NSMutableString *query = [NSMutableString string];
for (NSString *key in parameters)
@0xced
0xced / NSData+Base64.h
Created February 24, 2012 15:03
NSData Base64 category
//
// Created by Cédric Luthi on 2012-02-24.
// Copyright (c) 2012 Cédric Luthi. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSData (Base64)
+ (id) dataWithBase64Encoding_xcd:(NSString *)base64String;