Skip to content

Instantly share code, notes, and snippets.

@fhfaa
fhfaa / string-annot.js
Last active December 21, 2015 12:25
String Annotations @Schneller
(function (str, notes, wrap) {
var IDX = 0, TXT = 1,
lines = (Array(str.length + 1)).join(' ').split('');
notes = notes.map(function (n) {
return [+n.replace(/\D[\s\S]*$/, '') || 0, n.replace(/^\d+\s*/, '')];
});
notes.sort(function (a, b) {
return a[IDX] === b[IDX] ? 0 : (+a[IDX] < +b[IDX] ? 1 : -1);
}).forEach(function (n) {
@fhfaa
fhfaa / adventofcode15.js
Last active December 5, 2016 10:06
Advent of Code 2015
// Chrome DevTools console ~~ enter pt.1 & 2 separately
// var input = $({auto-generated <pre>-tag w/ input txt}).textContent.trimTrailingNL();
// I.)
input.split('').reduce((e,s) => e+(s==='('?1:-1),0)
input.split('').some(((p) => (c,i) => !~(p+=c==='('?1:-1)?console.log(++i)|1:0)(0))
// II.)
input.split('\n').map((s) => s.split('x').map(parseFloat).sort((a,b) => a-b)).map((a) => a[0]*a[1]*3+a[1]*a[2]*2+a[0]*a[2]*2).reduce((a,b) => a+b)
@fhfaa
fhfaa / renamer-albums-id3.pas
Last active October 22, 2018 22:43
ReNamer script: Name folders "$artist - $year - $album" according to ID3 the tags of the first contained *.MP3 (http://www.den4b.com/?x=products&product=renamer), ALSO rename "Artist - Album" to "Artist - Year - Album"
const
MASK = '*.mp3';
var
MasterFile: WideString;
function FindMasterFile(const Folder: WideString): WideString;
var
Files: TStringsArray;
begin
@fhfaa
fhfaa / CustomRules.js
Last active September 8, 2023 16:46
CORS ALL the things in Fiddler2
import System;
import System.Windows.Forms;
import Fiddler;
// INTRODUCTION
//
// Well, hello there!
//
// Don't be scared! :-)
//
@fhfaa
fhfaa / gcc-minileague.js
Created June 10, 2016 11:26
Global Corp. Challenge: fix mini leagues by accounting for missed entries
// content script for /event/mini-league/individual/
;(function () {
var maxEntries = 0,
sep = '',
$t = $('.table-responsive'),
sorted,
strideLength = [];
$t.find('th:eq(3)').text('FIXED');
[].filter.call(document.querySelectorAll('.chartlist-name'), function (e) { return (/(Hellboy)|(Bibi Blo)|(Bibi und Tina)|(Benjamin Bl)|(Die drei )|(John Sinclair)|(Sherlock Holmes)|(Hui Bu)|(Offenbarung 23)/i).test(e.innerText) }).
forEach(function (e) { e.parentNode.querySelector('.chartlist-delete form button').click(); });
document.querySelector('li.previous a').click();
@fhfaa
fhfaa / adventofcode16.js
Last active December 5, 2016 10:06
Advent of Code 2016
// Chrome DevTools console ~~ enter pt.1 & 2 separately
// var input = $({auto-generated <pre>-tag w/ input txt}).textContent.trimTrailingNL();
// I.)
input.split(', ').reduce(function (o,e,i,a) {
o.i=(o.i+(e[0]=='L'?3:5))%4;
o[o.i%2]+=(o.i>1?-1:1)*+e.substr(1);
return i+1==a.length?Math.abs(o[0])+Math.abs(o[1]):o;
},{i:0,0:0,1:0})
input.split(', ').reduce(function (o,e,s,n) {
@fhfaa
fhfaa / arschloch.bat
Last active November 28, 2017 19:44
von der uni, scheinbar fuer mark
@ECHO OFF
SETLOCAL
:: ffffffff
GOTO eof
:: ffff
:: -- OPTIONS --
:: 1 for yes, 0 for no
@fhfaa
fhfaa / adventofcode17.js
Last active December 12, 2017 12:21
Advent of Code 2017
// Chrome DevTools console ~~ enter pt.1 & 2 separately
// var input = $({auto-generated <pre>-tag w/ input txt}).textContent.trimTrailingNL();
// I.)
input.split('').map((e,i,a)=>e===(a[i+1]||a[0])?+e:0).reduce((a,b)=>a+b)
((t,l)=>(l=t.length/2)&&t.split('').map((e,i,a)=>e==a[(i+l)%t.length]?+e:0).reduce((a,b)=>a+b))(input)
@fhfaa
fhfaa / untappd.js
Created July 19, 2021 21:15
Export Untappd photos, quick & dirty
// === RUN IN BROWSER DEV TOOLS ===
// Requires: cURL set up and in path
// alterntively, change the generated command to whatever you like
// Log in to the Untappd website and open the gallery for any user:
// https://untappd.com/user/<USERNAME>/photos
// Auto-Click "Load more images" until there are no more (until button is hidden)
function more() {
const b = document.querySelector('.more_photos');