Skip to content

Instantly share code, notes, and snippets.

View VojtaStruhar's full-sized avatar
🤓

Vojtěch Struhár VojtaStruhar

🤓
View GitHub Profile
@VojtaStruhar
VojtaStruhar / publish-godot-to-itch.yml
Created March 6, 2024 21:14
Publish a Godot 4 game to Itch.io with Github Actions
name: Publish to Itch.io
on:
push:
branches: ["master"]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
@VojtaStruhar
VojtaStruhar / happy_number.py
Created December 25, 2023 13:23
Benchmark of string and numerical approaches to the Happy Number Leetcode task.
import timeit
def isHappyStr(n: int) -> bool:
seen = set()
current = str(n)
while current not in seen:
seen.add(current)
sum = 0
@VojtaStruhar
VojtaStruhar / FlyCamera.cs
Created August 29, 2022 14:21 — forked from FreyaHolmer/FlyCamera.cs
A camera controller for easily flying around a scene in Unity smoothly. WASD for lateral movement, Space & Ctrl for vertical movement, Shift to move faster. Add this script to an existing camera, or an empty game object, hit play, and you're ready to go~
using UnityEngine;
[RequireComponent( typeof(Camera) )]
public class FlyCamera : MonoBehaviour {
public float acceleration = 50; // how fast you accelerate
public float accSprintMultiplier = 4; // how much faster you go when "sprinting"
public float lookSensitivity = 1; // mouse look sensitivity
public float dampingCoefficient = 5; // how quickly you break to a halt after you stop your input
public bool focusOnEnable = true; // whether or not to focus and lock cursor immediately on enable
@tool
extends Node3D
# ------------------------------------------------------------------------------
# Script that turns a folder with meshes into MeshInstances in a scene.
# You can then export the scene into a MeshLibrary or further customize the
# meshes. You may want to add colliders :)
# Good for testing / prototyping / quick layout purposes.
# Written and tested in Godot 4 alpha 12
# ------------------------------------------------------------------------------
@VojtaStruhar
VojtaStruhar / DebugWireframe.qml
Created June 30, 2022 17:08
Wireframe rectangle with a description that I use for quickly sketching out complex layouts in QML.
// A clearly visible "wireframe" rectangle used for quickly sketching out layouts.
// Color of the rectangle is computed from its description. If you don't give it
// any, it will default to light gray color.
// Shows borders, diagonal, description text and its size, all colored.
import QtQuick
import QtQuick.Shapes 1.3
Rectangle {
id: root
#!/bin/sh
# This scipt was created to simplify connecting to my Rasberry Pi 4
# via ssh. Be sure to set the MAC addresses and username accordingly!
DEVICES=$(arp -an)
parse_ip() {
RPI_ADDRESS=$(echo $DEVICES | grep $1 | \
awk -F '(' '{print $2}' | awk -F ')' '{print $1}')
enum FilterType : String {
case Mono = "CIPhotoEffectMono"
case MonoChrome = "CIColorMonochrome"
case Noir = "CIPhotoEffectNoir"
case Tonal = "CIPhotoEffectTonal"
case Sharpen = "CIUnsharpMask"
case Blur = "CIGaussianBlur"
case Pixelate = "CIPixellate"
case Edges = "CIEdges"
case Negative = "CIColorInvert"
func addFilter(filterType : FilterType) -> UIImage {
let filter = CIFilter(name: filterType.rawValue)
// convert UIImage to CIImage and set as input
let ciInput = CIImage(image: self)
filter?.setValue(ciInput, forKey: "inputImage")
if filterType == .Sharpen {
filter?.setValue(0.8, forKey: "inputIntensity")
filter?.setValue(8, forKey: "inputRadius")
}