Skip to content

Instantly share code, notes, and snippets.

View joelrfcosta's full-sized avatar
🔥

Joel Costa joelrfcosta

🔥
View GitHub Profile
@joelrfcosta
joelrfcosta / buildStaticObjCLib
Last active October 11, 2015 12:28 — forked from adamgit/gist:3705459
Automatically create cross-platform (simulator + device) static libraries for Objective C / iPhone / iPad
#
# c.f. StackOverflow question/answer here: http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4
#
# Version 2.3
#
# Latest Change:
# - Apple's handling of "project files" is broken; added a workaround for Xcode 4.5
# - Added automatic FAIL BUILD if any of the internal commands fail
#
# Purpose:
@joelrfcosta
joelrfcosta / SingletonClass.m
Last active June 5, 2021 18:26 — forked from lukeredpath/ExampleClass.m
Singleton macro with blocks using GCD
#define SingletonWithBlock(block) static dispatch_once_t pred = 0; \
__strong static id _sharedObject = nil; \
dispatch_once(&pred, ^{ \
_sharedObject = block(); \
}); \
return _sharedObject; \
@implementation SingletonClass
+ (id)sharedInstance
@joelrfcosta
joelrfcosta / preloadFonts.m
Last active December 16, 2015 11:09 — forked from stuartcarnie/gist:945862
Preload fonts using CGD
#import <CoreText/CoreText.h>
...
// preload
dispatch_queue_t queue = dispatch_queue_create("com.company.worker", NULL);
dispatch_async(queue, ^(void) {
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setObject:@"Helvetica" forKey:(id)kCTFontFamilyNameAttribute];
[attributes setObject:[NSNumber numberWithFloat:36.0f] forKey:(id)kCTFontSizeAttribute];
@joelrfcosta
joelrfcosta / api.js
Created April 20, 2013 09:53 — forked from fwielstra/api.js
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
#!/bin/bash
## Nodejs custom version installer
##
## Ronaldo Barbachano April 2013
## Based on the openshift/nodejscustom-version-openshift repo
##
## Supply with path to existing openshift repo, or move script into
## repo root.
##
## Probably less headaches if this is run immediately after
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
find . -name "*.m" | xargs genstrings
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@joelrfcosta
joelrfcosta / GIFDownloader.h
Created April 20, 2016 01:04 — forked from paul-delange/GIFDownloader.h
Convert remote GIF into something MPMoviePlayerController can use
//
// GIFDownloader.h
// TheJoysOfCode
//
// Created by Bob on 29/10/12.
// Copyright (c) 2012 Tall Developments. All rights reserved.
//
#import <Foundation/Foundation.h>