Skip to content

Instantly share code, notes, and snippets.

View aal89's full-sized avatar
🎯
Focusing

Alex Burghardt aal89

🎯
Focusing
View GitHub Profile
@aal89
aal89 / 1mb.txt
Created July 18, 2019 08:51
1mb in text
This file has been truncated, but you can view the full file.
19063699041183922230424640119986913758023341770758751642047601347737139606611941581352175797681575117149435847472379921576378
82010873314125910417098681679467651061196703036344503828425038021866296075656578591024747456403918197240660392231867709196530
05547299081771122978128893134012025555840439838755861696435926779779011155301553716406948852775421829267789075611169229413304
42028620073205237675530442721666962286683534927131293735270935475331266785352417198234822645786435208887529004886675157771888
87716254578233139050956841337551473116293899780647416270305365091493516756140179109318676578254373967658333126619554398248807
73901335039931398874577719039802288956276828455645089612214856059038950787855805249688802161731552101060793394882144824301838
80013352318345613661078428780673839967965501913764666716551387847921893809223464453567368379243079836222406059944397498046708
72409291568897359376555992566277167049359808026761803186968491038946326201866824309514704973489863815255632689038911077381036
1679702913915218
@aal89
aal89 / kbtxtgenerator.js
Created July 18, 2019 08:52
Generates text files with random numbers of a particular size. Size is given in kb's as first parameter, defaults to 100.
const fs = require("fs");
const lineLength = 126;
const sizeInKb = process.argv[2] || 100;
let data = "";
for(var i = 0; i < sizeInKb * 1024; i++) {
if (i && i % lineLength === 0) {
data += "\n";
} else {
@aal89
aal89 / 420.swift
Last active July 23, 2019 11:32
A pure functional way to blaze some sick clouds in Swift.
// Higher order functions, being curried. Considered pure functional, because they don't have any side effects
// (mutate any given data). They just derive data from data.
let plus = { (first: Int) in { (second: Int) in first + second } }
let multiplesOf = { (first: Int) in { (second: Int) in second % first != 0 } }
// Just a simple first class function, not per se functional. Usable to reduce a collection of integers into the total.
let total: (Int, Int) -> Int = { $0 + $1 }
let calculation = (1...30)
.map(plus(2))
@aal89
aal89 / currying.swift
Last active September 26, 2019 09:13
Examples whereby we curry an arithmetic operator over a collection of natural numbers and curry a greetings functions over a collection of strings, in Swift.
// ========================== Generic (limited) curry function:
func curry<A, B, C>(_ f: @escaping (A, B) -> C) -> (A) -> (B) -> C {
return { a in { b in f(a, b) }}
}
// ========================== Example 1:
let add = curry((+) as ((Int, Int) -> Int))
let add2 = add(2)
@aal89
aal89 / hello.c
Created November 20, 2019 21:37
CC65 hello world demo for NES with a fix (wa) for the open gap on the bottom line (taken from https://github.com/cc65/cc65/blob/master/samples/hello.c)
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <joystick.h>
#include <nes.h>
static const char text[] = "get on that nesdev";
int main(void)
{
@aal89
aal89 / mandelbrot.c
Created November 20, 2019 21:42
CC65 mandelbrot demo for NES that compiles (taken from https://github.com/cc65/cc65/blob/master/samples/mandelbrot.c)
/*****************************************************************************\
** mandelbrot sample program for cc65. **
** **
** (w) 2002 by groepaz/hitmen, TGI support by Stefan Haubenthal **
\*****************************************************************************/
#include <stdlib.h>
#include <time.h>
@aal89
aal89 / tgidemo.c
Last active November 20, 2019 21:51
CC65 TGI NES demo that compiles (taken from https://github.com/cc65/cc65/blob/master/samples/tgidemo.c).
#include <stdio.h>
#include <stdlib.h>
#include <cc65.h>
#include <conio.h>
#include <tgi.h>
#include <nes.h>
#include <joystick.h>
#define TGI_COLOR_BLACK 0x00
#define TGI_COLOR_GREEN 0x01
@aal89
aal89 / .bash_profile
Last active December 17, 2019 16:34
Profile alias to quickly execute Python scripts from anywhere on some random path with regard to sys.argv, for *nix systems. Alias gp stands for globalpython.
alias gp='function __gp() { (python3 ~/Documents/python/$1.py $(shift;printf "$*") 2>/dev/null) || echo "File not found or errors occurred."; unset -f __gp; }; __gp'
# (assumption hiworld.py is an actual file)
#
# usage: gp hiworld
# usage: gp sub/dir/hiworld arg0 arg1
#
@aal89
aal89 / boot.ts
Last active January 29, 2020 09:54
Bootstrapper (chassis pattern) with a restarting capabilities for TypeScript/Javascript using 'top-level' async/await.
// random bootstrapper for any theoretical ts/js application
const timeout = (millis: number, fn: () => void) => new Promise(c => setTimeout(c, millis)).then(fn);
(async function boot() {
// this try-catch is an additional safety net used for (poorly) written applications in which errors
// are not properly caught
try {
// some random loading of initial components
@aal89
aal89 / bitbucket-pr-totals.js
Last active June 30, 2020 12:10
Show total changed lines of code for all files combined in a PR (new view) on Bitbucket. This is a TamperMonkey script.
// ==UserScript==
// @name Bitbucket totals in PR
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Show total changed lines of code
// @author You
// @match https://bitbucket.org/*/*/pull-requests/*
// @grant none
// ==/UserScript==