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, {
@onlyyoujack
onlyyoujack / gist:4601546
Created January 23, 2013 03:11
UIButton remove all target-actions
Call removeTarget:action:forControlEvents: pass nil for the target, NULL for action, and use a control mask that sets all bits (UIControlEventAllEvents). Something like this:
[someControl removeTarget:nil
action:NULL
forControlEvents:UIControlEventAllEvents];
https://developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html
http://stackoverflow.com/questions/3340825/uibutton-remove-all-target-actions
Pod::Spec.new do |s|
s.name = 'ShareKit'
s.version = '2.0'
s.summary = 'In order to make it easier for new users to choose a canonical fork of ShareKit, the ShareKit community has decided to band together and take responsibility for collecting useful commits into what we're calling "ShareKit 2". It is now ready for you. It is the first officially stable version of ShareKit since February 2010, with more frequent updates expected.'
s.homepage = 'https://github.com/ShareKit/ShareKit'
s.author = 'ShareKit'
s.source = { :git => 'https://github.com/onlyyoujack/ShareKit.git', :tag => 'v2.0' }
s.source_files = 'ShareKit/Classes/ShareKit'
end
<!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>