Skip to content

Instantly share code, notes, and snippets.

View zydeco's full-sized avatar

Jesús A. Álvarez zydeco

View GitHub Profile
@zydeco
zydeco / NSData+Hex.h
Last active August 29, 2015 13:58
Get a hex string from NSData
#import <Foundation/Foundation.h>
@interface NSData (Hex)
- (NSString*)hexString;
- (NSString*)hexStringWithCaps:(BOOL)caps;
+ (NSData*)dataWithHexString:(NSString*)hexString;
@end
@zydeco
zydeco / UIColor+String.h
Last active December 21, 2015 19:49
Init UIColor from string like #ff33cc rgb(255,51,204) or rgba(255,51,204,0.8)
#import <UIKit/UIKit.h>
@interface UIColor (String)
+ (UIColor*)colorWithString:(NSString*)str;
- (UIColor*)initWithString:(NSString*)str;
@end
@zydeco
zydeco / ExtendedAttributes.h
Created August 21, 2013 10:21
NSFileManager + extended attributes
//
// ExtendedAttributes.h
// NSFileManager+Xattr
//
// Created by Jesús A. Álvarez on 2008-12-17.
// Copyright 2008-2009 namedfork.net. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <sys/xattr.h>
@zydeco
zydeco / thread.h
Created May 28, 2012 14:18
pthread/win32 threads
#ifdef __WIN32__
#include <windows.h>
typedef HANDLE mutex_t;
typedef HANDLE thread_t;
#define mutex_init(m) m = CreateMutex(NULL, FALSE, NULL)
#define mutex_lock(m) WaitForSingleObject(m, INFINITE)
#define mutex_unlock(m) ReleaseMutex(m)
#define mutex_destroy(m) CloseHandle(m)