Skip to content

Instantly share code, notes, and snippets.

View KonradLinkowski's full-sized avatar
:shipit:

Konrad Linkowski KonradLinkowski

:shipit:
View GitHub Profile
@KonradLinkowski
KonradLinkowski / KeyboardEvent.js
Created September 25, 2018 07:51
Gist for creating keyboard event.
function createKeyboardEvent(name, key, altKey, ctrlKey, shiftKey, metaKey, bubbles) {
var e = new Event(name)
e.key = key
e.keyCode = e.key.charCodeAt(0)
e.which = e.keyCode
e.altKey = altKey
e.ctrlKey = ctrlKey
e.shiftKey = shiftKey
e.metaKey = metaKey
e.bubbles = bubbles
@KonradLinkowski
KonradLinkowski / months.txt
Created January 30, 2019 17:12
Months separated by commas.
EN = 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'September', 'October', 'November', 'December'
PL = 'Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'|
@KonradLinkowski
KonradLinkowski / fbclid-remove.js
Last active February 2, 2019 15:30
Removes fbclid from facebook links.
window.ddEventListener('click', event => {
const el = event.target
if (el.tagName.toLowerCase() === 'a') {
event.preventDefault()
const url = new URL(el.href)
url.searchParams.delete('fbclid')
window.open(url.href, el.target)
}
}, true)
// or
@KonradLinkowski
KonradLinkowski / remove-all-from-docker.sh
Last active March 10, 2020 09:50 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
docker stop `docker ps -qa` && docker rm `docker ps -qa` && docker rmi -f `docker images -qa ` && docker volume rm $(docker volume ls -qf) && docker network rm `docker network ls -q`
@KonradLinkowski
KonradLinkowski / deploy.yml
Last active September 24, 2022 11:35
Github Pages auto-deploy
name: Build and Deploy
on:
push:
branches:
- main # change to your desired branch name
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@KonradLinkowski
KonradLinkowski / file.js
Created April 29, 2020 00:23
CORS Anywhere XMLHttpRequest example
// XMLHttpRequest.open override
var cors_api_host = 'cors-anywhere.herokuapp.com';
var cors_api_url = 'https://' + cors_api_host + '/';
var slice = [].slice;
var origin = window.location.protocol + '//' + window.location.host;
var open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
var args = slice.call(arguments);
var targetOrigin = /^https?:\/\/([^\/]+)/i.exec(args[1]);
if (targetOrigin && targetOrigin[0].toLowerCase() !== origin &&
class Simple1DNoise {
#MAX_VERTICES = 256;
#MAX_VERTICES_MASK = this.#MAX_VERTICES - 1;
amplitude = 1;
scale = 0.5;
#r = [];
constructor() {
for (let i = 0; i < this.#MAX_VERTICES; ++i) {
this.#r.push(Math.random());
}
@KonradLinkowski
KonradLinkowski / alias.toml
Created February 15, 2021 14:18
My git aliases
[alias]
status-all=for-each-ref --format="%(refname:short) %(upstream:track) (upstream:remotename)" refs/heads
Hello there
function calcula(op) {
const operations = {
'+': (a, b) => a + b,
'-': (a, b) => a - b,
'*': (a, b) => a * b,
'/': (a, b) => a / b,
}
const operation = operations[op]