Skip to content

Instantly share code, notes, and snippets.

@sey
sey / Remove a warning with clang
Created October 23, 2012 10:22
Remove a warning with clang
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// the line producing the warning
#pragma clang diagnostic pop
@sey
sey / rename_part.bash
Created October 23, 2012 12:52
Rename part of a filename
for file in files; do
mv $file `echo $file | sed 's/origin/new/g'`;
done
@sey
sey / gist:3938578
Created October 23, 2012 12:53
.p12 to .pem
openssl pkcs12 -in keyStore.p12 -out keyStore.pem -nodes
@sey
sey / xml_pretty
Created October 25, 2012 06:56
Pretty XML printing
xmllint --format xml_file.xml
@sey
sey / mp3tocaf
Created October 25, 2012 06:58
Convert mp3, wav to caf
/usr/bin/afconvert -f caff -d LEI16 {INPUT} {OUTPUT}
@sey
sey / objective-c-singleton
Last active October 12, 2015 01:47
Singleton class constructor method. Makes use of instancetype (http://nshipster.com/instancetype/)
+ (instancetype)shared
{
static id shared;
static dispatch_once_t token;
dispatch_once(&token, ^{
shared = [[self alloc] init];
});
return shared;
}
@sey
sey / getUUID
Created November 10, 2012 15:34
getUUID
+ (NSString *)getUUID
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults stringForKey:@"UUID"])
{
return [defaults stringForKey:@"UUID"];
}
else
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
@sey
sey / debugCookies
Created November 10, 2012 15:35
debugCookies
+ (void)debugCookies
{
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[storage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
NSArray *cookies = [storage cookies];
for (NSHTTPCookie *cookie in cookies)
{
NSLog(@"cookie: %@", cookie);
}
}
lsof -n -i4TCP:9000 | grep LISTEN
@sey
sey / cordova_debug
Last active December 16, 2015 13:29
Cordova debug FileError codes
function debug() {
"use strict";
var errorsCode = [
{ 'FileError.NOT_FOUND_ERR': FileError.NOT_FOUND_ERR },
{ 'FileError.SECURITY_ERR': FileError.SECURITY_ERR },
{ 'FileError.ABORT_ERR': FileError.ABORT_ERR },
{ 'FileError.NOT_READABLE_ERR': FileError.NOT_READABLE_ERR },
{ 'FileError.ENCODING_ERR': FileError.ENCODING_ERR },
{ 'FileError.NO_MODIFICATION_ALLOWED_ERR': FileError.NO_MODIFICATION_ALLOWED_ERR },
{ 'FileError.INVALID_STATE_ERR': FileError.INVALID_STATE_ERR },