Skip to content

Instantly share code, notes, and snippets.

View herzi's full-sized avatar

Sven Herzberg herzi

  • Hamburg, Europe
View GitHub Profile
@herzi
herzi / Combine vs. Monotonic Header.md
Created September 27, 2020 17:29
Combine vs. Monotonic Headers

Combine vs. Monotonic Properties

TLDR: How to serialize independent, heterogeneous HTTP requests using Combine and Foundation.

I have a view model that displays to pieces of information from an API, let's assume it's a user's bio and the latest posts from the user.

class ViewModel: ObservableObject {
    @Published var bio: String?
 @Published var posts: [Post]?
@herzi
herzi / zshrc
Created March 5, 2020 16:20
A .zshrc for starters
#!/bin/zsh
# brew install antigen
source /usr/local/share/antigen/antigen.zsh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle colored-man-pages
//
// Picker+Style.swift
//
// Copyright 2019, Sven Herzberg
//
// License: MIT
//
// 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
@herzi
herzi / xcci.md
Last active August 29, 2015 14:19 — forked from quellish/xcci.md

Variable

Type

@herzi
herzi / xcci.md
Last active August 29, 2015 14:19 — forked from quellish/xcci.md

Variable

Type

@herzi
herzi / spec.md
Last active August 29, 2015 14:09 — forked from ePirat/spec.md

Icecast protocol specification

What is the Icecast protocol?

When speaking of the Icecast protocol here, actually it's just the HTTP protocol, and this document will explain further how source clients need to send data to Icecast.

HTTP PUT based protocol

Since Icecast version 2.4.0 there is support for the standard HTTP PUT method. The mountpoint to which to send the data is specified by the URL path.

@herzi
herzi / params.js
Last active August 29, 2015 14:05 — forked from domenic/params.js
fully promisified version
/**
* Turns: {
* keyOne: promiseOne,
* keyTwo: promiseTwo
* } into {
* keyOne: resolutionOne,
* keyTwo: resolutionTwo
* }
*
* (To avoid messing around with unclear array indices when calling different
@herzi
herzi / params.js
Last active August 29, 2015 14:05
/**
* Turns: {
* keyOne: promiseOne,
* keyTwo: promiseTwo
* } into {
* keyOne: resolutionOne,
* keyTwo: resolutionTwo
* }
*
* (To avoid messing around with unclear array indices when calling different
NSURLSession* session; // wie du an die kommst, weißt du ja jetzt
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/"]];
[request setValue:@"<ETag vom letzten Mal>" forHTTPHeaderField:@"If-None-Match"];
[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
error = [NSError errorWithDomain:@"FIXME" code:0 userInfo:@{@"unexpectedType": [[response class] description]}];
}
NSHTTPURLResponse* http = (NSHTTPURLResponse*)response;
if (http.statusCode == 304) {
@herzi
herzi / myApp.js
Last active December 24, 2015 21:39
Testing decorated services in AngularJS
(function () {
var myApp = angular.module('myApp', []);
}());