Skip to content

Instantly share code, notes, and snippets.

View patchthecode's full-sized avatar
Waste not.

PatchTheCode patchthecode

Waste not.
View GitHub Profile
@patchthecode
patchthecode / SSE.swift
Created May 4, 2022 13:58 — forked from JUSTINMKAUFMAN/SSE.swift
Swift SSE EventSource Server for Vapor
import Foundation
import NIO
import Vapor
/**
SSE EventSource server implementation for Swift Vapor 3
Usage:
```
// Create a route for all incoming SSE connection
@patchthecode
patchthecode / reset_idea_trial.sh
Created June 29, 2021 22:50 — forked from gulrich1/reset_idea_trial.sh
reset intellij trial
#!/bin/sh
#https://github.com/PythonicNinja/jetbrains-reset-trial-mac-osx/blob/master/runme.sh
for product in IntelliJIdea WebStorm DataGrip PhpStorm CLion PyCharm GoLand RubyMine Rider; do
echo "Closing $product"
ps aux | grep -i MacOs/$product | cut -d " " -f 5 | xargs kill -9
echo "Resetting trial period for $product"
@patchthecode
patchthecode / Hash Ladders for Shorter Lamport Signatures.md
Created June 11, 2021 03:37 — forked from karlgluck/Hash Ladders for Shorter Lamport Signatures.md
I describe a method for making Lamport signatures take up less space. I haven't seen anyone use hash chains this way before, so I think it's pretty cool.

What's this all about?

Digital cryptography! This is a subject I've been interested in since taking a class with Prof. Fred Schneider back in college. Articles pop up on Hacker News fairly often that pique my interest and this technique is the result of one of them.

Specifically, this is about Lamport signatures. There are many signature algorithms (ECDSA and RSA are the most commonly used) but Lamport signatures are unique because they are formed using a hash function. Many cryptographers believe that this makes them resistant to attacks made possible by quantum computers.

How does a Lamport Signature work?

@patchthecode
patchthecode / AuthenticationCache.swift
Created March 3, 2018 16:10 — forked from pedantix/JWTService.swift
# Snippets For how I hacked together
import Vapor
// Reference: https://github.com/vapor/auth/blob/beta/Sources/Authentication/AuthenticationCache.swift
/// Stores authenticated objects. This should be created
/// using the request container as a singleton. Authenticated
/// objects can then be stored here by middleware and fetched
/// later in route closures.
final class AuthenticationCache: Service {
/// The internal storage.
class class1 {
var view: viewSubclass1!
func printName() {
print("This is the view: \(view)")
}
}
class class2 {
var view: viewSubclass2!
func printName() {