Skip to content

Instantly share code, notes, and snippets.

View murgo's full-sized avatar

Lauri Härsilä murgo

View GitHub Profile
@murgo
murgo / steamvr_actions_oculus_touch.json
Created March 26, 2024 00:38
Configuration for Hitman 3 VR with Meta Quest 3 through Steam Link (moves menu button)
{
"action_manifest_version": 0,
"alias_info": {},
"bindings": {
"/actions/main": {
"chords": [],
"haptics": [
{
"output": "/actions/main/out/HapticsLeft",
"path": "/user/hand/left/output/haptic"
@murgo
murgo / sahkohue.py
Last active November 4, 2022 14:53
Color Philips Hue light based on current electricity price
import requests
import sys
import json
from qhue import Bridge
def getPrice():
req = requests.get("https://api.spot-hinta.fi/JustNow") # please don't spam the API, max. 1 request per minute
return json.loads(req.content)["PriceWithTax"]
def getNormalizedPrice(price): # make price to be clamped and scaled such as 0-50 c/kWh -> 0-1
@murgo
murgo / HashBenchmark.cs
Created February 17, 2022 13:42
Test how fast you can generate SHA-256 hashes.
// To run this, create a new folder and inside it type:
// dotnet new console
// Then delete Program.cs, download this script into the folder and run with:
// dotnet run
using System.Security.Cryptography;
var random = new Random();
var buffer = new byte[14];
@murgo
murgo / Results
Last active January 22, 2021 17:08
Testing if testing for zero at loops is faster
murgo@Destiny:~/sompi$ time ./testspeed
Load at end: 939524097
real 0m13.912s
user 0m13.912s
sys 0m0.000s
murgo@Destiny:~/sompi$ time ./testspeed_zerocheck
Load at end: 939524097
real 0m14.144s
user 0m14.144s
sys 0m0.000s
#!/usr/bin/env bash
die () {
echo >&2 "$@"
echo
echo "Usage:"
echo "duplicatefile.sh <originalFileLocation> <targetPath> <copyCount>"
echo
echo "Example usage: ./duplicatefile.sh file.txt . 5"
echo
@murgo
murgo / ComponentReplaceTool.cs
Created November 19, 2019 02:17
Unity tool script for replacing a Component with another in prefabs and scene objects
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Assets.Scripts.Tools.Editor
{
public class ComponentReplaceTool
{
@murgo
murgo / montecarlo-lootbox.js
Last active June 2, 2018 03:59
Quick monte carlo simulation for calculating average price of getting all unique prizes in a loot box system
<div>
Total iterations:
<span class="iterations">0</span>
</div>
<div>
Average count for complete collection:
<span class="averageCount">0</span>
<div>
@murgo
murgo / Program.cs
Last active March 21, 2017 01:26
My wunderpahkina-vol6 solver
using System;
using System.IO;
using System.Linq;
namespace Wunderpahkina_vol6
{
class Program
{
static void Main(string[] args)
{
@murgo
murgo / archiver.ps1
Created January 27, 2017 05:09
A script traversing through git commits, building the app for every point in history and copying the build output to deployable location, thus giving me a complete and browsable history of the game at all phases of development.
Param([Parameter(Mandatory=$true)][string]$archiveFolder)
do {
# form name from git commit time and message
$name = & git show -s --format="%cI_%s"
$name = $name.replace(':', '.').replace(' ', '-');
echo $name
# hack the watch and sourcemaps away
(Get-Content tsconfig.json) -replace '"watch": true', '"watch": false' | Set-Content tsconfig.json
@murgo
murgo / Boggler.cs
Last active October 29, 2015 23:13
Boggler
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Boggle
{
public class Boggler
{