Skip to content

Instantly share code, notes, and snippets.

View romainbriche's full-sized avatar

Romain Briche romainbriche

  • San Francisco, California
View GitHub Profile
@mikeabdullah
mikeabdullah / gist:4740463
Last active January 6, 2024 07:31
Atomic file copying
- (BOOL)atomicCopyItemAtURL:(NSURL *)sourceURL
toURL:(NSURL *)destinationURL
error:(NSError **)outError
{
NSFileManager *manager = [NSFileManager defaultManager];
// First copy into a temporary location where failure doesn't matter
NSURL *tempDir = [manager URLForDirectory:NSItemReplacementDirectory
inDomain:NSUserDomainMask
appropriateForURL:destinationURL
@insanehunter
insanehunter / lldb command
Last active December 12, 2015 06:48
LLDB command to skip breakpoint when running unit tests (when SenTestingKit framework is loaded).
script ('SenTestingKit' in [x.file.basename for x in lldb.target.modules] and lldb.thread.GetProcess().Continue())
@benmmurphy
benmmurphy / gist:4706099
Created February 4, 2013 10:45
csv object loading
irb(main):004:0> CSV.dump([Object.new])
=> "class,Object\n\n\n"
irb(main):005:0> CSV.load(CSV.dump([Object.new]))
=> [#<Object:0x00000100ae90d8>]
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active September 8, 2025 14:36
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add [email protected]:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@jmnavarro
jmnavarro / NSProcessInfo+DetectTestEnvironment.h
Created January 31, 2013 11:59
Determine if host app is running in test environment or in real one. Usefull to use in applicationDidFinishLaunching to change the startup path.
//
// NSProcessInfo+DetectTestEnvironment.h
// Memoir
//
// Created by JM - http://jmnavarro.github.com
//
#import <Foundation/Foundation.h>
@interface NSProcessInfo (DetectTestEnvironment)
@wess
wess / gist:4665164
Created January 29, 2013 15:37
A little function to create an HTTP query from an NSPredicate
NSMutableDictionary *generateQueryPartForPredicate(NSPredicate *predicate)
{
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
if([predicate isKindOfClass:[NSCompoundPredicate class]])
{
NSCompoundPredicate *compoundPredicate = (NSCompoundPredicate *)predicate;
for(NSComparisonPredicate *comparison in compoundPredicate.subpredicates)
[params setValue:comparison.rightExpression.constantValue forKey:comparison.leftExpression.keyPath];
@sebreh
sebreh / WeakMacros.h
Last active December 11, 2015 21:39
Shorthand macros for creating weak references.
#define SR_WEAK(obj) __typeof__(obj) __weak
#define SR_WEAK_SELF SR_WEAK(self)
// Usage:
// SR_WEAK_SELF weakSelf = self;
@luca-bernardi
luca-bernardi / DownloadImageTask.java
Created January 28, 2013 13:38
Android's AsyncTask for download asynchronously an image from an URL and assign it to an ImageView
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URL;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.ImageView;
@OliverLetterer
OliverLetterer / XCDUUID.m
Created January 26, 2013 17:05
With this gist, I, as a total assembly noob, am trying to understand the XCDUUID runtime hack (https://github.com/0xced/NSUUID/blob/1.0.1/NSUUID.m#L167-L221) to be able to use NSUUID on iOS < 6.0.
@implementation XCDUUID
+ (void) load
{
// query runtime if NSUUID class already exists, if so => done
if (objc_getClass("NSUUID"))
{
return;
}
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active October 15, 2025 02:35
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: