Skip to content

Instantly share code, notes, and snippets.

View regexident's full-sized avatar

Vincent Esche regexident

View GitHub Profile
@regexident
regexident / fizz_buzz.cpp
Last active January 11, 2024 10:57
FizzBuzz in C++ Template Meta-Programming
// Created by Vincent Esche on 2/10/15.
// Copyright (c) 2015 Vincent Esche. All rights reserved.
#include <iostream>
#include <cxxabi.h>
struct fizz;
struct buzz;
struct fizz_buzz;
@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 / README-Template.md
Last active January 23, 2023 22:17 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Motivation

@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 / 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 / AnyDiffable.swift
Created March 17, 2017 10:26 — forked from ollieatkinson/AnyDiffable.swift
Implementation of Paul Heckel's Diff Algorithm in Swift 3
public protocol Diffable: Hashable {
var primaryKeyValue: String { get }
}
public struct AnyDiffable: Diffable {
private let _primaryKeyValue: () -> String
@regexident
regexident / tomono.sh
Created June 12, 2017 10:35 — forked from eisisig/tomono.sh
convert multiple repos to monorepo
#!/bin/bash
# Merge multiple repositories into one big monorepo. Migrates every branch in
# every subrepo to the eponymous branch in the monorepo, with all files
# (including in the history) rewritten to live under a subdirectory.
#
# To use a separate temporary directory while migrating, set the GIT_TMPDIR
# envvar.
#
# To access the individual functions instead of executing main, source this
@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.