NostraDavid's Knowledge Base - Javascript code snippets and regex
For now () it's just snippets of JS and regex that I use every now and then
I'd use GitHub for that, but I have a tendency to forget GitHub Gist existsโฆ
Online Tools
These are websites/webpages that I use to optimize this site.
Tool name | What to use it for |
---|---|
SVGOMG! | "SVG Optimizer's Missing GUI", an online SVG optimizer |
Google's Closure Compiler | A Javascript optimizer - turns modern JS into highly optimized, yet compatible, Javascript. I use this to improve my JS code here and there. |
My Sitemap Generator | Since this is a fully static site I have to update the sitemap manually. I use this site to automate the generation partially. |
Boxy SVG editor | Usually I edit my SVG files by hand, but sometimes I need some basic shapes placed. |
Bing's robot.txt Tester | Use this to check your robots.txt for faults. |
Squoosh | Google Chrome Labs created this site so you can customize the compression of your image (and compare it with the original). Desktop version is also available. |
Diagrams.net (previously Draw.io) | Used for diagrams. If you save a file as PNG you can open it as PNG with an image viewer and and with the website or Desktop version |
Javascript oneliners
Small scripts that I run in the browser to manipulate a website (like remove my reddit comments from a specific subreddit, for example)
note | code |
---|---|
Open all collapsed comments on a reddit comment page |
|
Manipulating Unicode strings per code point, not per byte. "".split() gives you bytes, not codepoints |
Array.from("๐ฑ๐ข๐ฐ๐ฑ๐ฆ๐ซ๐ค ๐๐๐๐ #@$%#^$% ๐ฑ๐ข๐ฐ๐ฑ๐ฆ๐ซ๐ค ๐๐๐๐"); |
Remove all .bighead classed elements (no Array.from() needed, which is what I used before, so I could use map() instead of a for loop) |
|
Make console.log use colors |
|
This opens all are you sure? dialogs for comments, on a profile page of Reddit |
|
Removing duplicates |
|
Run a timed loop (handy for interacting with Reddit, because Reddit has a rate limit of 30 requests per minute) |
|
Remove all comments from a specific subreddit (TheLastOfUs2, in this case) |
|
Use on Twitch to track the amount of currently used emotes |
|
Regular Expressions
Use in combination with $0/$1/$2... to find and replace text.
note | regex |
---|---|
Find the nth comma, via stackoverflow; Edit the number in between {} to find the nth comma. |
,(?=(?:[^,]*,){3}[^,]*$) |
Every line that doesn't start with a . via regex; I was trying to filter bootstrap.css from all non-classes |
^((?!^\.).)*$ |
Filter everything from a : till the end of the line | [:].*$ |
Find non-ASCII letters in vscode; Great for finding unicode characters in copied code, because Haskell can't handle Unicode in your comments... |
([^\x00-\x7F]) |
hit him up when you pay for WoW | Craizler-TarrenMill |
WoW BattleTag | Cyrstad#2776 |
Find main content of HTML page | <main>\n\t+<section>((\n.*?)*)</section>(\n\t+)</main> |
find paragraph tags that aren't closed | \t+<p>.*(?<!</p>)$ |
find all lines that do not contain hede |
^((?!hede).)*$ |
National 'warcry'
Twitch sillyness
Not really a 'warcry', but whenever anyone posts any of these terms other nationals will join in repeating it.
PS: Sometimes it's just an emote spam
Country | Warcry |
---|---|
Dutch | G E K O L O N I S E E R D |
German | Sprich Deutsch, du Hurensohn! |
Swedish | Skรฅรฅรฅรฅรฅl |
Danish | Skรฅรฅรฅรฅรฅl |
Finnish | Torille! |
Bulgarian | KKomrade |
Germany | DatScheffe |
Information for a secret project
I can't show you yet. I'm halfway, but its important it's done.
Character | HTML code |
---|---|
๐ฅ | 𝑥 |
ษ | ə |
ฮฑ | α |
ฮฒ | β |
๐ | 𝔟 |
๐ | 𝔅 |
๐ | 𝔠 |
โญ | ℭ |
โ | † |
โก | ‡ |
๐ข | 𝔢 |
๐ | 𝔈 |
= | = |
๐ฃ | 𝔣 |
ฮณ | γ |
โฆ | … |
๐จ | 𝔨 |
๐ฉ | 𝔩 |
โณ | ℳ |
|
|
๐ฌ | 𝔬 |
รถ | ö |
๐ญ | 𝔭 |
โฒ | ′ |
๐ฎ | 𝔮 |
โ | → |
๐ฏ | 𝔯 |
ยง | § |
๐ | 𝔘 |
๐ฐ | 𝒰 |
ร | Ü |
โ | “ |
โ | ” |
ฯ | π |