Skip to content

Instantly share code, notes, and snippets.

@akfreas
akfreas / bashfu.sh
Created January 5, 2016 10:36
Bash-Fu
mkdir -p nathan/is_a_{alex,god}
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
println("test")
}
@akfreas
akfreas / NSURLRequest+cURL.m
Created September 15, 2015 10:13
NSURLRequest Create cURL Command
@interface NSURLRequest (cURL)
- (NSString *)curlCommand;
@end
@implementation NSURLRequest (cURL)
- (NSString *)curlCommand
{
NSString *(^stringFromDict)(NSDictionary *dict) = ^NSString*(NSDictionary *dict){
@akfreas
akfreas / gist:0cd345065b6d9bd780e5
Created June 18, 2014 14:59
NSURLRequest Curl Command
@interface NSURLRequest (CURL)
- (NSString *)curlCommand;
@end
@implementation NSURLRequest (CURL)
- (NSString *)curlCommand
{
NSDictionary *params = [NSJSONSerialization JSONObjectWithData:self.HTTPBody options:0 error:nil];
NSMutableString *paramString = [NSMutableString stringWithString:@"{"];
for (NSString *key in params) {
@akfreas
akfreas / Block Factory Pattern
Created March 25, 2014 21:05
How to create block factories in Objective-C
BOOL(^(^comparator)(NSString *, NSString *, BOOL))(NSString *, NSDictionary *) = ^BOOL(^(NSString *prefixString, NSString *typeString, BOOL hasNumberedSuffix))(NSString *, NSDictionary *) {
return ^BOOL(NSString *str, NSDictionary *dict) {
NSString *regexString = [NSString stringWithFormat:@"%@_([0-9]{2})_%@", prefixString, typeString];
NSError *err = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexString options:nil error:&err];
if ([[regex matchesInString:str options:0 range:NSMakeRange(0, [str length])] count] > 0) {
return YES;
} else {
return NO;
@akfreas
akfreas / ipin.py
Created March 25, 2014 21:04 — forked from shinyzhu/ipin.py
#---
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007
#
# Author:
# Axel E. Brzostowski
# http://www.axelbrz.com.ar/
# axelbrz@gmail.com
#
# References:
#!/usr/bin/env python
import biplist
import os
import requests
import tempfile
import sys
import git
testflight_api_url = "http://testflightapp.com/api/builds.json"
#!/usr/bin/env python
import os
import shutil
from zipfile import ZipFile
from boto.s3.connection import S3Connection
from tempfile import mkdtemp
aws_access_key_id = os.getenv("AWS_ACCESS_KEY_ID")
@akfreas
akfreas / gist:6788980
Created October 2, 2013 04:00
Plurality correctness
NSString *pluralString;
NSString *lastComponent = [person.firstName substringWithRange:NSMakeRange(firstName - 1, 1)];
if ([lastComponent isEqualToString:@"s"]) {
pluralString = @"'";
} else {
pluralString = @"'s";
}
#!/usr/bin/python
from git import *
from argparse import ArgumentParser
import urllib
import shutil
from elementtree.ElementTree import Element, parse
import os