Skip to content

Instantly share code, notes, and snippets.

View KCreate's full-sized avatar
🍰
the cake is a lie

Leonard Schütz KCreate

🍰
the cake is a lie
View GitHub Profile
@KCreate
KCreate / interpreter.ch
Created December 26, 2016 02:29
Simple calculator written in charly.
class Lexer {
property tokens
property source
property pos
property buffer
func constructor() {
@tokens = []
@token = null
@source = ""
@KCreate
KCreate / brainfuck.html
Created May 18, 2017 09:20
Brainfuck interpreter written in Javascript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
body * {
margin: 10px;
padding: 0;
display: block;
@KCreate
KCreate / EasyQuery.php
Created February 26, 2016 08:59
EasyQuery
// Easier sql queries
class EasyQuery {
private $dbname;
private $db;
public function __construct($dbname) {
$this->dbname = $dbname;
// Check if the db file exists
if (!file_exists($this->dbname)) {
@KCreate
KCreate / data-to-human-readable.js
Created May 17, 2018 13:48
Convert an amount of bytes to a human readable file size.
const bytesInKilobyte = 1000
const bytesInMegabyte = 1000000
const bytesInGigabyte = 1000000000
const bytesInTerabyte = 1000000000000
function toHumanReadable(bytes) {
if (bytes >= bytesInTerabyte) return Math.round(bytes / bytesInTerabyte * 100) / 100 + " tb";
if (bytes >= bytesInGigabyte) return Math.round(bytes / bytesInGigabyte * 100) / 100 + " gb";
if (bytes >= bytesInMegabyte) return Math.round(bytes / bytesInMegabyte * 100) / 100 + " mb";
if (bytes >= bytesInKilobyte) return Math.round(bytes / bytesInKilobyte * 100) / 100 + " kb";
@KCreate
KCreate / ir.js
Created December 20, 2018 15:16
IR Language Experiments
// Source code:
//
// int a = 25
// int b = 20
// int c = 0;
//
// if (a + b > 40) {
// c = 1;
// } else {
// c = 0;