Skip to content

Instantly share code, notes, and snippets.

View regexident's full-sized avatar

Vincent Esche regexident

View GitHub Profile
@regexident
regexident / gist:c79f61e6b0187eecccf5
Last active August 29, 2015 14:21
Obfuscated fizzbuzz
#include <iostream>
template <int N>
struct n { static const int v = N; };
template <typename...Ts>
struct l { };
template <typename T, typename TL> struct c;
@regexident
regexident / gist:61383dbf706a2b42a44c
Last active August 29, 2015 14:21
Underhanded Fizzbuzz
#include <stdio.h>
#include <stdint.h>
#include <math.h>
uint8_t a(double x) {
return -(31.0 / 6.0 * pow(x, 3)) + (38.0 * pow(x, 2)) - (449.0 / 6.0 * x) + 144.0;
}
uint8_t b(double x) {
return (3.0 / 2.0 * pow(x, 3)) - (16.0 * pow(x, 2)) + (113.0 / 2.0 * x) + 56.0;
@regexident
regexident / easing.js
Created October 6, 2016 10:36 — forked from AndrewRayCode/easing.js
ES6 module-ified easing functions, based on https://gist.github.com/gre/1650294
// based on https://gist.github.com/gre/1650294
// no easing, no acceleration
export function linear( t ) {
return t;
}
// accelerating from zero velocity
export function easeInQuad( t ) {
return t * t;
@regexident
regexident / String+Hyphenation.swift
Created September 27, 2017 09:12 — forked from frankrausch/String+Hyphenation.swift
Returns a String with soft hyphens (U+00AD)
import Foundation
extension String {
func hyphenated(languageCode: String) -> String {
let locale = Locale(identifier: languageCode)
return self.hyphenated(locale: locale)
}
func hyphenated(locale: Locale) -> String {
@regexident
regexident / swift-responder-chain.swift
Created October 5, 2017 08:31 — forked from anandabits/swift-responder-chain.swift
A minimalist responder chain implemented in pure Swift
// Created by Matthew Johnson on 5/28/16.
// Copyright © 2016 Anandabits LLC. All rights reserved.
//
// This is a minimalist implementation of a responder chain in pure Swift.
//
// It is not intended to demonstrate the best way to
// implement event processing in Swift.
//
// The intent is to show how little code is necessary to acheive behavior
// similar to Cocoa's responder chain in pure Swift.
@regexident
regexident / 0000-HashVisitable.md
Last active October 12, 2017 09:00
Swift Evolution Proposal Draft for replacing `Hashable` with `Hasher` and `HashVisitable`.

HashVisitable

During the review process, add the following fields as needed:

Introduction

@regexident
regexident / swift-format.swift
Created October 27, 2017 11:06 — forked from harlanhaskins/swift-format.swift
Simple Swift Formatter using SwiftSyntax
import Foundation
import SwiftSyntax
func main() throws {
guard CommandLine.arguments.count > 1 else {
print("usage: swift-format [file]")
exit(-1)
}
let url = URL(fileURLWithPath: CommandLine.arguments[1])
@regexident
regexident / analytic_wfm.py
Created January 12, 2018 01:13 — forked from sixtenbe/analytic_wfm.py
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@regexident
regexident / inherit.rs
Created January 17, 2018 11:38 — forked from kyleheadley/inherit.rs
A model for trait-based inheritance in Rust
//! Demo of static "inheritance"
//!
//! Use trait objects to get dynamic inheritance,
//! but casting to a subtype is not explored here
////////////////////////////////////////////////////////
// Define Base type, interface, and what is overloadable
////////////////////////////////////////////////////////
/// The main type that will be extended
@regexident
regexident / Perceptron.swift
Created May 31, 2018 14:38
Perceptron Algorithm
//: Playground - noun: a place where people can play
import Cocoa
struct Vector {
let x: Float
let y: Float
let z: Float
static func *(lhs: Vector, rhs: Float) -> Vector {