Skip to content

Instantly share code, notes, and snippets.

View maxsz's full-sized avatar

Maximilian Szengel maxsz

View GitHub Profile
@maxsz
maxsz / test
Created October 27, 2022 13:38
test
test
@maxsz
maxsz / SequenceExtensions.swift
Created July 25, 2016 14:08
Swift SequenceType Extensions
extension SequenceType {
// Index an array with a property.
@warn_unused_result
func index<T: Hashable>(@noescape by indexFunc: (Generator.Element -> T)) -> [T: Generator.Element] {
var dict: [T: Generator.Element] = [:]
for element in self {
let index = indexFunc(element)
dict[index] = element
@maxsz
maxsz / NSPopoverDelegateResponderFix.m
Created May 4, 2016 09:32
Workaround for firstResponder NSPopover bug
- (void)popoverWillClose:(NSNotification *)notification
{
// https://openradar.appspot.com/26064913
// Turns out that Apple has a bug in their responder chain. It stores a non-weak (assign)
// "_previousResponder", which is a button inside the deallocated popover. During window
// state restoration/archiving, it tries to access this object (the button) and crashes.
// We work around this by resetting the "_previousResponder" when the popover closes.
NSResponder *firstResponder = [[[self view] window] firstResponder];
[[[self view] window] makeFirstResponder:nil];
@maxsz
maxsz / DelayedBlockOperation.swift
Last active October 26, 2018 11:21
Delayed NSOperation
class DelayedBlockOperation: NSOperation {
private var delay: NSTimeInterval = 0
private var block: (() -> Void)? = nil
private var queue: dispatch_queue_t = dispatch_get_main_queue()
override var asynchronous: Bool { return true }
override var executing : Bool {
get { return _executing }
set {
willChangeValueForKey("isExecuting")

Keybase proof

I hereby claim:

  • I am maxsz on github.
  • I am maxsz (https://keybase.io/maxsz) on keybase.
  • I have a public key whose fingerprint is 57B1 EF7D EE00 DD2C FA8B 98AD 52C4 992F 0226 BFD5

To claim this, I am signing this object:

@maxsz
maxsz / gist:cddf3f20456d2a053b70
Created August 9, 2013 09:06
Slow newrelic_rpm gem with rubinius and rails 4.
% ruby --version
rubinius 2.0.0.n198 (1.9.3 417f847d 2013-07-17 JI) [x86_64-apple-darwin12.4.0]
% rails --version
Rails 4.0.0
Create a new Rails app and switch to it's folder
% rails new TestApp
% cd TestApp