Skip to content

Instantly share code, notes, and snippets.

View mmodrow's full-sized avatar

Marc A. Modrow mmodrow

  • Bremen, Germany
View GitHub Profile
@mmodrow
mmodrow / Batman.js
Created October 19, 2017 11:32
NaNaNaNaNaNaNaNaNa NaNaNaNaNaNaNa BATMAN!
for(var i=0, a="";i<16;i++)a+=((+"[]")+"").substring(0,2)+(!!((i+1)%9)?"":" ")+(!!((i+1)%16)?"":String.fromCharCode(32,66,65,84,77,65,78,33))
@mmodrow
mmodrow / cacheBreaker.php
Created October 19, 2017 11:33
Cache breaker for gitted projects
/**
* add a cache breaking get parameter to an url, that's based on the local git dir timestamp
* @return string
*/
public function getCachebrokenUrl($url = "") {
$version = $this->getVersionHash();
$cachebrokenUrl = preg_replace("/((?:href|src)=\"[^?\"]*)(\")/", "$1?version=".$version."$2", $url);
return $cachebrokenUrl;
}
@mmodrow
mmodrow / caesar.js
Created October 19, 2017 11:39
Ceasar cypher in JS
function caesar(char, offset){
var charArray = Array.prototype.slice.call(char);
var output = "";
charArray.forEach( function(singleChar){
output += singleChar === " " ? " " :
String.fromCharCode(((((singleChar+"").toUpperCase().charCodeAt (0) + offset + 26) - 65)% 26)+ 65);
});
return {message: output, offset: offset};
}
@mmodrow
mmodrow / frontendchecklist.io-persist.js
Last active December 15, 2017 09:21
Adds load and save feature on the command line for carrying state on https://frontendchecklist.io beyond browser sessions
// ==UserScript==
// @name The Front-End Checklist Persistator
// @namespace http://tampermonkey.net/
// @version 0.1
// @description load and store data put into "The Front-End Checklist"
// @author Marc Modrow
// @match https://frontendchecklist.io
// @grant none
// ==/UserScript==
@mmodrow
mmodrow / NewtonsoftJsonRegexParseFailExample.cs
Last active January 31, 2018 19:29
Demonstrates a misleading ArgumentOutOfRangeException when Parsing a RegexString without '/'-enclosure with Newtonsoft.Json
using System.Text.RegularExpressions;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
ClassWithRegexAttribute objectWithRegexAttribute =
JsonConvert.DeserializeObject<ClassWithRegexAttribute>(
"{\"RegexAttribute\": \"committing-some-shitty-code-on-my-colleagues\"}");
@mmodrow
mmodrow / 9gagEventlessDownloadIcon.js
Created December 11, 2018 13:04
Non-Evented Download-Links on 9gag
// ==UserScript==
// @name Non-Evented Download-Link on 9gag
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adds an anchor to every 9gag-Post, that has no events attached to it.
// @author https://gist.github.com/mmodrow
// @match https://9gag.com/*
// @grant none
// ==/UserScript==
@mmodrow
mmodrow / allocateWindowsToWorkspaces.sh
Last active January 22, 2019 15:16
Allocate Workspaces to Applications in Ubuntu
#!/bin/bash
function allocateByName() {
ID=$(getWindowIdByTitle "$1")
if [ "$ID" = "" ]; then
echo "Window $1 not found."
echo ""
else
allocateByIds "$ID" $2 "$1" "$3"
fi
@mmodrow
mmodrow / MSDocsRedirect.js
Last active August 4, 2020 13:25
MSDocs redirect to english via tampermonkey
// ==UserScript==
// @name MSDocs redirect to english
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author mmodrow <marc@marcamodrow.de>
// @match https://docs.microsoft.com/*
// @grant none
// ==/UserScript==
@mmodrow
mmodrow / start.sh
Last active March 22, 2019 08:42
Start a GUI application from the Linux terminal without blocking the terminal.
#!/bin/bash
force=0
for arg in "$@"
do
if [[ "$arg" = "-h" || "$arg" = "--help" ]]
then
echo "Just add program starting commands as parameters as you please. They will be started in order."
echo "Add '-f' at any point to apply force mode to all following programs."
echo "Add '-F' at any point to remove force mode to all following programs."
continue
@mmodrow
mmodrow / git-lol.sh
Created February 1, 2019 16:32
Generate a graphical git commit charton the console
# symlink as /usr/sbin/git-lol to access as "git lol" alias
git log --graph --decorate --oneline --abbrev-commit --all --color=always