Skip to content

Instantly share code, notes, and snippets.

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

Simon simonwep

🎯
Focusing...
View GitHub Profile
@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
// ==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==
// ==UserScript==
// @name GitHub notification-count
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Shows the amount of notifications
// @match https://*.github.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
const selection = new SelectionArea({
// All elements in this container can be selected
selectables: ['.box-wrap > div'],
// The container is also the boundary in this case
boundaries: ['.box-wrap']
}).on('start', ({store, event}) => {
// Remove class if the user isn't pressing the control key or ⌘ key
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 / 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') {
@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": ""
// ==UserScript==
// @name Spotify ad skipper
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Detects and skips ads on spotify
// @match https://*.spotify.com/*
// @grant none
// @run-at document-start
// @downloadURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw
// @updateURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw
@simonwep
simonwep / APIDocExample.md
Last active February 1, 2023 06:45
An API-Documentation example README

API Documentation Example

This API uses POST request to communicate and HTTP response codes to indenticate status and errors. All responses come in standard JSON. All requests must include a content-type of application/json and the body must be valid JSON.

Response Codes

Response Codes

200: Success
400: Bad request
401: Unauthorized
404: Cannot be found
@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 = {'|', '\\', '-', '/'};