Skip to content

Instantly share code, notes, and snippets.

protocol Calendar {
typealias Unit: BidirectionalIndexType
typealias Era: Unit
typealias Year: Unit
typealias Month: Unit
typealias Week: Unit
typealias Day: Unit
typealias Weekday: Unit
typealias Hour: Unit
@neonichu
neonichu / fauxpas2puncover.rb
Last active August 29, 2015 14:06
Convert JSON generated by Faux Pas to a format understood by PuncoverPlugin.
#!/usr/bin/env ruby
require 'rubygems'
require 'date'
require 'json'
input = JSON.parse(ARGF.read)
output = { 'meta' => { 'timestamp' => DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%6N') } }
symbols = {}
@mchambers
mchambers / reflect.swift
Last active March 5, 2021 09:20
Basic Reflection in Swift.
// Let's define a basic Swift class.
class Fruit {
var type=1
var name="Apple"
var delicious=true
}
// We can get at some info about an instance of an object using reflect(), which returns a Mirror.
reflect(Fruit()).count
reflect(Fruit())[1].0
@danielpunkass
danielpunkass / fsa.py
Last active July 22, 2018 02:50
A simple lldb module for adding an "fsa" command to inject F-Script anywhere into any process
"""
Automate loading of F-Script Anywhere into any app.
By Daniel Jalkut - @danielpunkass - http://indiestack.com/
To set up:
0. Make sure you have FScript.framework installed in /Library/Frameworks (http://www.fscript.org)
1. Copy this script to ~/.lldb/fsa.py
2. Add the following to your ~/.lldbinit file:
import lldb
import re
import shlex
# This script allows Xcode to selectively ignore Obj-C exceptions
# based on any selector on the NSException instance
def getRegister(target):
if target.triple.startswith('x86_64'):
return "rdi"
@trinitronx
trinitronx / xcode-cli-tools.sh
Last active January 18, 2024 05:20
Script to download & install XCode Command Line tools on OSX 10.7 or 10.8. Lifted from jedi4ever/veewee template.
#!/bin/sh
# 2021-12-09:
# This script is no longer supported!
# Apple broke all direct downloads without logging with an Apple ID first.
# The number of hoops that a script would need to jump through to login,
# store cookies, and download is prohibitive.
# Now we all must manually download and mirror the files for this to work at all :'-(
OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}')
@jarsen
jarsen / NSArrayMagic.m
Last active July 24, 2018 09:22
How to do lots of cool things with NSArray. Inspired by NSHipster and WWDC 2013 Session 228 - "Hidden Gems in Cocoa and Cocoa Touch"
NSArray *albums = @[[Album albumWithName:@"Random Access Memories" price:9.99f],
[Album albumWithName:@"Clarity" price:6.99f],
[Album albumWithName:@"Weekend in America" price:7.99f],
[Album albumWithName:@"Weekend in America" price:7.90f],
[Album albumWithName:@"Bangarang EP" price:2.99f]];
// Reversing an Array
__unused NSArray *reversed = albums.reverseObjectEnumerator.allObjects;
// PREDICATES
@dctrwatson
dctrwatson / commit_diff.sh
Last active April 9, 2024 20:50
Update Phabricator diff depending on build status
BASE_COMMIT=$(echo {\"diff_id\": ${DIFF_ID}} | arc call-conduit differential.getdiff | awk -v RS=',' -v FS=':' '$1~/\"sourceControlBaseRevision\"/ {print $2}' | tr -d \")
# Update repo (can be taken care of by jenkins too)
git fetch --all
git remote prune origin
# We only want to test the diff so reset to base
git reset --hard ${BASE_COMMIT}
git clean -fdx
@ridiculousfish
ridiculousfish / gist:3729531
Created September 15, 2012 20:06
A (buggy) thread safe set written in Go
package main
import (
"fmt"
)
type SetTest struct {
val string
result chan bool
}
@ridiculousfish
ridiculousfish / SafeSet.m
Created June 26, 2012 09:22
A thread safe set written in Objective-C
#import <Foundation/Foundation.h>
@interface SafeSet : NSObject {
NSMutableSet *set;
dispatch_queue_t queue;
}
@end
@implementation SafeSet