Skip to content

Instantly share code, notes, and snippets.

@onlyyoujack
onlyyoujack / gist:1689218
Created January 27, 2012 15:11 — forked from AdamSwinden/gist:1358867
Using URL scheme to open Settings.app
// Turn on Location Services?
[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
// Set up Twitter?
[NSURL URLWithString:@"prefs:root=TWITTER"]];
// Hook up a Bluetooth device?
[NSURL URLWithString:@"prefs:root=General&path=Bluetooth"]];
// Change app settings
/* Copied, Pasted and summarized from ps' source code.
You can use sysctl to get other process' argv.
*/
#include <sys/sysctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define pid_of(pproc) pproc->kp_proc.p_pid
@onlyyoujack
onlyyoujack / Xcode4TestFlightintegration.sh
Created April 9, 2012 05:51 — forked from martijnthe/Xcode4TestFlightintegration.sh
ReWrite of "Xcode 4 scheme Archive step Post-script for automatic TestFlight build uploading. See the blog post here: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode"
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Inspired by original script by incanus:
# https://gist.github.com/1186990
#
# Rewritten by martijnthe:
# https://gist.github.com/1379127
#
@onlyyoujack
onlyyoujack / BNRTimeBlock.h
Created April 14, 2012 11:31 — forked from bignerdranch/BNRTimeBlock.h
Timing Utility Post 20120308
CGFloat BNRTimeBlock (void (^block)(void));
@onlyyoujack
onlyyoujack / gist:2383840
Created April 14, 2012 11:50 — forked from asmallteapot/gist:1664575
Using C99 for clever and non-fragile UITableView configuration. Allows implicit defaults. Copypasta’d from a screencap tweeted by @jonsterling: http://twitpic.com/80uyfp
typedef enum {
kAccomplishmentTitleSection = 0,
kAccomplishmentCategorySection,
kNumberOfSections
} NESTemplateEditTableSections;
static NSString * const kCellIdentifiers[] = {
[kAccomplishmentTitleSection] = @"AccomplishmentTitleCell",
[kAccomplishmentCategorySection] = @"AccomplishmentCategoryCell"
};
OLD:
FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
[db executeUpdate:@"insert into namedparamtest values (:a, :b, :c, :d)" withParameterDictionary:dictionaryArgs];
NEW:
FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:dbPath];
[queue inDatabase:^(FMDatabase *db) {
require 'rubygems'
require 'oauth'
require 'yaml'
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
def get_access_token
p "get_access_token: Initializing Consumer"
consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, {
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!-- iframe used for attempting to load a custom protocol -->
<iframe style="display:none" height="0" width="0" id="loader"></iframe>
function doesAppExist() {
// try to open iOS application
document.location = 'customiosappurl://';
// if above failed, nothing happened
// set a timeout and do something else
!window.document.webkitHidden && setTimeout(function() {
setTimeout(function() {
window.location = '//apple.itunes.com/whatever'
}, 100);
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person