Skip to content

Instantly share code, notes, and snippets.

View lukaskollmer's full-sized avatar
👻
procrastinating

Lukas Kollmer lukaskollmer

👻
procrastinating
View GitHub Profile
@lukaskollmer
lukaskollmer / NSDate+Compare.swift
Created November 8, 2015 12:44
NSDate (Compare)
// MARK: NSDate + Compare
public func <(a: NSDate, b: NSDate) -> Bool {
return a.compare(b) == .OrderedAscending
}
public func ==(a: NSDate, b: NSDate) -> Bool {
return a.compare(b) == .OrderedSame
}
extension NSDate: Comparable { }
@lukaskollmer
lukaskollmer / daringfireball.net.js
Created December 31, 2015 13:14
dotjs configuration for daringfireball to make the website nicer
$('body').css({
'background-color' : 'white',
'font-family' : 'Avenir-Roman',
'line-height' : '200%'
});
$('div').css({
'color' : 'black',
'font-size' : '110%'
});
@lukaskollmer
lukaskollmer / Add Twitter Profile Picture to iOS Contacts.py
Last active February 15, 2016 05:45
Load Twitter profile pictures and set them as image to your iOS contacts
import twitter
import json
import urllib
import contacts
import console
from objc_util import *
import ui
import os
from PIL import Image
import webbrowser
@lukaskollmer
lukaskollmer / SequenceType+Exclude.swift
Last active May 7, 2016 16:17
Swift SequenceType exclude
extension SequenceType where Generator.Element : Equatable {
/// Returns `self`, excluding `element`
@warn_unused_result
public func excluding(element: Self.Generator.Element) -> [Self.Generator.Element] {
return self.filter({$0 != element})
}
public func excluding(element: [Self.Generator.Element]) -> [Self.Generator.Element] {
return self.filter({!(element.contains($0))})
}
@lukaskollmer
lukaskollmer / MediaPicker.py
Created May 12, 2016 18:36
Pythonista media picker example
# coding: utf-8
import console
from objc_util import *
console.clear()
importFramework('MediaPlayer')
MPMediaPickerController = ObjCClass('MPMediaPickerController')
@lukaskollmer
lukaskollmer / ImportFramework.py
Created May 12, 2016 18:41
Import ObjC frameworks
from objc_util import *
class ImportFrameworkError(Exception):
def __init__(self, name):
self.name = name
def __str__(self):
return 'Couldn\'t import {}.framewrork. (Neither from public, nor from private frameworks)'.format(self.name)
@lukaskollmer
lukaskollmer / photos_legacy.py
Created May 21, 2016 13:16
Add legacy functions to the photos module
import photos
def pick_an_image(show_albums=False, include_metadata=False, original=True, raw_data=False, multi=False):
assets = photos.get_assets()
return photos.pick_asset(assets, multi=multi).get_image()
photos.pick_image = pick_an_image
//
// UIFont+CustomFont.m
//
// Created by Lukas Kollmer on 6/13/15.
// Copyright (c) 2015 Lukas Kollmer. All rights reserved.
//
@import UIKit;
#import <objc/runtime.h>
@lukaskollmer
lukaskollmer / javascript.js
Last active May 27, 2016 08:01
How do languages handle removing objects during iteration?
var list = [1, 2, 3, 4];
list.forEach(function(entry) {
console.log(entry);
var index = list.indexOf(entry);
list.splice(index, 1);
});
console.log('list after loop: ', list);
/**
Console output:
@lukaskollmer
lukaskollmer / Demo.py
Created June 7, 2016 19:11
Pythonista crash demo
# coding: utf-8
#!/usr/bin/env python3
# Copyright (c) 2016 Lukas Kollmer <lukas@kollmer.me>
'''
Purpose: Showcases a crash when calling a nonexistent python method from within an Objective-C method
'''
import console
from objc_util import *