Skip to content

Instantly share code, notes, and snippets.

@akfreas
akfreas / ipin.py
Created November 2, 2012 07:13 — forked from shinyzhu/ipin.py
iPIN - iPhone PNG Images Normalizer
#---
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007, 2012
#
# Author:
# Alexander Freas
# www.sashimiblade.com
# alex@sashimiblade.com
#
#
@akfreas
akfreas / gist:5054929
Created February 28, 2013 07:26
Grabs profile pictures of a person/place/thing from Wikipedia. This function will check for all images associated with an article's title and compare those images against the images inside the infobox (typically the box on the top right hand corner of an article), returning the WikiMedia URLs of the images inside the infobox.
def figure_wikipedia_pic(figure_name, image_size):
wiki_images_get = requests.get("http://en.wikipedia.org/w/api.php?format=json&action=query&titles=%s&prop=images" % figure_name)
wiki_json = wiki_images_get.json()
wiki_page_json = requests.get("http://en.wikipedia.org/w/api.php?format=json&action=query&titles=%s&prop=revisions&rvprop=content&rvsection=0" % figure_name).json()
wiki_page_json = str(wiki_page_json)
#!/usr/bin/python
from git import *
from argparse import ArgumentParser
import urllib
import shutil
from elementtree.ElementTree import Element, parse
import os
@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/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")
#!/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"
@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:
@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 / 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 / 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){