Skip to content

Instantly share code, notes, and snippets.

View julian-savage's full-sized avatar

Julian Savage julian-savage

  • Tokyo, Japan
View GitHub Profile
@julian-savage
julian-savage / expand_vars.py
Created May 20, 2017 14:02
Create all possible expansions for a string containing variables
import re
def expand_vars(value, vars):
return [vars.get(seg, [ seg ]) for seg in re.split('(\$\w+)', value)]
def join_segments(segments):
return [reduce(lambda acc, seg: (acc[0]+seg[acc[1]%len(seg)], acc[1]/len(seg)),
segments,
("", val))[0]
for val in range(0, reduce(lambda n, seg: n * len(seg), segments, 1))]
@julian-savage
julian-savage / GzipInputStream.swift
Created August 7, 2016 13:23
InputStream which decompresses gzip/zlib compressed data
import Foundation
import Compression
public class GzipInputStream : InputStream {
private var decompressor : Decompressor
override public init(data: Data) {
let compressedInputStream = InputStream(data: data)
self.decompressor = Decompressor(compressedInputStream)