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 201801041611 Focus ReSwift reducers to one state

Title: Focus ReSwift reducers to one state change ID: 201801041611 Tags: #reswift #srp

ReSwift reducers should not have conditional side-effects, changing different states out of convenience. That makes it hard to notice which action changed what. The condition is most of the problem, I think.

An ideal approach would be to have 1 reducer/action pair for each substate change.

When reducers overlap (they touch the same state), this can become a problem. (IncreaseCounter and DecreaseCounter are a bad example.) Conditional changes to another substate should be extracted as another action which is dispatched by a Middleware under similar circumstances.

DivineDominion /
Last active Dec 13, 2016
nvALT Preview Template featuring relative paths

Run this from your terminal to execute the setup script. It creates the directory and downloads the template right into this new folder.

curl -s | bash 

Aferwards, you can change the base directory in ~/Library/Application\ Support/nvALT/template.html as expected.

DivineDominion / ModalDialogController.swift
Created Sep 6, 2016
Showing any NSWindowController as an app modal
View ModalDialogController.swift
class ModalDialogController: NSWindowController {
convenience init() {
self.init(windowNibName: "ModalDialogController")
@IBOutlet var closeButton: NSButton!
override func windowDidLoad() {
DivineDominion / AppDelegate.swift
Created May 18, 2016
WTF: Crashing NSTableHeaderCell subclass ¯\_(ツ)_/¯
View AppDelegate.swift
// AppDelegate.swift
// TableZombies
// Created by Christian Tietze on 18/05/16.
// Copyright © 2016 Christian Tietze. All rights reserved.
import Cocoa
View install_wiki.rb
#!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
require 'open3'
# Print banner when arguments are missing
ARGV << '-h' if ARGV.count < 2
DivineDominion / Gemfile
Last active May 11, 2016 — forked from erikpukinskis/lilwiki.rb
Super short & minimal wiki using Sinatra and DataMapper
View Gemfile
# A sample Gemfile
source ""
gem 'sinatra'
gem 'sinatra-authentication'
gem 'data_mapper'
gem 'dm-sqlite-adapter'
gem 'rdiscount'
View Subscription.swift
import Foundation
public struct Subscription<State: Any> {
let subscriber: AnyStoreSubscriber
let selector: (State -> Any)
init(aSubscriber: AnyStoreSubscriber) {
DivineDominion / in_memory_strategy.rb
Created Sep 22, 2013
Repository in Ruby according to Eric Evans (2006): Domain-Driven Design. Tackling complexity in the heart of software, Upper Saddle River, NJ: Addison-Wesley.
View in_memory_strategy.rb
class InMemoryStrategy
def matching(criteria)
results = []
domain_objects.each do |object|
results << object if criteria.satisfied_by?(object)
DivineDominion / com.brettterpstra.gitlogger.plist
Last active Dec 18, 2015 — forked from ttscoff/gitlogger.rb
Logs selected git repository commits to a text file or Day One for the past day once in the morning.
View com.brettterpstra.gitlogger.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
DivineDominion /
Last active Dec 15, 2015
Where I show the most inefficient way to duplicate HTML rendering for JavaScript XHR form validation callbacks.

Because Rails' Unobstrusive JavaScript (UJS) driver rails.js and jQuery won't execute any JavaScript in XMLHttpRequest's response bodies when the status code is 400 or 424 or something similar, I had to instruct the client (jQuery) myself to render error messages on form validation.

This is my first attempt to do so: instead of a JS request, respond with JSON and do the interface changes client-side. Problem is, the JavaScript code is sent to the client only once, hence ERB view templates aren't available during execution. I couldn't just use Rails helpers this way to refactor rendering flash messages. The HTML was spread across three places then: create.html.erb to handle synchroneous requests and render both flash messages and form validation error, to render errors and lastly create.js.erb to render success messages and insert the new entry.

It worked, and it was a fun ride since I didn't

You can’t perform that action at this time.