Skip to content

Instantly share code, notes, and snippets.

@wukerplank
wukerplank / BlockStateSubscriber.swift
Created April 25, 2018 17:55
Example for a ReSwift block state subscriber - awesome for debugging.
class BlockStoreSubscriber<T: StateType>: StoreSubscriber {
private var updateBlock: (T) -> Void
init(_ updateBlock: @escaping (T) -> Void) {
self.updateBlock = updateBlock
}
func newState(state: T) {
self.updateBlock(state)
@wukerplank
wukerplank / examples.rb
Last active August 15, 2018 12:52
A small class that crawls a directory recursively and yields matched filenames to a block.
require 'recursive_crawler'
# Just crawl a directory and echo all found filenames
c = RecursiveCrawler.new(->(filename)}{ puts filename })
c.run('.')
# Crawl a directory and look for video files
c = RecursiveCrawler.new(->(filename)}{ puts filename }, /\A.+\.(avi|mkv|mpg|mpeg|wmv|mp4|m4v|divx)\z/i)
c.run('/path/to/my/movie/collection')