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 / 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==
@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 / profile
Last active October 1, 2020 18:41
Terminal coloring with git branch if one is found
print_git_data() {
if [ $(parse_git_branch) ]; then
printf ' ('
printf $(parse_git_branch)
printf ' '
printf $(parse_latest_commit_hash)
printf ')'
fi
}
@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 / 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 / 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 / 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 / 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 / faketypes.cs
Last active April 23, 2023 14:11
UInt128 and UInt256 data types in c# to compare string hashes with one and another.
using System;
using System.Globalization;
using System.Text.RegularExpressions;
namespace FakeTypes
{
// All types within this namespace are considered fakes. A UInt128 is a struct
// containing two ulongs, their primary reason for existence is for quick calculation
// and comparisons of hash strings as numbers. Allocation should be on the stack.
@aal89
aal89 / pba.cs
Created July 30, 2019 22:35
Print byte array in c#
public void PrintByteArray(byte[] bytes)
{
var sb = new StringBuilder("new byte[] { ");
foreach (var b in bytes)
{
sb.Append(b + ", ");
}
sb.Append("}");
Console.WriteLine(sb.ToString());
}