Skip to content

Instantly share code, notes, and snippets.

View kristofgilicze's full-sized avatar

Kristof Gilicze kristofgilicze

View GitHub Profile
@kristofgilicze
kristofgilicze / calculate_nmea_checksum.py
Created August 3, 2022 16:12
Calculate NMEA checksum
def calculate_nmea_checksum(sentence: str) -> bool:
checksum = 0
payload = sentence.raw.split("*")[0][1:]
for byte in payload:
checksum ^= ord(byte)
return checksum == sentence.checksum
@kristofgilicze
kristofgilicze / load-font-face.ts
Created December 1, 2021 23:38
Load font face for use in WebComponents
function loadFontFace(
fontName: string,
url: string,
fontWeight: string = 'normal',
fontStyle: string = 'normal',
format: string = 'woff2'
) {
// Add custom font to page DOM since font-face doesn't work within Shadow DOM.
let element = document.getElementById(`custom-loaded-${fontName}`);
@kristofgilicze
kristofgilicze / set-plain-bg-gnome.sh
Created November 14, 2021 21:23
Set the Gnome bg a solid color
gsettings set org.gnome.desktop.background primary-color '#2C001E'
gsettings set org.gnome.desktop.background color-shading-type 'solid'
@kristofgilicze
kristofgilicze / snap-rm-old-revisions.sh
Created November 13, 2021 19:20
Remove old snap revisions to clean up some space
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
i=0
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
echo "$snapname $revision"
((i=i+1))
@kristofgilicze
kristofgilicze / centering-a-div.css
Created April 1, 2021 19:19
The age old question of centering a DIV, the modern way.
/*
<div class="wrapper">
<div></div>
</div>
*/
/* With Grid */
@kristofgilicze
kristofgilicze / terminal-line-cursor-effect.css
Created March 30, 2021 13:07
Terminal cursor style blinking dash at the end of the element with pure css
.terminal-line-cursor-effect::after {
content: ' _';
animation: animate 1.5s linear infinite;
}
@keyframes animate {
0% {
opacity: 0;
}
50% {
@kristofgilicze
kristofgilicze / DarkModeToggle.vue
Last active March 5, 2021 17:47
Dark mode toggle for Vuetify
<template>
<div>
<v-tooltip v-if="!$vuetify.theme.dark" bottom>
<template v-slot:activator="{ on }">
<v-btn v-on="on" icon @click="toggleDarkMode">
<v-icon class="mr-1">mdi-moon-waxing-crescent</v-icon>
</v-btn>
</template>
<span>Dark Mode On</span>
</v-tooltip>
@kristofgilicze
kristofgilicze / blueprint-bg.css
Created February 13, 2021 00:45
Blueprint CSS pattern for backgrounds
body {
background-color: #269;
background-image:
linear-gradient(rgba(255,255,255,.5) 2px, transparent 2px),
linear-gradient(90deg, rgba(255,255,255,.5) 2px, transparent 2px),
linear-gradient(rgba(255,255,255,.28) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,.28) 1px, transparent 1px);
background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px;
}
@kristofgilicze
kristofgilicze / tile_server.py
Last active February 15, 2021 18:37
Simple Tile server Blueprint for Flask Python framework integration
import os
import sqlite3
from io import BytesIO
from flask import g
from flask import abort
from flask import Blueprint
from flask import current_app
/*==============================
* The BrainF*ck interpreter
* Kristof Gilicze
* 2018.09.29.
*==============================*/
#include <stdio.h>
enum StatusCode{
SUCCESSFULL_RUN=0,