Skip to content

Instantly share code, notes, and snippets.

@CVertex
CVertex / export-devices.js
Created May 27, 2013 09:25
Extract UDIDs and Device names from Apple dev portal
// open the devices portal and run this in chrome console
var rows = $('#grid-table tr');
rows.each(function(i,val) {
var udid = $(val).find('td[aria-describedby=grid-table_deviceNumber]').html();
var name = $(val).find('td[aria-describedby=grid-table_name]').html();
console.log(udid + '\t' + name);
});
@zrxq
zrxq / gist:5362898
Last active December 16, 2015 02:29
contentCenter CGRect for a CALayer from a resizable UIImage (resizableImageWithCapInsets)
inline static CGRect CGRectCenterRectForResizableImage(UIImage *image) {
return CGRectMake(image.capInsets.left/image.size.width, image.capInsets.top/image.size.height, (image.size.width-image.capInsets.right-image.capInsets.left)/image.size.width, (image.size.height-image.capInsets.bottom-image.capInsets.top)/image.size.height);
}
@cihancimen
cihancimen / string_contains_emoji
Created November 26, 2012 00:54
Check if an NSString contains an emoji character
- (BOOL)stringContainsEmoji:(NSString *)string {
__block BOOL returnValue = NO;
[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
const unichar hs = [substring characterAtIndex:0];
// surrogate pair
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
const unichar ls = [substring characterAtIndex:1];
@tprochazka
tprochazka / WidthEvaluator.java
Created May 10, 2012 19:45
How to animate width of any View
import android.animation.IntEvaluator;
import android.view.View;
import android.view.ViewGroup;
public final class WidthEvaluator extends IntEvaluator {
private final View view;
public WidthEvaluator(View dashboard) {
this.view = dashboard;
@rsaunders100
rsaunders100 / KDPersistantCache.h
Created April 18, 2012 15:53
Persistently stores and recovers NSCoding compliant objects with a expiry time
//
// KDPersistantCache.h
// KDPrototype
// Stores NSCoding compliant objects persistantly in the NSCachesDirectory
// for a specified period of time.
//
// Created by on 18/04/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
@FlorianMielke
FlorianMielke / FMInfoPanelViewController.h
Created December 6, 2011 06:58
Info Panel attached to a UIScrollViewIndicator like in the Path 2 app. More information: http://cl.ly/CN2p
//
// FMInfoPanelViewController.h
// Created by Florian Mielke (@FlorianMielke) on 06.12.11.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
@interface FMInfoPanelViewController : UIViewController <UIScrollViewDelegate>
@abahgat
abahgat / gae-memcache-decorator.py
Last active April 27, 2025 09:47
A Python decorator to cache method results using memcache on Google AppEngine
import functools
import logging
from google.appengine.api import memcache
def cached(time=1200):
"""
Decorator that caches the result of a method for the specified time in seconds.
Use it as:
@mediabounds
mediabounds / floatsign.sh
Last active April 15, 2025 12:08
A small bash script to re-sign iOS applications.
# !/bin/bash
# Copyright (c) 2011 Float Mobile Learning
# http://www.floatlearning.com/
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
@mhawksey
mhawksey / gist:1276293
Last active February 28, 2025 08:52
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@alexras
alexras / Delaunay.pde
Created September 25, 2011 21:07
Quick-and-dirty Delaunay triangulation in Processing used to create http://youtu.be/dsrMjbR0usA
float dpLength(DelaunayPoint p1, DelaunayPoint p2) {
float deltaX = p2.x - p1.x;
float deltaY = p2.y - p1.y;
float deltaZ = p2.z - p1.z;
return sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ));
}
DelaunayPoint dpAdd(DelaunayPoint p1, DelaunayPoint p2)
{