Skip to content

Instantly share code, notes, and snippets.

View jerrymarino's full-sized avatar

Jerry Marino jerrymarino

View GitHub Profile
#import <objc/runtime.h>
#import <objc/message.h>
#import <QuartzCore/QuartzCore.h>
#define PROPERTY(propName) NSStringFromSelector(@selector(propName))
// A better assert. NSAssert is too runtime dependant, and assert() doesn't log.
// http://www.mikeash.com/pyblog/friday-qa-2013-05-03-proper-use-of-asserts.html
// Accepts both:
// - PSPDFAssert(x > 0);
@jerrymarino
jerrymarino / MagicalRecordNoParents.m
Created July 22, 2013 15:24
Magical Record without parent contexts
//Also fine to use MR_coordinatorWithInMemoryStore
NSPersistentStoreCoordinator *coordinator = [NSPersistentStoreCoordinator MR_newPersistentStoreCoordinator];
[NSPersistentStoreCoordinator MR_setDefaultStoreCoordinator:coordinator];
NSManagedObjectContext *defaultContext = [NSManagedObjectContext MR_newMainQueueContext];
defaultContext.persistentStoreCoordinator = coordinator;
[NSManagedObjectContext performSelector:@selector(MR_setDefaultContext:) withObject:defaultContext];
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@jerrymarino
jerrymarino / ecmascript-rough-object-size
Created August 4, 2013 02:02
ECMAScript object size
function roughSizeOfObject( object ) {
var objectList = [];
var stack = [ object ];
var bytes = 0;
while ( stack.length ) {
var value = stack.pop();
if ( typeof value === 'boolean' ) {
%%% @author Sergey Prokhorov <me@seriyps.ru>
%%% @copyright (C) 2013, Sergey Prokhorov
%%% @doc
%%% Walker alias method - efficient random selection with defined probabilities.
%%% <http://en.wikipedia.org/wiki/Alias_method>
%%%
%%% > ProbabilityValueList = [{10, a}, {20, b}, {30, c}, {40, d}],
%%% > WalkerVectors = walker_alias:build(ProbabilityValueList),
%%% > RandomValue = walker_alias:choice(WalkerVectors).
%%%
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
SYS_CACHES_DIR="/Library/Caches"
# YouCompleteMe configuration for OSX development
import os
import ycm_core
flags = [
'-resource-dir',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0',
'-isysroot',
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk',
'-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include',
@jerrymarino
jerrymarino / vim script
Created April 19, 2017 07:14
Jump to semantic placeholders in vim
function! Generate_placeholder_pattern()
return '<#\%(T##\)\?\%([^#]\+##\)\?\([^#]\+\)#>'
endfunction
function! Jump_to_placeholder()
if &filetype !=# 'swift'
return ''
end
if !Check_placeholder_existence()
@jerrymarino
jerrymarino / run_ios_sim.sh
Last active April 7, 2024 08:45
Build and run an iOS application on the simulator from the command line
#!/bin/bash
# run_ios_sim builds and runs an iOS app on the simulator
#
# It is designed to replicate the behavior of "Run" in Xcode and assumes basic
# xcodebuild usage.
#
# USAGE:
# export IOS_SIM_UDID=342F9A20-DF48-41A9-BE60-C6B35F47E97F; \
# export BUNDLE_IDENTIFIER=a.Some; \
# export APP_PATH=$PWD/Build/Debug-iphonesimulator/$APP_NAME.app \
@jerrymarino
jerrymarino / vim_and_tmux_on_osx.md
Created April 25, 2017 16:41
Setting up vim and tmux on OSX

Upgrade Vim to MacVim

Firstly, install macvim and get the keyboard working

Note: easiest way here is to use macvim from brew

brew install macvim --with-override-system-vim

In .vimrc