Skip to content

Instantly share code, notes, and snippets.

View krmax44's full-sized avatar

Max krmax44

View GitHub Profile
@krmax44
krmax44 / Mockify-dist.js
Last active November 22, 2017 09:11
Mockify everything.
/*
Mockify text on the fly with this small script
How to use: Create a new bookmark in your browser, name it Mockify or something and as URL paste the following:
Click on the bookmark, enter your text and it will copy your mockified text to your clipboard.
*/
javascript:(function(){ var input = prompt("Mockify:", ""); var out = ""; for (i = 0; i < input.length; i++) { if (i % 2) { out += input[i].toUpperCase(); } else { out += input[i].toLowerCase(); } } var tbx = document.createElement('input'); document.body.appendChild(tbx); tbx.value = out; tbx.focus(); tbx.setSelectionRange(0, tbx.value.length); document.execCommand("copy"); document.body.removeChild(tbx); })();
@krmax44
krmax44 / longestWords.js
Created October 8, 2018 18:06
Horribly inefficient solution, but it's only one line of code!
// words.txt: https://github.com/dwyl/english-words/blob/master/words.txt
// see this video for why this exists: https://www.youtube.com/watch?v=zp4BMR88260
console.log(require('fs').readFileSync('words.txt').toString().split('\n').filter(word => /^[abcdefhijlnoprstu\-y. ]*$/.test(word.toLowerCase())).sort((a,b) => a.length < b.length ? 1 : -1)[0]);
// output: dichlorodiphenyltrichloroethane
@krmax44
krmax44 / homework.js
Last active May 30, 2019 22:29
Capture The Flag At UCF - Scripting Repetition solution with Node.js
const net = require('net');
const client = new net.Socket();
const math = require('mathjs'); // requires mathjs package!
client.connect(10104, 'ctf.hackucf.org');
client.on('data', data => {
const text = data.toString();
const flag = /flag{.*}/gm.exec(text);
@krmax44
krmax44 / index.js
Last active September 4, 2019 14:10
Get a random German city.
#!/usr/bin/env node
const axios = require('axios');
const sparqlQuery = `SELECT ?itemLabel
WHERE
{
?item wdt:P31 wd:Q1549591.
?item wdt:P17 wd:Q183.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
@krmax44
krmax44 / script.js
Created September 12, 2019 19:03
Remove all videos from YouTube Watch Later playlist
/*
go to https://www.youtube.com/playlist?list=WL&disable_polymer=true
or any other YouTube playlist - but make sure to be on the old interface
scroll all the way to the bottom and load in all playlist items
then open up the developer console (Ctrl + Shift + I)
and paste the following snippet
*/
(async () => {
for (const e of $$('.pl-video-edit-remove')) {

Keybase proof

I hereby claim:

  • I am krmax44 on github.
  • I am krmax44 (https://keybase.io/krmax44) on keybase.
  • I have a public key whose fingerprint is ED54 CB31 C56C 04BD 8DB9 2014 5C49 9A4F 4EC4 EE03

To claim this, I am signing this object:

/*
I stumbled upon the Python-syntax for creating a RegEx, and decided to spend a minute trying to replicate
it in JavaScript with Template String Functions. I certainly have no use for it but there you go.
*/
function combine(...args) {
const parts = args.shift();
const inserts = [...args, ''];
return parts.reduce((a, b, i) => (a += b + inserts[i]), '')
@krmax44
krmax44 / _README.md
Created August 13, 2020 19:50
Continous deployment with Gitlab and PHP

Continous deployment with Gitlab and PHP

Use this script to auto-deploy Gitlab artifacts to your PHP server.

Usage

Set up a Gitlab CI pipeline that creates an artifact zip file, a webhook that is triggered by pipeline events set to index.php. The token should be a secure, random string and needs to be also set in config.php.

This project follows hack-driven development guidelines - please read the code thoroughly before deploying on production. No warranty provided, it might just rm -rf your life server 🤷

@krmax44
krmax44 / Code.gs
Created November 9, 2020 08:47
JS Array functions in Google Spreadsheets
function JSMAP(data, fn) {
return data.map(eval(fn));
}
function JSFILTER(data, fn) {
return data.filter(eval(fn));
}
function JSREDUCE(data, fn, start) {
return data.reduce(eval(fn), eval(start));
@krmax44
krmax44 / _r2c3.md
Last active December 28, 2020 12:27

Real Remote Chaos Experience (r2c3)

Remote, as in, from the couch. Allows the rc3 world to be navigated using a gamepad. Install Greasemonkey, then click on the Raw button of the r2c3.user.js file below. An installation window should open. If not, just create an empty script and paste the code below.

Controls

  • axis 0/1: mapped to up, down, left, right (movement).
  • button 5 (right top shoulder button): mapped to shift (running)
  • button 0 (A button): mapped to Enter
  • button 1 (X button): mapped to Mic Mute toggle