Skip to content

Instantly share code, notes, and snippets.

View hrasekj's full-sized avatar
🕸️
Web developer!

Jakub Hrášek hrasekj

🕸️
Web developer!
View GitHub Profile
@yarlson
yarlson / README.md
Created October 23, 2024 16:42
Docker Image Sync Script

Docker Image Sync Script

Direct host-to-host Docker image transfer utility that preserves layer caching without requiring a registry. Useful for transferring locally built images to remote hosts while maintaining Docker's layer efficiency.

Features

  • Preserves layer caching by transferring only missing layers
  • Parallel blob transfer with SSH optimization
  • No registry required

Usage

@Diaoul
Diaoul / monitors.sh
Last active February 12, 2025 15:01
Arrange workspace on multiple monitors (Hyprland)
#!/usr/bin/env bash
set -e
declare -i last_called=0
declare -i throttle_by=4
@throttle() {
local -i now=$(date +%s)
if (($now - $last_called > $throttle_by))
then
@JacobWeisenburger
JacobWeisenburger / makeSearchParamsObjectSchema.ts
Last active April 19, 2025 19:41
a way to parse URLSearchParams with Zod
import { z } from 'zod'
function safeParseJSON ( string: string ): any {
try { return JSON.parse( string ) }
catch { return string }
}
function searchParamsToValues ( searchParams: URLSearchParams ): Record<string, any> {
return Array.from( searchParams.keys() ).reduce( ( record, key ) => {
const values = searchParams.getAll( key ).map( safeParseJSON )
@marklawlor
marklawlor / kysely-types.ts
Last active August 3, 2023 19:29
Prisma/Kysely database
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { Prisma, PrismaClient, PrismaPromise } from "@prisma/client";
import type { CamelCase, Merge, SnakeCase, PascalCase } from "type-fest";
import {
ColumnType,
DummyDriver,
Generated,
Kysely,
MysqlAdapter,
@quangdinh
quangdinh / gammastep.sh
Last active March 26, 2025 17:01
Sway / Waybar / Wofi / Swaylock config & styles
#!/usr/bin/env bash
pid=$(pgrep gammastep)
if [[ $1 = "toggle" ]]; then
if pgrep -x "gammastep" > /dev/null; then
kill -9 $(pgrep -x "gammastep");
else
gammastep -O ${GAMMASTEP_NIGHT:-3500} &
fi
@jfcherng
jfcherng / st4-changelog.md
Last active August 18, 2024 07:25
Sublime Text 4 changelog just because it's not on the official website yet.
@samthor
samthor / code.js
Last active July 18, 2022 11:02
Async cancellable promises
// nb. This code is available in an ES module of Promise helpers, here:
// https://github.com/samthor/promises
// symbol returned to indicate that a call was cancelled
export const takeoverSymbol = Symbol('takeover');
/**
* Accepts a generator function, which yields Promises, and converts it to an async function
* that cancels any previous calls.
*/
@wellcaffeinated
wellcaffeinated / RXJS Observable from mongoose (mongodb) cursor.js
Created May 30, 2018 21:35
Rx.Observable that can sequentially pull data from a mongoose (mongodb) cursor with fine control over concurrency
const Rx = require( 'rxjs/Rx' );
// This took me way too long to figure out. Hope this helps someone.
// <3 Well Caffeinated
function fromCursor( cursor ){
return new Rx.Observable((obs) => {
// is the connection closed
var closed = false
// get the next document
@Rich-Harris
Rich-Harris / service-workers.md
Last active May 3, 2025 12:49
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@sphvn
sphvn / traverse.js
Last active October 26, 2023 21:49
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
var traverse = function(o, fn) {
for (var i in o) {
fn.apply(this,[i,o[i]]);
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
}
}
}
// usage