Skip to content

Instantly share code, notes, and snippets.

View futuretap's full-sized avatar

Ortwin Gentz, FutureTap futuretap

View GitHub Profile
@holtwick
holtwick / asmacro.m
Created October 29, 2010 07:54
Log current method and the arguments passed to that method
#if DEBUG
#import <objc/runtime.h>
#import <objc/message.h>
#include <execinfo.h>
#include <stdio.h>
void dumpCall(id *__selfPtr, SEL __cmd) {
// Get argument stack
id __self = *__selfPtr;
@jverkoey
jverkoey / Dictionary+GetWithDefault.swift
Last active November 5, 2015 09:11
Swift Dictionary get-with-default extension
import Foundation
extension Dictionary {
/**
Returns the value for the given key if it exists, otherwise stores and returns the result of
withDefault.
Example usage:
var dictionary: [String:[String]] = [:]
@beccadax
beccadax / WideningOperatorExamples.swift
Created August 29, 2014 07:32
Adds a prefix ^ operator which allows widening conversions between numeric types.
let i8 = Int8(42)
let i16 = Int16(42)
let i32 = Int32(42)
let i64 = Int64(42)
^i8 + i16
let f = Float(42.0)
let cgf = CGFloat(42.0)
let d = Double(42.0)
@steipete
steipete / UIPopoverPresentationController+PSPDFAdditions.m
Last active June 27, 2016 18:20
If you're annoyed about the incorrect arrow presentation on popovers (https://twitter.com/steipete/status/624521051855319040) use this category. Oh, and file a radar! I did.
@implementation UIPopoverPresentationController (PSPDFAdditions)
+ (void)load {
PSPDFSwizzleMethodImplementation(self, @selector(containerViewWillLayoutSubviews), ^(UIPopoverPresentationController *_self) {
// Refresh bar button view internals
[_self pspdf_updateBarButtonView];
((void( *)(id, SEL))objc_msgSend)(_self, PSPDFPrefixedSelector(containerViewWillLayoutSubviews));
});
}
@depth42
depth42 / Example for not breaking on certain exceptions
Last active August 9, 2016 14:14
Breaking on exceptions in Objective-C is cumbersome, because a breakpoint on objc_exception_throw cannot differentiate between an expected (caught) exception and an unexpected exception (like one from a failed assertion). To work around this, we intercept objc_exception_throw using mach_override and apply filter rules to decide whether to break …
@implementation NSManagedObjectContext (PWExtensions)
#ifndef NDEBUG
// Core Data uses exceptions to notify itself about optimistic locking failures. These exceptions are intercepted by
// Core Data and never reach the client code. Such an exception should not drop in the debugger because it is not raised
// due to a programming error.
// Since the exception is thrown inside -[NSManagedObjectContext save:], this category is a logical place to install
// the filter.
+ (void) load
{
@0xced
0xced / Emoji-iOS-10.0-14A5322e.json
Created August 8, 2016 22:38
Emoji from iOS beta 4 (14A5322e)
{
"People" : [
{
"Symbol" : "😀",
"Name" : "GRINNING FACE"
},
{
"Symbol" : "😬",
"Name" : "GRIMACING FACE"
},
@chriscdn
chriscdn / CLLocation+rhextensions.h
Last active August 17, 2018 07:23
A CLLocation category for determing the time zone from a location.
//
// CLLocation+rhextensions.h
//
// Copyright (C) 2015 by Christopher Meyer
// http://schwiiz.org/
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@kashif
kashif / geodatabases.md
Created May 27, 2011 10:09
GeoDatabases - a discussion

GeoDatabases

What is a GeoDatabase? and how is it diff from a regular db

  • Stores geometries
  • multi-dimensional
  • R-Tree indexing (Query planner uses it?)
  • projections
  • Supports Datums ?
  • Vector and raster support
@sononum
sononum / gist:6183139
Created August 8, 2013 09:26
accelerate Kaminari with Postgres insert into config/initializers/kaminari.rb
module Kaminari
module PageScopeMethods
def total_count
@_hacked_total_count || (@_hacked_total_count = self.connection.execute("SELECT (reltuples)::integer FROM pg_class r WHERE relkind = 'r' AND relname ='#{table_name}'").first["reltuples"].to_i)
end
end
end
@tordans
tordans / application_helper.rb
Created September 27, 2010 12:47
Eine pragmatische Lösung für das Übersetzungsproblem der Rails Methode distance_of_time_in_words(). Im Deutschen wird je nach Satzbau eine andere Ausgabe benötigt.
# ---
# Code gehört in app/helpers/application_helper.rb (oder einen anderen Helper…)
# ---
# Ausgabe: "Vor mehr als 5 Monaten"/"Vor etwa einem Jahr" — statt "Dauer: mehr als 5 Monate"/"Dauer: etwa 1 Jahr", wie es die Originalfunktion liefert
# Original-File: actionpack/lib/action_view/helpers/date_helper.rb, line 63
# Dokumenation: http://apidock.com/rails/v2.3.8/ActionView/Helpers/DateHelper/distance_of_time_in_words
# Changelog: I18n.with_options-Scope geändert auf "distance_in_words_gebeugt"
def distance_of_time_in_words_gebeugt(from_time, to_time = 0, include_seconds = false, options = {})
from_time = from_time.to_time if from_time.respond_to?(:to_time)