This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |