Skip to content

Instantly share code, notes, and snippets.

Avatar

Starbeamrainbowlabs sbrl

View GitHub Profile
View init.js
/*
* 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 / AutoUpdateExampleHelper.cs
Last active Jun 30, 2022
A simple automatic update system, written in C# for a blog post.
View AutoUpdateExampleHelper.cs
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 / ParseCSV.mjs
Last active Jan 28, 2022
Quick CSV Parser that converts CSV files into an array of JS Objects.
View ParseCSV.mjs
"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 Dec 7, 2021
GloVe word embedding handling code for Python - improved fork of https://gist.github.com/ppope/0ff9fa359fb850ecf74d061f3072633a
View glove.py
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
Multi-process line-by-line reading from a single pipe in Node.js
View main.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 Jun 25, 2015
A maze game written in Python
View getch.py
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 Apr 23, 2021
A Simple CLI for Pepperminty Wiki. In development to test Pepperminty Wiki's machine friendlyness :D #cli
View peppermint
#!/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 Apr 18, 2021
[Ansi.mjs] VT100 ANSI escape sequence generator in JS. Ported from the C# version.
View Ansi.mjs
"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 Mar 7, 2021
[Bezier.js] A bezier curve class that takes an arbitrary number of control points. Originally written for my university coursework. #es6 #module #microlibrary
View Bezier.js
"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
@sbrl
sbrl / NightInk.php
Last active Dec 19, 2020
[NightInk/PHP] A teeny-tiny templating engine. This implementation is in PHP.
View NightInk.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