Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Alex Burghardt aal89

🎯
Focusing
View GitHub Profile
@aal89
aal89 / profile
Last active Oct 1, 2020
Terminal coloring with git branch if one is found
View profile
print_git_data() {
if [ $(parse_git_branch) ]; then
printf ' ('
printf $(parse_git_branch)
printf ' '
printf $(parse_latest_commit_hash)
printf ')'
fi
}
@aal89
aal89 / bitbucket-pr-totals.js
Last active Jun 30, 2020
Show total changed lines of code for all files combined in a PR (new view) on Bitbucket. This is a TamperMonkey script.
View bitbucket-pr-totals.js
// ==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 Jan 29, 2020
Bootstrapper (chassis pattern) with a restarting capabilities for TypeScript/Javascript using 'top-level' async/await.
View boot.ts
// 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 / .bash_profile
Last active Dec 17, 2019
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.
View .bash_profile
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 / tgidemo.c
Last active Nov 20, 2019
CC65 TGI NES demo that compiles (taken from https://github.com/cc65/cc65/blob/master/samples/tgidemo.c).
View 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 / mandelbrot.c
Created Nov 20, 2019
CC65 mandelbrot demo for NES that compiles (taken from https://github.com/cc65/cc65/blob/master/samples/mandelbrot.c)
View 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 Nov 20, 2019
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)
View 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 / currying.swift
Last active Sep 26, 2019
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.
View currying.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 Sep 20, 2019
UInt128 and UInt256 data types in c# to compare string hashes with one and another.
View faketypes.cs
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 Jul 30, 2019
Print byte array in c#
View pba.cs
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());
}
You can’t perform that action at this time.