Skip to content

Instantly share code, notes, and snippets.

View dscottboggs's full-sized avatar
✌️

Scott Boggs dscottboggs

✌️
View GitHub Profile
@dscottboggs
dscottboggs / kemal-example.cr
Created June 20, 2019 23:35
Kemal won't work with these routes
require "kemal"
require "spec-kemal"
# From here until the note denoting the end of this section is just an error-
# handling solution. It is only here to better demonstrate/replicate the issue.
# ERROR HANDLING SECTION
# Base error handler exception type.
abstract class HTTPStatusError < Exception
abstract def status_code
@dscottboggs
dscottboggs / brainfuck.c
Created April 18, 2019 20:47
C brainfuck interpreter
// brainfuck interpreter
//
// based on the example distributed with the crystal source code
#include <mine.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef INITIAL_SIZE
#define INITIAL_SIZE 5
#endif
@dscottboggs
dscottboggs / pkg-versions.txt
Created December 30, 2018 05:48
manjaro package versions
warning: lib32-systemd: local (239.303-1) is newer than multilib (239.6-2)
warning: libsystemd: local (239.303-1) is newer than core (239.6-2)
warning: systemd: local (239.303-1) is newer than core (239.6-2)
warning: systemd-sysvcompat: local (239.303-1) is newer than core (239.6-2)
from inspect import getsource
from timeit import timeit
from textwrap import dedent
# Generate a dict of all the valid printable two-character ASCII combinations
test_object = { }
DEFAULT_COUNT = 100_000
VALID_ASCII = range(0x20, 0x7F)
for character in VALID_ASCII:
for second in VALID_ASCII:
require "benchmark/ips"
def square_root_of(number)
# Computes the square root of x, using the Newton–Raphson method
approximation = 0
guess = number.to_f / 2
until approximation == guess
approximation = guess
guess = (approximation + number / approximation) / 2
end
@dscottboggs
dscottboggs / middleware.go
Created August 19, 2018 08:38
A usage example for the concept of a middleware handler
package middleware
import (
"net/http"
"github.com/dscottboggs/middleware-basic-auth"
"github.com/dscottboggs/middleware-logging"
)
/* Middleware is a shim between the http server and the handler functions. Each