Skip to content

Instantly share code, notes, and snippets.

View stefc's full-sized avatar

Stefan B\u+00F6ther stefc

View GitHub Profile
import Foundation
public func IntPow(_ base: Int, exp: Int) -> Int {
guard exp >= 0 else {
return 0
}
guard exp > 0 else {
return 1
}
return (1..<exp).reduce(base) { (accu, _) in accu * abs(base) }
@stefc
stefc / IntTests.swift
Created January 4, 2018 08:06
Unit Test for IntPow functions
import XCTest
import xProcs
class IntTests: XCTestCase {
func testIntPow() {
XCTAssertEqual(IntPow(5, exp: 2), 25)
XCTAssertEqual(IntPow(5, exp: 1), 5)
XCTAssertEqual(IntPow(5, exp: 0), 1)
}
@stefc
stefc / Package.swift
Created January 4, 2018 07:34
The initially by the Swift-Package Manager generated Project Structure of xProcs
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "xProcs",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
@stefc
stefc / .gitignore
Last active January 4, 2018 07:28
Swift Package Manager Samples
.DS_Store
/.build
/Packages
/*.xcodeproj
Package.resolved
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/*_Info.plist
@stefc
stefc / DataVaultTokenizer.cs
Created August 11, 2017 06:57
DataVaultTokenizer
using System.Collections.Generic;
using Superpower.Model;
using Superpower.Parsers;
using Superpower;
using System;
namespace datavault.dsl {
class DataVaultTokenizer : Tokenizer<DataVaultToken> {
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1f8FlqHY9rraoXNiw56ESSl2WYM68j5sMruqLQe47Km1GOwCM3yeWUNKx+CKoDGHSyU4wxd9Dzs+JaCrhVdCF8rE5sqDxmK6d2fCIAHShlTs5vEfHqGbnKEipFptgMHvKE8+EHjR32bFzyjkOHzIiOtfs+9H69/OfvbLr3AcNvxAgtV8AM9hzXH8N7Qo5A6ZfI9UBtoFSTzUnKikh4Mw92+XDRDwraWMiEc/8TvVnfK7BX9d4NaKWfRwSh3qBCbh0wZhWBWRNdsX+YYrmmkyd6eVnkhEpnhbbNVbHw0xBScStqM/VuU4NVF6UJaZt9DRcq+UCwJz76KS2LTY75wjt jona.johannes.nitsch@txs.de
@stefc
stefc / Bootstrapper.cs
Created August 8, 2016 15:09
Bootstrapper for NancyFx combined with a FeatureToggle (FeatureSwitcher)
using System.Collections.Generic;
using System.Linq;
using Nancy;
using Nancy.Bootstrapper;
using FeatureSwitcher;
using txs.nextgen.apigateway.todo;
namespace txs.nextgen.apigateway
{
@stefc
stefc / Commands.cs
Created August 6, 2016 12:26
NancyFX ModelBinding Example
public class AufnehmenAufgabe : IDomainCommand {
public Guid Id { get; }
public string Titel { get; }
public AufnehmenAufgabe(Guid id, string titel)
{
Id = id;
Titel = titel;
}
}
[Unit]
Description=Docker Socket for the API
[Socket]
ListenStream=2375
BindIPv6Only=both
Service=docker.service
[Install]
WantedBy=sockets.target
@stefc
stefc / Fib1.cs
Created June 21, 2016 12:29
Functional Fibonacci
public static ulong fib1(int n)
{
ulong a = 0;
ulong b = 1;
for (int i = 0; i < n; i++)
{
ulong temp = a;
a = b;
b = temp + b;
}