This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See more at [https://github.com/matchai/waka-box](https://github.com/matchai/waka-box) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.math.BigDecimal; | |
import java.math.RoundingMode; | |
public class ByteStringer { | |
private static final String[] BYTES_UNITS = new String[] {"B", "KB", "MB", "GB", "TB"}; | |
public static double round(double value, int places) { | |
if (places < 0) throw new IllegalArgumentException(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simply remove the element | |
* @author TheRolf | |
*/ | |
Element.prototype.remove = function() { | |
this.parentElement.removeChild(this) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes all elements from a NodeList. | |
* This NodeList is generally a document element query result. | |
* @author TheRolf | |
*/ | |
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() { | |
for(var i = this.length - 1; i >= 0; i--) { | |
if(this[i] && this[i].parentElement) { | |
this[i].parentElement.removeChild(this[i]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Resolves promise after certain period of time in ms | |
* @author TheRolf | |
* @param {Number} timeout delay in ms | |
*/ | |
const TimeoutPromise = function(timeout) { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(); | |
}, timeout); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MinecraftVersionSorter.js 1.0 by TheRolf | |
// to use it, just just need to pass it as arg of the sort function for an array | |
// ["1.4.9","1.7","1.7.10","1.12.2","1.17.1","1.16.210","1.18"].sort(MinecraftSorter) | |
const MinecraftVersionSorter = (a, b) => { | |
const aSplit = a.split('.').map(s => parseInt(s)) | |
const bSplit = b.split('.').map(s => parseInt(s)) | |
if(aSplit.includes(NaN) || bSplit.includes(NaN)) { | |
return String(a).localeCompare(String(b)) // compare as strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates html from string and appends it to current element | |
* @author TheRolf | |
* @param {String} str html string to append | |
*/ | |
Element.prototype.appendHTML = function(str) { | |
var div = document.createElement('div') | |
div.innerHTML = str | |
while (div.children.length > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
romlist = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"] | |
numlist = [1000,900,500,400,100,90,50,40,10,9,5,4,1] | |
number = int(input("Enter integer > 0: ")) | |
rn = [] | |
numlist_index = 0 | |
# a number should | |
while number > 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from rich.console import Console | |
from rich.panel import Panel | |
console = Console() | |
pathway = "wordlepy.txt" | |
def unused(letter): | |
return "[white on #2c3032]" + letter + "[/]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gives char codes of the string | |
* @author TheRolf | |
*/ | |
String.prototype.codes = function() { | |
return this.split('').map(c => { | |
let code = c.charCodeAt(0); | |
return code; | |
}).flat() | |
} |
OlderNewer