Skip to content

Instantly share code, notes, and snippets.

View simonwep's full-sized avatar
🎯
Focusing...

Simon simonwep

🎯
Focusing...
View GitHub Profile
@simonwep
simonwep / CLICommandParser.js
Created November 27, 2018 18:16
Function to parse cli commands
/**
* Parses a cli command, e.g. "mov a b -p all 'C:/user/me'"
* Example result of `mov -p 1000 -a "f and b" "/s/d/l" -l`:
*
* {
* "cmd": "mov",
* "params": {
* "p": "1000",
* "a": "f and b",
* "l": ""
@simonwep
simonwep / treesearch.js
Created April 19, 2019 15:28
Searches for a value in a object
function searchFor(val, s, all = true) {
const results = [];
const handleValue = (key, value, p) => {
const da = typeof key === 'string' && key.match(/^[_a-zA-Z][\w\d_]*$/);
const query = p + (da ? `.${key}` : `[${key}]`);
if (value === s) {
return query;
} else if (typeof value === 'object') {
const lookUpObjectValue = (obj, str) => {
const validProp = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c === '_';
const isNum = c => c >= '0' && c <= '9';
const errored = i => {
const cursor = `${str}\n${' '.repeat(i)}^`;
console.error(`Invalid accessor:\n${cursor}`);
};
const length = str.length;
@simonwep
simonwep / ConsoleProgressBar.java
Last active May 21, 2019 01:00
An simple console progressbar with message and a indicator.
package classes;
public class ConsoleProgressBar {
private double minValue;
private double maxValue;
private int barSize;
private int barPos;
private char[] loading = {'|', '\\', '-', '/'};
@simonwep
simonwep / docker-wide-purge.sh
Created August 3, 2019 12:40
Stops all docker container, removes all container and images
# Stop Running containers
docker stop $(docker ps -a -q)
# Remove container and images
docker rm $(docker ps -a -q)
docker image rm $(docker image ls -a -q)
# See if everything got removed
docker image ls
docker container ls
@simonwep
simonwep / deploy-github-pages.sh
Created December 27, 2019 15:21
Builds your app and moves all production files to the gh-pages branch
#!/bin/bash
BRANCH="gh-pages"
echo "[DGP] Deploying to github-pages (branch $BRANCH)..."
# Check if there are current changes
if [[ "$(git status --porcelain --untracked-files=no)" ]]; then
echo "[DPG] Please undo your current changes."
exit
fi
@simonwep
simonwep / duckduckgo-hide-ads.tapermonkey.js
Last active January 15, 2020 15:58
Hides duckduckgo ads
// ==UserScript==
// @name DuckDuckNoAds
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Hides duckduckgo ads
// @match https://duckduckgo.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
@simonwep
simonwep / github-contribution-hints.tapermonkey.js
Last active January 15, 2020 15:58
Enhanced contribution info
// ==UserScript==
// @name GitHub contribution hints
// @version 1.0
// @namespace http://tampermonkey.net/
// @description A few more infos about your contribs on the front page
// @match https://*.github.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
@simonwep
simonwep / github-auto-repo-confirm.tapermonkey.js
Last active January 15, 2020 15:58
Automatically inserts the repo-name in the security tab
// ==UserScript==
// @name GitHub auto confirm
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Automatically inserts your repo name in dialogs
// @match https://*.github.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
// ==UserScript==
// @name Kraken speech
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://trade.kraken.com/*
// @grant none
// ==/UserScript==