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
DivineDominion / execute.rb
Last active Oct 17, 2019
Extract note links from a source note
View execute.rb
#!/usr/bin/env ruby
# Avoid all the script configuration and use this convenience script instead!
# 1) Put it into the same folder,
# 2) run the script: `ruby _execute.rb PATH/TO/THE_NOTE.txt`
# Configure here #
View test-descriptions-for-fizz-buzz.js
// I have some testing framework in the scope
// Questions below:
// 1. Should the description be like it is here, in first `it`, or with `only` word added:
// "should return Fizz when the number is divisible only by 3"
// That would imply that the number is divisible by 3 only, which is technically not true, as it is divisible
// by 1 as well, and some numbers, e.g. 6, 9, and so on, are divisible by themselves.
it('should return Fizz when the number is divisible by 3', () => {
// 2. Is that name enough, having `any` in it, to be complete in what numbers are producing `fizz`.
// There is also a matter of adding `only` (similar to case #1) having `anyNumberDivisibleOnlyBy3`.
IanKeen / Decodable+Random.swift
Last active Mar 8, 2019
Custom Decoder that can be used to create Decodable instances that are populated with random values
View Decodable+Random.swift
import Foundation
extension Decodable {
public static func randomInstance() throws -> Self {
let decoder = RandomDecoder()
return try Self(from: decoder)
private class RandomDecoder: Decoder {
DivineDominion / cocoaconv.rb
Last active Sep 28, 2018
Convert libMultiMarkdown enums to Swift-bridgeable NS_ENUMs. Pass the path to libMultiMarkdown.h to the script when running.
View cocoaconv.rb
#!/usr/bin/env ruby
require 'optparse'
CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
FALLBACK_PATH = File.join(CURRENT_PATH, "..", "build-xcode", "Debug", "include", "libMultiMarkdown", "libMultiMarkdown.h")
options = {:mode => :nsenum} do |parser|
parser.banner = "Usage: #{$0} [options] path/to/libMultiMarkdown.h"
AliSoftware / SwiftCopying.swift
Last active Aug 24, 2017
TypeSafe copy()/mutableCopy() (NSCopying/NSMutableCopying) in Swift
View SwiftCopying.swift
import Foundation
//: Swift type-safe protocol versions of (Mutable)Copying
protocol SwiftCopying {
associatedtype NonMutableType = Self
func clone() -> NonMutableType
extension SwiftCopying where Self: NSCopying {
func clone() -> NonMutableType {
return self.copy() as! NonMutableType
sjoerdvisscher / minimal.swift
Created Jun 28, 2017
Using Decodable to generate a minimal value
View minimal.swift
struct MinimalDecoder : Decoder {
var codingPath = [CodingKey?]()
var userInfo = [CodingUserInfoKey : Any]()
public func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> {
return KeyedDecodingContainer(MinimalKeyedDecodingContainer<Key>(decoder: self))
public func unkeyedContainer() throws -> UnkeyedDecodingContainer {
return DecodingContainer(decoder: self)
mminer / MyService.swift
Last active Oct 11, 2019
Components of XPC service.
View MyService.swift
import Foundation
class MyService: NSObject, MyServiceProtocol {
func upperCaseString(_ string: String, withReply reply: @escaping (String) -> Void) {
let response = string.uppercased()
darrensapalo / rxswift3networkcalltoobject
Last active Jul 8, 2019
Swift 3 example of a network request wrapped as an RxSwift Observable and converted into a class object
View rxswift3networkcalltoobject
import Foundation
import RxSwift
let networkQueue = DispatchQueue(label: "com.appName.networkQueue")
class Queue {
var name: String
public init (_ name: String) { = name
set -e
# set your Frameworks path here
khanlou / Quicksort.swift
Created Dec 9, 2016
Quicksort - the only use for partition(by:) I could find
View Quicksort.swift
import Foundation
extension Array where Element: Comparable {
mutating func quickSort() {
extension ArraySlice where Element: Comparable {
mutating func quickSort() {
You can’t perform that action at this time.