Skip to content

Instantly share code, notes, and snippets.

View fictorial's full-sized avatar

Brian Hammond fictorial

View GitHub Profile
static inline void dispatchOncePersistent(NSString *prefsKey, void (^aBlock)())
{
if (![[NSUserDefaults standardUserDefaults] boolForKey:prefsKey]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:prefsKey];
[[NSUserDefaults standardUserDefaults] synchronize];
aBlock();
}
}
Thanks guys, with a little help from a friend I ended up fixing it by
setting on the pods project "Build active architechtures only" to no. and
then the standard architechtures for both the targets and the project.
Hope this helps someone.
@fictorial
fictorial / ContactsLoader.h
Last active August 29, 2015 14:03
Trying to get Facebook social profile from AddressBook
@interface LocalContact : NSObject
@property (nonatomic, copy) NSString *firstName;
@property (nonatomic, copy) NSString *lastName;
@property (nonatomic, copy, readonly) NSString *fullName;
@property (nonatomic, copy) NSString *mobileNumber;
@property (nonatomic, copy) NSString *normalizedMobileNumber;
@property (nonatomic, copy) NSString *facebookID;
@fictorial
fictorial / acks_acks.txt
Created October 31, 2014 12:52
Please do not ACK my ACKs!
Please do not ACK my ACKs!
I already have stacks and stacks!
If you would be so kind, offer me some pork rind.
You see, I prefer snacks, not ACKs!
I have a yak. His name is Jack.
And when he walks, Jack makes tracks.
I follow his tracks to stacks of snacks.
But when you ACK my ACKs, all I see are stacks of ACKs.
I cannot see Jack's yak tracks!
@fictorial
fictorial / autoreload.py
Last active August 29, 2015 14:08
autoreload
#!/usr/bin/env python
from os.path import getmtime
import sys, subprocess, time
import signal
usage = 'usage: autoreload "/bin/foo --bar" *.py'
try:
cmd = sys.argv[1]
@fictorial
fictorial / app.js
Created July 2, 2015 14:24
Clara.io issue w.r.t. THREE.js import and spotlights
var scene, camera, renderer;
$(function () {
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMapEnabled = true;
document.body.appendChild(renderer.domElement);
/*
* This is a simple program to run Node.js as the
* specified user and in a chroot.
*
* BUILD:
* gcc -o chrooted-node chrooted-node.c
*
* USE:
* sudo chrooted-node <as-user> <chroot-dir> <file.js>
*
/**
* Tries to create the directories of the given path
* if they do not exist already.
*/
this.mkpath = function(path, mode) {
var parts = path.split('/');
if (!parts || parts.length == 0)
return;
// Process files in optimally-sized chunks without
// reading the entire file into memory.
var posix = require("posix");
this.FileOpenError = function (path, message) {
this.message = message || "failed to open file";
this.path = path;
};
GLOBAL.import_package = function(name) {
var package = {};
require("posix").readdir(name).wait()
.filter(function (filename) {
return filename.match(/^(.+)\.js$/);
})
.forEach(function (filename) {
var basename = filename.split(/^(.+)\.js$/)[1];
package[basename] = require("./" + name + "/" + basename);
});