Skip to content

Instantly share code, notes, and snippets.

View jancimajek's full-sized avatar

Jan Majek (Yanchix Ltd) jancimajek

View GitHub Profile
@jancimajek
jancimajek / watch-screenshots.ps1
Last active November 24, 2023 01:02
Move Windows Screenshot files
# See: https://superuser.com/a/844034/448073
#
# Useful Docs:
# - `Get-EventSubscriber` -- List subscribed events -- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-eventsubscriber?view=powershell-7.3
# - `Register-ObjectEvent` -- Register new event -- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/register-objectevent?view=powershell-7.3
# - `Unregister-Event -SubscriptionId 123` -- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/unregister-event?view=powershell-7.3
$watchFolder = "$env:LOCALAPPDATA\Packages\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\TempState\ScreenClip"
# Define actions after an event is detected
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jancimajek
jancimajek / install-docker-colima.md
Last active May 18, 2023 09:34
Install Docker with alternative runtime Colima via brew

Install Docker with alternative runtime Colima via brew

# Install docker, compose & buildx
brew install docker
brew install docker-compose
brew install docker-buildx

# Link plugins
mkdir -p ~/.docker/cli-plugins
console.clear();
const appStart = Date.now();
const delay = async (delayMs: number) => new Promise(res => setTimeout(res, delayMs));
const waitFor = async (checkFn: () => Promise<boolean>, maxWaitMs = 5000, pollIntervalMs = 250): Promise<void> => {
const start = Date.now();
// const waitForIt = async (start: number): Promise<void> => {
// const check = await checkFn();
@jancimajek
jancimajek / github-labels.sh
Last active November 18, 2022 19:16
Set up labels for a GitHub repo
#!/usr/bin/env sh
# Set up labels:
gh label list && \
gh label edit "bug" -n "Bug" -c "#d73a4a" -d "Something isn't working" && \
gh label edit "documentation" -n "Docs" -c "#0075ca" -d "Improvements or additions to documentation" && \
gh label edit "enhancement" -n "Enhancement" -c "#CAE308" -d "New feature or request" && \
gh label edit "question" -n "Tech Debt" -c "#29CEDF" -d "Technical debt" && \
gh label edit "wontfix" -n "Ignore" -c "#bbbbbb" -d "Disregard & Ignore" && \
gh label delete --confirm "duplicate" && \
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
[ -n "$ZSH_VERSION" ] || {
# ANSI formatting function (\033[<code>m)
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
omz_f() {
[ $# -gt 0 ] || return
IFS=";" printf "\033[%sm" $*
}
# If stdout is not a terminal ignore all formatting
[ -t 1 ] || omz_f() { :; }
@jancimajek
jancimajek / rebase-master.sh
Last active October 11, 2019 14:38
Smart rebase master
#!/bin/bash
# GITS: https://gist.github.com/jancimajek/c744675a13da3357a7e9d3959b6b1d3b
echo "[git fetch]"
git fetch
NEEDS_UPDATE=$(git log HEAD..origin/master --oneline | wc -l)
if [ $NEEDS_UPDATE -eq 0 ]
then
@jancimajek
jancimajek / async-error.ts
Last active July 9, 2019 20:45
Async error handling
import debug from 'debug';
import express, { NextFunction, Request, Response } from 'express';
const testRouter = express.Router();
const delay = async (wait: number, label: string) =>
new Promise(resolve => {
debug('yncx:delay:start')({ wait, label });
setTimeout(() => {
debug('yncx:delay:end')({ wait, label });
@jancimajek
jancimajek / .eslintrc.js
Last active September 30, 2018 16:11
leveluptuts/React-Testing-For-Beginners
module.exports = {
"parser": "babel-eslint",
"env": {
"jest/globals": true,
"browser": true,
"es6": true
},
"settings": {
"ecmascript": 6,
"jsx": true
@jancimajek
jancimajek / History|-10266e64|entries.json
Last active November 10, 2022 13:37
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///Users/jan.majek/Projects/boilerplate-typescript/src/actions/download.ts","entries":[{"id":"Z0XS.ts","timestamp":1667820526418},{"id":"eGHD.ts","timestamp":1667904802020},{"id":"gU3A.ts","timestamp":1667906605037},{"id":"D2AS.ts","timestamp":1667906636984},{"id":"u9Ow.ts","timestamp":1667906783440},{"id":"dfBB.ts","timestamp":1667906812352},{"id":"zW6W.ts","timestamp":1667906921326}]}