Skip to content

Instantly share code, notes, and snippets.

View mieky's full-sized avatar
🦀

Mike Arvela mieky

🦀
View GitHub Profile
@mieky
mieky / code-repo.fish
Created March 28, 2024 18:33
Fish script to open Git repo in VS Code
function code-repo --description 'Open current Git repo in VSCode'
if not type -q git
echo "couldn't find command: git"
return 1
end
if not type -q code
echo "couldn't find command: code"
return 1
end
@mieky
mieky / github-artifacts-size.sh
Last active March 28, 2024 05:32
Get total size of artifacts in a GitHub repo
#!/bin/bash
# Calculate the total size of artifacts in GitHub repo (not visible in the UI).
# Needs token with the "repo" scope: Profile > Settings > Developer Settings > Personal access tokens
#
# Requires jq 1.6 or higher.
if [ $# -ne 1 ] || [ -z $API_TOKEN ]; then
echo "Usage: API_TOKEN=<token> $0 <org/repo>"
exit 1
@mieky
mieky / ha.fish
Last active March 28, 2024 05:29
Fish script for toggling between Hue lighting scenes
# Sample fish shell script to toggle Hue scenes with curl using the home assistant hue service.
# See: https://www.home-assistant.io/integrations/hue/#service-hueactivate_scene
#
# Uses fish shell and jq, `brew install fish jq`.
#
# Usage:
# - export HA_KEY="<api_token_generated_in_home_assistant_ui>"
# - tweak the entity_ids to match yours (call /api/states to see available entities)
# - save this in fish/functions, and append "ha" to the end of your config.fish to load
@mieky
mieky / rabbit_publish.sh
Last active March 28, 2024 05:27
Publish a JSON payload into a local RabbitMQ HTTP API
#!/bin/bash
# Publish JSON payloads into a RabbitMQ HTTP API with curl and jq.
# Usage: rabbit_publish.sh exchange_name '{ "data": "my json payload" }'
#
# To install prequisites on macOS:
# brew install rabbitmq jq
# rabbitmq-plugins enable rabbitmq_management
if [ $# -ne 2 ]; then
@mieky
mieky / macos-lifehacks.md
Last active December 2, 2023 21:10
MacOS Lifehacks

Collection of useful tips & tricks to set up on a Mac.

Safari: bind cmd+alt+arrows to switch between previous/next tab

defaults write -app Safari NSUserKeyEquivalents '{
"Show Next Tab" = "@~\\U2192";
"Show Previous Tab" = "@~\\U2190";
}'
@mieky
mieky / html5-camera-test.html
Last active March 28, 2022 08:00
HTML5 camera test
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>HTML5 camera test</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<form>
@mieky
mieky / ehdotus.md
Last active September 29, 2021 13:08 — forked from japsu/ehdotus.md
Sähköauton lataus taloyhtiössä

Sähköauton lataus taloyhtiössä

Esitys yhtiökokoukselle

Taustaa

Sähköautojen osuus autokannasta kasvaa koko ajan. Valtioneuvoston tavoitteena on, että vuonna 2030 Suomessa olisi jopa 700 000 täyssähköautoa ja lataushybridiä, kun vuoden 2020 lopussa liikennekäytössä oli 9 674 täyssähköautoa ja 45 650 lataushybridiä. Maaliskuussa 2021 voimaan astui laki, jonka myötä taloyhtiöiden pitää varautua sähköautojen määrän kasvuun.

Sähköauton latauksen järjestäminen on yksi keskeisimpiä kysymyksiä sähköauton hankintaa pohtivalle. Sähköauton kotilatauksen toteuttaminen sähkö- ja paloturvallisella tavalla edellyttää lataukseen tarkoitetun suojatun pistorasian tai kiinteän latausaseman asennusta. Lisäksi sähköauton latauksessa taloyhtiössä on huomioitava osakkaiden yhdenvertaisuus.

@mieky
mieky / ts-node-memoize.ts
Last active May 1, 2021 08:52
Simple function invocation memoization with Typescript
import * as crypto from "crypto";
type CacheKey = string;
type ExpiryTimestamp = number;
const log = (...args: any[]) => process.env.DEBUG && console.log(...args);
const hashCode = (input: string): string =>
crypto.createHash("sha256").update(input).digest("hex");
@mieky
mieky / .dir_colors
Last active February 27, 2021 13:21
macOS LS_COLORS for web development
# LS_COLORS
# Maintainers: Magnus Woldrich <m@japh.se>,
# Ryan Delaney <ryan.patrick.delaney@protonmail.com>
# URL: https://github.com/trapd00r/LS_COLORS
#
# This is a collection of extension:color mappings, suitable to use as your
# LS_COLORS environment variable. Most of them use the extended color map,
# described in the ECMA-48 document; in other words, you'll need a terminal
# with capabilities of displaying 256 colors.
#
// Generate a deterministic pseudo UUID (v4), such that the same input always gives the same output.
// Potentially useful for test mocks or such where a specific datum is associated to a specific UUIDs,
// but doesn't need guarantees against clashing.
// With ES6 modules, you can remove the "require" part, and instead import like this:
// import { createHash } from "crypto";
const pseudoUuid = (input) => require("crypto")
.createHash("sha256")
.update(input)