Skip to content

Instantly share code, notes, and snippets.

View sbrl's full-sized avatar

Starbeamrainbowlabs sbrl

View GitHub Profile
@sbrl
sbrl / AutoUpdateExampleHelper.cs
Last active January 8, 2024 10:41
A simple automatic update system, written in C# for a blog post.
using System;
using System.Net;
using System.IO;
using System.IO.Compression;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Text;
using System.Security.Cryptography;
using System.Security.Permissions;
@sbrl
sbrl / NightInk.php
Last active May 22, 2023 20:06
[NightInk/PHP] A teeny-tiny templating engine. This implementation is in PHP.
<?php
namespace SBRL;
/**
* A teeny-tiny templating engine.
* @author Starbeamrainbowlabs
* @version v0.4
* @lastModified 19th December 2020
* @license https://www.mozilla.org/en-US/MPL/2.0/ Mozilla Public License 2.0
@sbrl
sbrl / init.js
Last active August 29, 2022 12:32
Atom Settings Backup by https://atom.io/packages/sync-settings
/*
* Your init script
*
* Atom will evaluate this file each time a new window is opened. It is run
* after packages are loaded/activated and after the previous editor state
* has been restored.
*
* An example hack to log to the console when each text editor is saved.
*
* atom.workspace.observeTextEditors (editor) ->
@sbrl
sbrl / ParseCSV.mjs
Last active January 28, 2022 05:11
Quick CSV Parser that converts CSV files into an array of JS Objects.
"use strict";
/**
* Parses the source CSV into an array of objects.
* @param {string} source The source CSV to parse.
* @param {Boolean} [parse_numbers=true] Whether number-like values should be parsed with parseFloat()
* @returns {[object]} An array of objects. The keys are taken from the csv header.
*/
export default function ParseCSV(source, parse_numbers = true) {
@sbrl
sbrl / glove.py
Last active December 7, 2021 15:20
GloVe word embedding handling code for Python - improved fork of https://gist.github.com/ppope/0ff9fa359fb850ecf74d061f3072633a
import time
import io
import sys
from loguru import logger
import numpy
import tensorflow as tf
from ..polyfills.string import removeprefix, removesuffix
from .normalise_text import normalise as normalise_text
@sbrl
sbrl / main.js
Created May 26, 2020 19:35
Multi-process line-by-line reading from a single pipe in Node.js
"use strict";
import EventEmitter from 'events';
import child_process from 'child_process';
/**
* Helper method that waits for an event to be fired on a given object.
* @param {EventEmitter} obj The object that will fire the event - must inherit from EventEmitter
* @param {string} event_name The name of the event to wait for.
* @return {Promise} A promise that resolves when the specified event is fired on the given object.
@sbrl
sbrl / getch.py
Created June 25, 2015 13:32
A maze game written in Python
class _Getch:
"""Gets a single character from standard input. Does not echo to the
screen."""
def __init__(self):
try:
self.impl = _GetchWindows()
except ImportError:
self.impl = _GetchUnix()
def __call__(self): return self.impl()
@sbrl
sbrl / peppermint
Last active April 23, 2021 00:42
A Simple CLI for Pepperminty Wiki. In development to test Pepperminty Wiki's machine friendlyness :D #cli
#!/usr/bin/env bash
##########################
### Colour Definitions ###
#### ANSI color codes ####
RS="\033[0m" # reset
HC="\033[1m" # hicolor
UL="\033[4m" # underline
INV="\033[7m" # inverse background and foreground
FBLK="\033[30m" # foreground black
@sbrl
sbrl / Ansi.mjs
Last active April 18, 2021 03:20
[Ansi.mjs] VT100 ANSI escape sequence generator in JS. Ported from the C# version.
"use strict";
/**
* Generates various VT100 ANSI escape sequences.
* Ported from C#.
* @licence MPL-2.0 <https://www.mozilla.org/en-US/MPL/2.0/>
* @source https://gist.github.com/a4edd3204a03f4eedb79785751efb0f3#file-ansi-cs
* @author Starbeamrainbowlabs
* GitHub: @sbrl | Twitter: @SBRLabs | Reddit: u/Starbeamrainbowlabs
***** Changelog *****
@sbrl
sbrl / Bezier.js
Last active March 7, 2021 18:49
[Bezier.js] A bezier curve class that takes an arbitrary number of control points. Originally written for my university coursework. #es6 #module #microlibrary
"use strict";
/******************************************************************************
*************************** ES6 Bezier Curve Class ***************************
******************************************************************************
* v0.4
******************************************************************************
* A bezier curve class that supports an arbitrary number of control points.
* Originally written for my 2D Graphics coursework at University.
*
* Bug reports can be made as a comment on this gist, or