Skip to content

Instantly share code, notes, and snippets.

View resynth1943's full-sized avatar

resynth1943

View GitHub Profile
@resynth1943
resynth1943 / console-mark.js
Created April 26, 2019 03:36
console-mark
// Let's not make this a compatability bottleneck.
// https://babeljs.io/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=MYewdgziA2CmB00QHMAUADAUICNJd8OqkABHifiQbkYcdmZdTXebfY2-Ua5c0TtoCqkgBVJB3AcOGBdUlxDxEwFqk9aVILVcgRVI5w6ZPWrsavAbEiW-vRvEn8fEv2UqaHQgrx2a_RWfMNm-lxuYjcjVHJT4ZURkJak1xXWclcxc6EO89CLNdWJMLOLNsyj5U9V8mElSaCqzyny9K711yNwZK5jtMTWjnQXlLSWzZBk6hnpjBsa7uruGZy0mR3rnCTHQASgBuIA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.4.3&externalPlugins=
console.log('This project is maintained by: ');
console.log("%c\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557
@resynth1943
resynth1943 / test-creator.js
Created May 9, 2019 16:53
This code generates files that test if a value has the correct "typeof" value.
const fs = require('fs');
const assert = require('assert');
const typeofResults = ['number', 'bigint', 'boolean', 'symbol', 'string', 'object'];
typeofResults.forEach(result => {
fs.writeFileSync(`./is-${result}.js`, `module.exports = function (x) {
return typeof x === '${result}';
}`);
});
@resynth1943
resynth1943 / opaque-types.ts
Created July 19, 2019 10:37
TypeScript - Opaque Types
type Opaque<V> = V & { readonly __opq__: unique symbol };
type AccountNumber = Opaque<number>;
type AccountBalance = Opaque<number>;
function createAccountNumber (): AccountNumber {
return 2 as AccountNumber;
}
function getMoneyForAccount (accountNumber: AccountNumber): AccountBalance {
@resynth1943
resynth1943 / example.ts
Created July 23, 2019 17:28
Discord - Ratelimiting made easy
import { Bucket } from './ratelimiting';
import { User } from 'discord.js';
// Create your ratelimit bucket here. This is where we'll be storing everyone who uses a command.
const ratelimitBucket = new Bucket<User>(/* enter your timeout here in milliseconds. */ 5000);
// This obviously won't work, but you need to enter this code (or your variant) into your command handler.
onCommand((message: Message) => {
// Enter the member into the bucket, so we can keep track of them. If the user is already in the bucket, this does nothing.
this.enterMember(message.author);
@resynth1943
resynth1943 / dom_logged.js
Created July 24, 2019 22:39
A tiny logger that outputs logs to an element as <code> elements.
let logBuffer = [];
let appendText = (text) => {
logBuffer.push(text);
}
window.addEventListener('DOMContentLoaded', () => {
const logBox = document.getElementById('logbox');
appendText = (text) => {
@resynth1943
resynth1943 / text.txt
Last active July 25, 2019 00:29
Stub text. My lorem ipsum.
This is a blockquote, and this is also the hook. Keep reading. Please, keep reading. You'll need this one day. What is life? Where we do fit in? The answer is simple, we don't. Anarchy. Every man or woman for themselves. According to the Americans, love is priceless, and we should search for it. We know better. This, really is, the hook. Everything in a flash. Your whole life. Your belongings. Nothing matters anymore. The truth is truly a beautiful thing. We shouldn't follow the Americans, for obvious reasons, as they really romanticize everything, but all is not lost. Just be you. Don't try to impress anyone else. An act can't last forever, and if you are acting, neither can you. Please, be yourself. Don't try to copy anyone else, but rather observe them, and learn from their mistakes. At the end of the day, as some would put it, you should never act. Life is worth much more than that. So, in closing, be yourself. No cliches. Don't blindly follow others. You are you, and that's the best thing about you. Rega
@resynth1943
resynth1943 / suggestions.md
Last active November 15, 2019 18:31
How not to write an article.

Each exhibit has a codeblock containing git diffs. The - represents a section of text that should be removed, while + means a section of text that should be kept. Lines beginning with # represents a comment added by me.

Exhibit A - Textual Example

- In this article we take a look at how to downgrade from one edition of Windows 7 to another. For instance, if you have Windows 7 Professional, but would like to downgrade to Windows 7 Home Premium. You might ask, for what reason? Well, there are scenarios where this issue might come up. Maybe you want to reassign Windows 7 Professional to another computer, and install Windows 7 Home Premium on it instead. Maybe the edition is not being used effectively and could be more useful else where such as a laptop you carry to work since Windows 7 Professional includes a lot of business features. 
- The problem is the process of reassigning licenses, this would probably mean you will have to backup data, prepare to reinstall applications and drivers then 
@resynth1943
resynth1943 / doc.md
Last active April 10, 2021 09:18
A document about Syretia.

I'd like to bring up a difficult topic, today. Simon. For a while, he's been using an alternate account to watch me (I'm clearly a very interesting person). This has been going on for a while, and you may not realize this. Simon has been messaging me with warnings about speaking about him at two separate times, and it's quite obvious that he's using his alternate account exactly for this. I shouldn't have to remind you that this behaviour is extremely inappropriate, and I hope that you'll put a stop to it immediately. He's also been using another server to contact me (the Blargbot one), but I've left that one. I don't want to leave this one.

You're probably wondering why I don't just block the account? I have literally just a moment ago, but I really don't want anyone to experience this too. It's completely inappropriate for a moderator to be contacting me, and issuing threats like the following.

@resynth1943
resynth1943 / poem.txt
Created September 16, 2019 20:19
Git fucks you up
It fucks you up, git.
It may not mean to, but it does.
It fills you with the faults it has
And add some extra, just for you.
But it was fucked up in it's turn
By fools in old-style hats and coats,
Who half the time were soppy-stern
And half at one another’s throats.
@resynth1943
resynth1943 / Parser.ts
Last active September 22, 2019 23:56
Custom dotenv parser
import { promises, readFileSync } from 'fs';
import { DotEnvOptions } from './Types';
import { resolve } from 'path';
import Logger from 'Base/Logging';
const { readFile } = promises;
const logger = Logger.get('dotenv');
/** Bisects the line, revealing the key & value pair in an Array. */
function bisectLine(line: string) {