Skip to content

Instantly share code, notes, and snippets.

@FlameWolf
FlameWolf / Git-Reset-Hard.sh
Created April 16, 2024 04:37
Revert to a previous commit discarding all changes made afterwards
git reset --hard [Commit-SHA-Id]
git push origin [Branch-Name] --force
@FlameWolf
FlameWolf / generateMalluNames.js
Last active March 14, 2024 08:10
Mallu name generator
function generateMalluNames(randomise = false) {
const alphabet = new Array(26);
const vowels = ["a", "e", "i", "o", "u"];
const softConsonants = ["b", "c", "d", "g", "j", "k", "p", "r", "s", "t", "z"];
for (let i = 0; i < 26; i++) {
alphabet[i] = String.fromCharCode(i + 97);
if (i === 16) {
alphabet[i] += "u";
}
}
const getRandomIdString = (steps = 1) => {
let seed = "";
for (let i = 0; i < steps; i++) {
seed += crypto.randomUUID();
}
return seed.replaceAll("-", "");
};
@FlameWolf
FlameWolf / shortcomings-of-communism.md
Created February 26, 2024 14:24
The Theoretical and Practical Issues with Communism

Let's take a look at the various shortcomings of Communism, the cause of which can be attributed to its conflict with fundamental aspects of human psychology:

1. The Denial of Individuality and Self-Interest

  • Loss of Motivation: Communism's emphasis on collectivism and the common good runs counter to inherent human desires for self-determination and the pursuit of individual goals. Without the potential for personal gain or the ability to better one's own situation, the drive to excel, innovate, and work hard diminishes.
  • Forced Equality and the Tragedy of the Commons: The mandated egalitarianism ignores individual differences in skills, ambition, and work ethic. This erodes personal responsibility. People may ask, “Why should I work harder if my rewards remain the same?” This phenomenon, known as the Tragedy of the Commons, often leads to the depletion of shared resources and a decrease in overall productivity.
  • Stifling Creativity and Entrepreneurship: The lack of economic freedom
@FlameWolf
FlameWolf / signing-git-commits.md
Last active February 3, 2024 07:00
How to sign Git commits

How to sign Git commits

  1. Install GPG4Win and Git for Windows.
  2. Set up Git to use GPG4Win.
    git config --global gpg.program "<path to gpg.exe>"
  3. Generate key.
    gpg --full-generate-key
    
@FlameWolf
FlameWolf / merge-sort.js
Created January 19, 2024 14:11
MergeSort implementation in JavaScript
function mergeSort(input) {
const merge = (left, right) => {
const merged = [];
while (left.length && right.length) {
if (left[0] < right[0]) {
merged.push(left.shift());
} else {
merged.push(right.shift());
}
}
@FlameWolf
FlameWolf / snail.js
Created January 12, 2024 11:28
Snail Algorithm (CodeWars Challenge)
/*
input:
[
[01, 02, 03, 04, 05, 06],
[07, 08, 09, 10, 11, 12],
[13, 14, 15, 16, 17, 18],
[19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30],
[31, 32, 33, 34, 35, 36]
];
@FlameWolf
FlameWolf / getContent.js
Last active May 4, 2024 09:42
Get content from KKS
copy((function() {
const contentParagraphs = [
...document.querySelectorAll("#main > #content > article > .entry-content > p"),
...document.querySelectorAll("div.entry-content > div:not(#widgets-wrap-before-post-content)")
];
return contentParagraphs
.filter(x => x.getAttribute("role") !== "navigation")
.reduce((acc, value) => acc + "\n" + value.textContent, "");
})());
@FlameWolf
FlameWolf / ratios.js
Last active November 29, 2023 11:51
Get the ratios of consecutive elements from an array
[1, 2, 3, 4, 5].reduce((accumulator, current, index, { [index + 1]: next }) => next ? accumulator.concat(current / next) : accumulator, []); // [ 0.5, 0.6666666666666666, 0.75, 0.8 ]
@FlameWolf
FlameWolf / fibonacci.js
Created November 3, 2023 06:38
JavaScript generator function to get Fibonacci numbers
function* fibonacci(max = Number.MAX_SAFE_INTEGER) {
let current = 1;
let previous = 0;
while (current <= max) {
[current, previous] = [previous, current + previous];
if (current <= max) {
yield current;
} else {
return;
}