Skip to content

Instantly share code, notes, and snippets.

@saiki-k
saiki-k / humbleKeysExtractor.js
Last active January 28, 2024 07:07
Humble Keys' Extractor
const excludedTitles = ['A title I already own', 'Got this other title too'];
const { includedKeysCombined, csv } = run(excludedTitles);
copy(includedKeysCombined);
function scrapeTitlesAndKeys() {
const result = [];
// Get all elements with classes "key-redeemer" (Normal key pages), and "multiselect-nonimage-content" (Choice key pages)
@saiki-k
saiki-k / octave.js
Last active July 24, 2020 12:42
Functions to calculate the frequency of a musical note, octave range between two musical notes / musical note frequencies
const getNoteDistanceFromC0 = note => {
// Notes in an octave
const noteNumberMap = { "C": 1, "C#": 2, "D♭": 2, "D": 3, "D#": 4, "E♭": 4, "E": 5, "F": 6, "F#": 7, "G♭": 7, "G": 8, "G#": 9, "A♭": 9, "A": 10, "A#": 11, "B♭": 11, "B": 12 };
const getOctaveNum = note => note.charAt(note.length - 1);
return noteNumberMap[note.slice(0, -1)] - 1 + (getOctaveNum(note) * 12);
};
const getOctaveRange = (note1, note2) =>
(getNoteDistanceFromC0(note2) - getNoteDistanceFromC0(note1)) / 12;
@saiki-k
saiki-k / windows--x86--node-gyp.md
Last active February 5, 2020 14:34
Configuring Windows (32-bit) for node-gyp
  • Install the 32-bit version of Node
  • Install Python 2.7
  • Install Microsoft Visual Studio 2015 Community
  • Install Windows 8.1 SDK
  • Open the command prompt as Administrator, run the following commands, then close the command prompt (a new prompt is required before the new environment variables will be available)
    • setx PYTHON C:\Python27\python.exe /m
      • (May need to change path to your custom install directory.)
  • Open a new command prompt and run the following command; if it runs without any errors the configuration for node-gyp builds is succesful.
  • npm install -g node-gyp

Keybase proof

I hereby claim:

  • I am fatman- on github.
  • I am saiki (https://keybase.io/saiki) on keybase.
  • I have a public key ASB2nV_1TkWE8eM4Gh63zaRpjDzzl6T7ocNGi6iBOR70Qwo

To claim this, I am signing this object:

@saiki-k
saiki-k / saintPatrickInTheConsole.js
Last active March 18, 2017 09:13
Happy St. Patrick's Day!
(() => {
const clover = () => {
const emoji = ['☘️', '🍀'];
const pick = Math.floor(Math.random() * 2);
const depth = Math.floor(Math.random() * 100);
const tag = document.createElement('div');
tag.innerHTML = emoji[pick];
tag.style.zIndex = depth;
tag.style.opacity = depth / 100;
tag.style.fontSize = `${depth}pt`;
@saiki-k
saiki-k / udemyCourseTimeCalculator.js
Created March 14, 2017 11:08
A script meant to run from a browser's console, on a Udemy course page; to calculate the total time of the course.
(() => {
let totalMinutes = 0;
let totalSeconds = 0;
Array
.from(document.querySelectorAll('.lecture__item__link__time'))
.map(item => item.innerHTML)
.forEach(itemTime => {
totalMinutes += parseInt(itemTime.split(':')[0]);
totalSeconds += parseInt(itemTime.split(':')[1]);
});