Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
Doing awesome stuff

Filip Troníček filiptronicek

🐢
Doing awesome stuff
View GitHub Profile
@filiptronicek
filiptronicek / paper.py
Created Jan 25, 2021
Update your local Paper MC version
View paper.py
import requests
import re
import json
import os
req = requests.get("https://papermc.io/api/v2/projects/paper/version_group/1.16/builds").text
releases = json.loads(req)
download = 'https://papermc.io/api/v2/projects/paper/versions/'+releases['builds'][-1]['version'] + '/builds/' + str(releases['builds'][-1]['build']) + '/downloads/'+releases['builds'][-1]['downloads']['application']['name']
@filiptronicek
filiptronicek / script.js
Created Jan 22, 2021
Get all smileys from W3Schools
View script.js
const nodes = document.querySelectorAll("html body div#belowtopnav.w3-main.w3-light-grey div.w3-row.w3-white div#main.w3-col.l10.m12 div.w3-responsive table.w3-table-all.charset-tryit tbody tr td:first-child")
const emojis = [];
for (const node of nodes) {
emojis.push(node.innerText)
}
console.log(JSON.stringify(emojis))
@filiptronicek
filiptronicek / time.js
Last active Nov 27, 2020
Get time difference between server and client
View time.js
const timestamp = Date.now();
fetch(`https://time.filiptronicek.workers.dev/?ts=${timestamp}`).then(f => f.json()).then(f => {
const nowstamp = Date.now()
console.table({adjusted: Math.round(f.result.ms - (nowstamp - timestamp) / 2), raw: f.result.ms})
})
@filiptronicek
filiptronicek / worker.js
Created Oct 27, 2020
Minecraft latest version Cloudflare Worker
View worker.js
const url = "https://launchermeta.mojang.com/mc/game/version_manifest.json";
async function gatherResponse(response) {
const { headers } = response;
const contentType = headers.get("content-type") || "";
return (await response.json());
}
async function handleRequest() {
const init = {
@filiptronicek
filiptronicek / backup-with-few-players.sh
Last active Oct 25, 2020
Back up a folder on linux to Google Drive
View backup-with-few-players.sh
sudo tmux capturep -p | egrep -i "There are [1-2]" && cd /home/ && sudo bash back.sh
@filiptronicek
filiptronicek / api-commit.js
Created Oct 11, 2020
Get current Vercel deploy commit sha on your website
View api-commit.js
export default async (_req, res) => {
res.json({ data: process.env.VERCEL_GITHUB_COMMIT_SHA });
};
@filiptronicek
filiptronicek / conversion.md
Last active Oct 9, 2020
Converting from jQuery to vanilla JS
View conversion.md
View bash-stuff.md

Bash stuff

  • Ctrl + O - trigger next command in history
  • Ctrl + R - search in history
  • Ctrl + Z - run in background

alias update="sudo apt-get update && sudo apt-get upgrade && sudo apt-get full-upgrade autoremove"

Git stuff

Verbose before commit: git config --global commit.verbose 1

@filiptronicek
filiptronicek / qr.js
Created Jul 21, 2020
QR code generator in 5 lines or less
View qr.js
let toConvert = $("#content").val();
function generate(text) { $("#qrcode").html(""); $("#qrcode").qrcode(text);}
if($("#content").val() == "") $("#qrcode").html("");