Skip to content

Instantly share code, notes, and snippets.

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

Simon simonwep

🎯
Focusing...
View GitHub Profile
@simonwep
simonwep / FXResizeHelper.java
Created February 5, 2018 14:46
Helper class to resize an undecorated JavaFX Stage.
package classes;
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.stage.Screen;
import javafx.stage.Stage;
import java.util.HashMap;
@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 / 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
// ==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 / 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;
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
// ==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==
// ==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==