Skip to content

Instantly share code, notes, and snippets.

@ahayman
ahayman / CGPathBevel.h
Last active October 5, 2015 15:48
Core Graphics Beveling Routine
//
// CGPathBevel.h
//
// Created by Aaron Hayman on 6/21/12.
// Copyright (c) 2012 FlexileSoft, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
void bevelPath(CGPathRef path, CGContextRef context, CGFloat bevelDepth, CGColorRef highlight, CGColorRef shadow, CGFloat lightSourceAngle, BOOL evenOddShadows, BOOL eofFill);
@staltz
staltz / introrx.md
Last active November 20, 2024 15:03
The introduction to Reactive Programming you've been missing
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@KyleLeneau
KyleLeneau / ExampleViewController.swift
Last active October 31, 2015 21:08
Quick implementation of a UITextView that supports placeholder text and cursor position just like UITextField
class ExampleViewController: UIViewController, UITextViewDelegate {
@IBOutlet var placeholderInput: UIPlaceHolderTextView! {
didSet {
placeholderInput.placeholder = "Your custom placeholder text here"
placeholderInput.placeholderColor = UIColor.redColor() // what ever color you want here too
placeholderInput.text = placeholderInput.placeholder
placeholderInput.textColor = placeholderInput.placeholderColor
placeholderInput.selectedTextRange = placeholderInput.textRangeFromPosition(placeholderInput.beginningOfDocument, toPosition: placeholderInput.beginningOfDocument)
@KyleLeneau
KyleLeneau / InspectAPK.sh
Created July 15, 2016 07:20 — forked from laomo/InspectAPK.sh
Inspect APK's info like package name, version code, version name, etcetera
#!/bin/bash
apk_file=$1
if [ -z $apk_file ]; then
apk_file_num=`ls *.apk | wc -l | tr -d ' '`
if [ $apk_file_num -gt 1 ]; then
echo "Ambiguous apk_files. Please enter one APK to inspect."
exit -1
fi
apk_file=`ls *.apk`
@anandabits
anandabits / HKT.swift
Last active December 25, 2023 00:57
Emulating HKT in Swift
// This example shows how higher-kinded types can be emulated in Swift today.
// It acheives correct typing at the cost of some boilerplate, manual lifting and an existential representation.
// The technique below was directly inspired by the paper Lightweight Higher-Kinded Polymorphism
// by Jeremy Yallop and Leo White found at http://ocamllabs.io/higher/lightweight-higher-kinded-polymorphism.pdf
/// `ConstructorTag` represents a type constructor.
/// `Argument` represents an argument to the type constructor.
struct Apply<ConstructorTag, Argument> {
/// An existential containing a value of `Constructor<Argument>`
/// Where `Constructor` is the type constructor represented by `ConstructorTag`