Skip to content

Instantly share code, notes, and snippets.

View vesan's full-sized avatar

Vesa Vänskä vesan

View GitHub Profile
@chmolto
chmolto / transporter.py
Last active April 14, 2025 20:13 — forked from keshav-space/transporter.py
Migrate GitHub project between accounts
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://aboutcode.org for more information about nexB OSS projects.
#
from traceback import format_exc as traceback_format_exc
import requests
@amkisko
amkisko / solid_queue_alive.rb
Last active May 23, 2025 10:06
Rails solid_queue / solid queue alive server livenessProbe readinessProbe health check kubernetes helper
class SolidQueueAliveServer
def initialize(host: nil, port: nil, engine: nil, logger: nil)
@host = host || "0.0.0.0"
@port = port || 7433
@engine = engine || "puma"
@logger = logger || Rails.logger
end
def run!
require "rackup"
@robconery
robconery / Book.md
Last active March 8, 2026 23:03
Obsidian Bujo Templates
title {{title}}
description {{description}}
author {{author}}
created
{"DATE:YYYY-MM-DD HH:mm:ss" => nil}
updated
{"DATE:YYYY-MM-DD HH:mm:ss" => nil}

cover|150

@danielwestendorf
danielwestendorf / install.sh
Last active December 22, 2025 07:04
writebook-to-pdf
#!/bin/bash
set -e
curl -s https://gist.githubusercontent.com/danielwestendorf/cda938b1ffb0a203ec3a415079d56efa/raw/a99d03110521fb3c1a21e0412614831a96b024ea/writebook-to-pdf > /tmp/writebook-to-pdf
docker run -d -p 5001:5001 --name breezy-pdf-lite -e "DEBUG=breezy-pdf-lite:*" -e "PORT=5001" -e "PRIVATE_TOKEN=YOURSUPERSECRETTOKEN" danielwestendorf/breezy-pdf-lite:latest
echo "Try: ruby /tmp/writebook-to-pdf export https://books.37signals.com/2/the-writebook-manual"
@JonnieCache
JonnieCache / zellij_tab_title.zsh
Last active February 14, 2026 19:44
ZSH script to set the zellij tab title to the running command line, or the current directory
function current_dir() {
local current_dir=$PWD
if [[ $current_dir == $HOME ]]; then
current_dir="~"
else
current_dir=${current_dir##*/}
fi
echo $current_dir
}

Ruby: The future of frozen string literals

What is a literal?

In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.

Some examples:

7 # integer literal
@amkisko
amkisko / debug_callbacks.rb
Last active February 6, 2025 09:12
Rails ActiveRecord and ActiveSupport callbacks wrapper for collecting metrics in pair with rspec
if ENV["DEBUG_CALLBACKS"]
Rails.application.eager_load!
ActiveRecord::Callbacks::CALLBACKS.each do |callback_type|
ApplicationRecord.descendants.each do |model|
kind, name = callback_type.to_s.split("_")
chain = model.__callbacks[name.to_sym]&.send(:chain)
filtered = chain&.select { |chain_callback| chain_callback.kind == kind.to_sym }
$callbacks_counter ||= {}
$callbacks_counter[model.name] ||= {}
@amkisko
amkisko / Gemfile
Last active September 13, 2025 16:04
ActiveAdmin v4 propshaft, importmap, stimulus, tailwindcss and ActionPolicy configuration
# NOTE: partial content required for Gemfile
gem "rails"
gem "propshaft"
gem "importmap-rails"
gem "stimulus-rails"
gem "tailwindcss-rails"
gem "action_policy"
@dhh
dhh / linux-setup.sh
Last active February 18, 2026 22:50
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
@hSATAC
hSATAC / gcp-start-iap-tunnel-ssh-proxy-magic.sh
Last active July 30, 2025 00:07 — forked from netj/gcp-start-iap-tunnel-ssh-proxy-magic.sh
a nifty script for accessing with native SSH your IAP allowed Compute Engine instances
#!/usr/bin/env bash
# ~/.ssh/gcp-start-iap-tunnel-ssh-proxy-magic.sh
# a script to be used as SSH ProxyCommand to allow fully functional SSH access to any Google Cloud Compute Engine VMs allowing IAP access
#
# Author: Jaeho Shin <[email protected]>
# Created: 2022-10-31
# See also:
# - https://gist.github.com/netj/df4f9de1fefd254ab11979be7035b5d0/#readme
# - https://cloud.google.com/iap/docs/using-tcp-forwarding
#