Skip to content

Instantly share code, notes, and snippets.

View tanner0101's full-sized avatar
💭
💧

Tanner tanner0101

💭
💧
View GitHub Profile
import Foundation
public protocol Stream: class {
var isClosed: Bool { get }
func close() throws
func setTimeout(_ timeout: Double) throws
}
public protocol ReadableStream: Stream {

Vapor Auth 2.0

Token (Authorization Bearer) authenication with a table holding the tokens.

Request

GET /name HTTP/1.1
Authorization: Bearer foobar
Host: 0.0.0.0:8080
@tanner0101
tanner0101 / conversion.swift
Last active July 11, 2016 20:37
CLI -> Toolbox
#!/usr/bin/env swift
print("This CLI updater is out of date.")
print("Please visit docs.qutheory.io or run")
print("the following command to update.")
print()
print("curl -sL toolbox.qutheory.io | bash")
@tanner0101
tanner0101 / install-swift-linux.sh
Last active July 28, 2016 19:19
Install Swift on Linux
#!/bin/bash
if [[ "$(uname)" == "Linux" ]]; then
URL=https://swift.org/builds/swift-3.0-preview-1/ubuntu1404/swift-3.0-preview-1/swift-3.0-preview-1-ubuntu14.04.tar.gz
START=$(pwd)
cd $HOME
wget $URL -O - | tar xz
package com.hlprmnky.vapor_spring_benchmark;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import com.google.common.collect.ImmutableMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
@tanner0101
tanner0101 / HomeModule.cs
Created June 13, 2016 14:35
Nancy Benchmark
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Dapper;
using Microsoft.Data.Sqlite;
using Nancy;
namespace NancyVsVapor
{
@tanner0101
tanner0101 / bench.go
Last active June 13, 2016 15:47
Go Benchmark
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
@tanner0101
tanner0101 / run.py
Created June 13, 2016 02:57
Flask Benchmark
import sys
import flask
import random
import sqlite3
import logging
import socket
logging.basicConfig(level=logging.WARNING, format='%(levelname)s: %(message)s')
app = flask.Flask(__name__)
@tanner0101
tanner0101 / urls.py
Created June 13, 2016 02:56
Django Benchmark
from django.conf.urls import url
from django.http import HttpResponse
from django.http import JsonResponse
from django.db import connection
def plaintext(request):
return HttpResponse('Hello, world')
def json(request):
return JsonResponse({
@tanner0101
tanner0101 / cluster.js
Created June 13, 2016 02:51
Express Benchmark
var cluster = require('cluster');
if(cluster.isMaster) {
var cpuCount = require('os').cpus().length;
for(var i = 0; i < cpuCount; i += 1) {
cluster.fork();
}
cluster.on('exit', function(worker) {