Skip to content

Instantly share code, notes, and snippets.

View filiptronicek's full-sized avatar
🐢
Doing awesome stuff

Filip Troníček filiptronicek

🐢
Doing awesome stuff
View GitHub Profile
@filiptronicek
filiptronicek / time.js
Last active November 27, 2020 12:15
Get time difference between server and client
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 October 27, 2020 12:02
Minecraft latest version Cloudflare Worker
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 October 25, 2020 12:22
Back up a folder on linux to Google Drive
sudo tmux capturep -p | egrep -i "There are [1-2]" && cd /home/ && sudo bash back.sh
@filiptronicek
filiptronicek / api-commit.js
Created October 11, 2020 19:12
Get current Vercel deploy commit sha on your website
export default async (_req, res) => {
res.json({ data: process.env.VERCEL_GITHUB_COMMIT_SHA });
};
@filiptronicek
filiptronicek / conversion.md
Last active October 9, 2020 07:07
Converting from jQuery to vanilla JS
@filiptronicek
filiptronicek / bash-stuff.md
Last active July 30, 2020 18:16
Bash tricks

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 July 21, 2020 09:35
QR code generator in 5 lines or less
let toConvert = $("#content").val();
function generate(text) { $("#qrcode").html(""); $("#qrcode").qrcode(text);}
if($("#content").val() == "") $("#qrcode").html("");
@filiptronicek
filiptronicek / nehoda.txt
Last active July 15, 2020 15:41
Nehoda API
PN = počet nehod
Š = škody (in K)
TR = Těžce ranění
PVA = Pod Vlivem Alkoholu
NR = 19
LR = lehce zraněných
@filiptronicek
filiptronicek / dark.css
Created June 24, 2020 21:06
Mannoviny Darkmode (WIP)
@media (prefers-color-scheme: dark) {
header, .site-title a {
background: #2a2a2e !important;
color: white !important;
}
}