Skip to content

Instantly share code, notes, and snippets.

View resynth1943's full-sized avatar

resynth1943

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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