Skip to content

Instantly share code, notes, and snippets.

View jan-martinek's full-sized avatar

Jan Martinek jan-martinek

View GitHub Profile
local addScore <const> = playdate.scoreboards.addScore
local getScores <const> = playdate.scoreboards.getScores
local scoreboardsState <const> = State.scoreboards -- default state is an empty table {}
local boards = {
{
id = "score",
name = "High Scores",
},
-- ...
@jan-martinek
jan-martinek / Maze.lua
Last active September 3, 2022 13:45
Maze
local function vectorFromAngle(magnitude, angle)
angle = (angle + 90) % 360
local rad = math.rad(angle)
local x = magnitude * math.cos(rad)
local y = magnitude * math.sin(rad)
return v2D.new(x, y)
end
Maze = {}
class("Maze").extends(NobleScene)
@jan-martinek
jan-martinek / partial.html
Created July 17, 2021 02:04
Workaround for Hugo: sorting pages by Czech alphabet (first 40 alpha chars)
{{ $page := .Page }}
{{ range .pages }}
{{ $alpha := "aábcčdďeéěfgh#iíjklmnňoópqrřsštťuúůvwxyýzž" }}
{{ $title := substr (.Title | lower | replaceRE "ch" "#" | replaceRE (print "[^" $alpha "]") "") 0 40 }}
{{ $sortStr := split $title "" }}
{{ $len := len $sortStr }}
{{ $score := math.Pow 100 42 }}
/* correct quotes in various languages */
@mixin quotes($langs, $open, $close) {
@each $lang in $langs {
[lang="#{$lang}"] {
q::before { content: $open; }
q::after { content: $close; }
}
}
backend:
name: git-gateway
branch: master
media_folder: static/media
public_folder: /media
display_url: "https://pasporty.netlify.com"
slug:
encoding: ascii
clean_accents: true
collections:
#!/bin/bash
# $ npm run build
# $ sh /path/to/this/script/sdrm.sh ./book "John Doe"
DIR=$1
NAME=$2
LICENSE="Licencováno k užívání dle poskytnuté licence čtenáři <i>$NAME</i>."
PLACEHOLDER='<section id="social-drm-placeholder"></section>'
REPLACEMENT='<section id="social-drm">'$LICENSE'</section>'
@jan-martinek
jan-martinek / volume.py
Created August 31, 2018 21:03
Volume service for VLC radio based on Arduino measuring potentiometer voltage
#!/usr/bin/python
import atexit
import re
import socket
import subprocess
import time
import os
import sys
from datetime import datetime
@jan-martinek
jan-martinek / turtle.py
Created November 3, 2017 13:24
Simple turtle graphics script for use with STS-Pi and explorerhat (no pen logic)
#!/usr/bin/env python
# Explorer HAT/pHAT https://shop.pimoroni.com/search?type=product&q=explorer+hat
# STS-Pi https://shop.pimoroni.com/products/sts-pi
import time
import explorerhat
speed = 100
@jan-martinek
jan-martinek / retina-preview.php
Last active August 9, 2017 11:43
Preview last screenshot on another device
<?php
/* I use this to quickly preview last taken screenshot on my retina ipad.
* (I use xip.io to quickly access virtual hosts on my dev machine.)
*
* Be sure to allow write in the dir where this script is located.
*
* It's possible to change the directory where screenshots are stored on mac.
* Consider using one exclusively for this purpose
* (see google.com/search?q=change+screenshot+location+mac).
@jan-martinek
jan-martinek / phat-clock.py
Last active September 9, 2024 13:51
Simple clock for raspberry pi + Unicorn pHAT
#!/usr/bin/env python
# H | M*10 | M
# 1 5 9 | 1 5 | 1 5 9
# 2 6 10 | 2 | 2 6
# 3 7 11 | 3 | 3 7
# 4 8 12 | 4 | 4 8
import time
import unicornhat as unicorn