Skip to content

Instantly share code, notes, and snippets.

Christian Tietze DivineDominion

Block or report user

Report or block DivineDominion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lilwiki.rb
require 'rubygems'
require 'sinatra'
require 'rdiscount'
require 'haml'
require 'dm-core'
require 'sinatra-authentication'
use Rack::Session::Cookie, 'shhhhhhhhhhhhhhh~'
class Page
View date.m
#include <time.h>
+ (NSDate *)dateFromISO8601String:(NSString *)string {
if (!string) {
return nil;
}
struct tm tm;
time_t t;
@steipete
steipete / PSPDFThreadSafeMutableDictionary.m
Last active May 28, 2019
Simple implementation of a thread safe mutable dictionary. In most cases, you want NSCache instead, but it can be useful in situations where you want to manually control what is evicted from the cache in low memory situations.**Warning:** I only use this for setting/getting keys. Enumeration is not thread safe here and will still throw exception…
View PSPDFThreadSafeMutableDictionary.m
//
// PSPDFThreadSafeMutableDictionary.m
//
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
//
// 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
// copies of the Software, and to permit persons to whom the Software is
@luisobo
luisobo / README.md
Last active Jan 14, 2016
Hide iOS Simulator when running Unit Tests.
View README.md

Hide iOS Simulator when running Unit Tests.

Based on this work, that @Dan2552 pointed out.

Instructions:

  1. Clone this gist (git clone https://gist.github.com/6201428.git hide_ios_simulator)
  2. Xcode -> Preferences -> Behavior -> Testing -> Generates output
  3. Run script -> Choose script -> Select hide_simulator
View solarized-dark.css
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@jstn
jstn / RandomNumbers.swift
Last active Oct 2, 2018
generate random numbers for 64-bit types while mitigating modulo bias
View RandomNumbers.swift
/*
`arc4random_uniform` is very useful but limited to `UInt32`.
This defines a generic version of `arc4random` for any type
expressible by an integer literal, and extends some numeric
types with a `random` method that mitigates for modulo bias
in the same manner as `arc4random`.
`lower` is inclusive and `upper` is exclusive, thus:
@kristopherjohnson
kristopherjohnson / DataStore.swift
Created Sep 28, 2014
Swift: Core Data persistence stack
View DataStore.swift
import Foundation
import CoreData
// "Class variables" used in DataStore.sharedDataStore()
private var _instance: DataStore?
private var DataStoreClassLock = NSRecursiveLock()
private let appStoreFilename = "DataStore.sqlite"
private let testStoreFilename = "test_DataStore.sqlite"
@natecook1000
natecook1000 / NSScanner+Swift.swift
Created Mar 3, 2015
Swift-friendly NSScanner methods
View NSScanner+Swift.swift
// NSScanner+Swift.swift
// A set of Swift-idiomatic methods for NSScanner
//
// (c) 2015 Nate Cook, licensed under the MIT license
import Foundation
extension NSScanner {
// MARK: Strings
@robb
robb / Example.m
Last active Sep 25, 2018
A macro to convert nullable references to nonnull references while triggering an assert if the expression is actually true. Think of this as unsafe unwrap for Objective-C.
View Example.m
NS_ASSUME_NONNULL_BEGIN
void Log(NSString *foo) {
NSLog(@"%@", foo);
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSDictionary *stuff = @{
@"a": @"Test"
View nstextview+caret.m
# pragma mark Custom caret
- (void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag {
aRect.size.width = self.caretWidth;
[super drawInsertionPointInRect:aRect color:aColor turnedOn:flag];
}
// This is a hack to get the caret drawing to work. I know, I know.
- (void)setNeedsDisplayInRect:(NSRect)invalidRect {
invalidRect.size.width += self.caretWidth - 1;
You can’t perform that action at this time.