Skip to content

Instantly share code, notes, and snippets.

View JohannesFischer's full-sized avatar

Johannes Fischer JohannesFischer

View GitHub Profile
@JohannesFischer
JohannesFischer / regex-golf
Last active May 12, 2021 01:50
My solutions for Regex Golf - https://alf.nu/RegexGolf
# Warmup – Type a regex in the box.
foo
# Anchors – You are deducted one point per character you use, and ten if you match something you shouldn't.
ick$
# It never ends – $ not allowed
fu\b
# Ranges – The test vectors were generated by grepping /usr/dict/words. Can you tell?
@JohannesFischer
JohannesFischer / bored.js
Last active March 7, 2018 13:23
Prints block letters
const letters = {
a: [
0, 1, 1, 1, 0,
1, 0, 0, 0, 1,
1, 1, 1, 1, 1,
1, 0, 0, 0, 1,
1, 0, 0, 0, 1
],
b: [
1, 1, 1, 1, 0,
@JohannesFischer
JohannesFischer / index.js
Last active February 19, 2018 00:15
Selenium Node Tests
const webdriver = require('selenium-webdriver');
const { By, promise, until } = webdriver;
const firefox = require('selenium-webdriver/firefox');
const binary = new firefox.Binary(firefox.Channel.NIGHTLY);
binary.addArguments('-headless');
const capabilities = {
acceptInsecureCerts: true
};
{"docs":"css/d3~4/docker~17/dom/dom_events/eslint/express/git/html/http/javascript/moment/mongoose/node/npm/ruby~2.3/rails~4.1/sinon~4/webpack"}
@JohannesFischer
JohannesFischer / Dockerfile
Created January 30, 2018 07:12
Docker Mongo Node
FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 8000
CMD [ "npm", "start" ]
@JohannesFischer
JohannesFischer / swap.js
Last active January 13, 2018 06:43
determine if an array is sortable with one swap
// test arrays
var x = [1, 2, 3];
var y = [1, 3, 2];
var z = [3, 2, 1];
// global swap counter
var swaps = 0;
// custom sort function that counts swaps
function swapcount(a, b){
@JohannesFischer
JohannesFischer / userscript.js
Created November 27, 2017 02:30
e-learning
console.log('E-Learning Boost Activated');
let initialized = false;
function getAnswerWindow() {
let win = window;
while (win.window.length > 0) {
win = win.window[1];
}
return win;
@JohannesFischer
JohannesFischer / docker.sh
Last active November 7, 2017 00:50
Docker - Remove all untagged Images
docker image rm --force $(docker image ls | awk '$1 == "<none>" {print $3}')
@JohannesFischer
JohannesFischer / pre-commit
Last active December 6, 2017 23:48
Git pre commit hook - test modified files with ESLint and Rubocop and for focus tags in spec files
#!/bin/sh
FILE_COUNT=$(git status | grep 'modified:' | wc -l)
if [ $FILE_COUNT -gt 100 ] ; then
echo "File count is 100+, skipping pre-commit validation"
exit 0
fi
FAILED=0
@JohannesFischer
JohannesFischer / javascript.json
Last active February 23, 2017 02:04
VS Code Snippets [javascript]
{
"Print to console": {
"prefix": "conl",
"body": [
"console.log($1);"
],
"description": "Log output to console"
},
"Print info to console": {
"prefix": "coni",