Skip to content

Instantly share code, notes, and snippets.

@pixelrevision
pixelrevision / UIApplication+BuildInfo.swift
Created September 7, 2016 15:13
Adds strong typed build info to UIApplication
import Foundation
extension UIApplication {
var build: String {
return NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String
}
var version: String {
return NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String
@pixelrevision
pixelrevision / excel_to_json.py
Created May 24, 2016 19:35
spreadsheet to json
#!/usr/bin/python
import os
import argparse
import xlrd
import json
def create_json_object(args):
workbook = xlrd.open_workbook(args.input)
sheet = workbook.sheet_by_index(0)
json_array = []
@pixelrevision
pixelrevision / excel_to_table.py
Last active December 28, 2015 05:59
Creates html tables from an excel doc
#!/usr/bin/python
import os
import shutil
import xlrd
import argparse
import xml.etree.ElementTree as elementTree
import xml.dom.minidom as minidom
def parseExcelDoc(xlsFile, outputFile, useTableHeader):
print xlsFile
@pixelrevision
pixelrevision / resize_ios_images.py
Last active December 21, 2015 11:39
Resize iOS images
'''
requires imagemagick to be installed. http://www.imagemagick.org/script/index.php
requires pngquant to be installed if using compression on pngs. http://pngquant.org/
'''
import os
import sys
import subprocess
import argparse
import shutil
import mimetypes
@pixelrevision
pixelrevision / resize_android_images.py
Last active December 19, 2015 06:49
Process Android images
'''
requires imagemagick to be installed. http://www.imagemagick.org/script/index.php
'''
import os
import sys
import subprocess
import argparse
# defines the input we want to use. Change the directory name or the target DPI to set this.
inputDirName = "drawable-xhdpi"
@pixelrevision
pixelrevision / crop_images.py
Last active December 17, 2015 02:39
Image cropping with coordinates in file name
'''
Script to crop dead space in images and save out coordinates in the file name. Requires PIL to be installed:
http://www.pythonware.com/products/pil/
usage:
python crop_images.py path/to/input/dir path/to/output/dir
'''
from PIL import Image
from PIL import ImageOps
import os
import sys
@pixelrevision
pixelrevision / PXRImageSizeUtil.h
Created April 15, 2013 23:21
A image resizing utility for iOS
#import <Foundation/Foundation.h>
typedef enum {
PXRImageSizeUtilVerticalAlignTop,
PXRImageSizeUtilVerticalAlignBottom,
PXRImageSizeUtilVerticalAlignMiddle
}PXRImageSizeUtilVerticalAlign;
typedef enum {
PXRImageSizeUtilHorizontalAlignLeft,
@pixelrevision
pixelrevision / PXRWebViewMessenger.js
Last active December 16, 2015 06:29
Call native iOS methods in javascript.
var PXRWebViewMessenger = function(){
this.prefixTrigger = "pxr";
this.queue = [];
this.timer = null;
};
PXRWebViewMessenger.prototype.callMethod = function(methodName, params){
var self = this;
var message = {};
message.method = methodName;
@pixelrevision
pixelrevision / ISO 8601 date
Created March 19, 2013 21:42
Get a date from a ISO 8601 string in javascript.
var a = dateString.split(/[^0-9]/);
var date = new Date (a[0],a[1]-1,a[2],a[3],a[4],a[5]);
@pixelrevision
pixelrevision / gist:5069770
Created March 2, 2013 04:58
Print all font family names in ios
NSArray *familyNames = [UIFont familyNames];
for(NSString *family in familyNames){
NSLog(@"-%@", family);
NSArray *fontNames = [UIFont fontNamesForFamilyName:family];
for(NSString *font in fontNames){
NSLog(@"----%@", font);
}
}