Skip to content

Instantly share code, notes, and snippets.

@maierru
maierru / gpu_passthrough.sh
Created August 13, 2024 12:59
GPU Passthrough proxmox setup
#!/bin/bash
# https://www.reddit.com/r/homelab/comments/b5xpua/the_ultimate_beginners_guide_to_gpu_passthrough/
# intel based script
apt-get update
apt-get upgrade -y
echo "current value of GRUB_CMDLINE_LINUX_DEFAULT"
@maierru
maierru / client_example
Created November 8, 2019 23:42 — forked from sandro/client_example
Ruby select socket server. An example of a single-threaded, event-driven (select) server.
$ irb -r ./select_server
>> client.puts "hi"
=> nil
>> client.puts "bye"
=> nil
>> client.close
=> nil
>> exit
@maierru
maierru / clear-sidekiq-jobs.sh
Created April 15, 2019 07:35 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
@maierru
maierru / freebsd.txt
Created January 14, 2019 13:23
mac os x bash last day of each month
$ for i in {1..12}; do date -v1d -v-1d -v-${i}m +%Y-%m-%d; done
2018-11-30
2018-10-31
2018-09-30
2018-08-31
2018-07-31
2018-06-30
2018-05-31
2018-04-30
2018-03-31
@maierru
maierru / gist:c6cffec05574fb2c0ed354348997fdfa
Created December 11, 2018 12:17
mac os background notification in the ssh session
sleep 10 && echo -en "\007"
@maierru
maierru / line_count_benchmark.rb
Created August 17, 2018 14:24 — forked from guilhermesimoes/line_count_benchmark.rb
Ruby Benchmark: Counting the number of lines of a file
# gem install benchmark-ips
require "benchmark/ips"
path = "lib/rubycritic/cli/options.rb"
Benchmark.ips do |x|
x.report("read + each_line") { File.read(path).each_line.count }
x.report("open + each_line") { File.open(path, "r").each_line.count }
@maierru
maierru / table_info.sql
Created August 6, 2018 15:39
postgresql table info sql
SELECT l.what, l.nr AS "bytes/ct"
, CASE WHEN is_size THEN pg_size_pretty(nr) END AS bytes_pretty
, CASE WHEN is_size THEN nr / x.ct END AS bytes_per_row
FROM (
SELECT min(tableoid) AS tbl -- same as 'public.tbl'::regclass::oid
, count(*) AS ct
, sum(length(t::text)) AS txt_len -- length in characters
FROM public.write_a_table_name_instead t -- provide table name *once*
) x
, LATERAL (
@maierru
maierru / accounting.sql
Created February 6, 2018 09:20 — forked from RichardKnop/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@maierru
maierru / signals.go
Created January 19, 2018 15:32
go systems signals handler
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
@maierru
maierru / OTP
Last active December 13, 2019 13:10
Phoenix (elixir) highload optimization
# Move erts IO Polling to dedicated threads
# https://github.com/erlang/otp/pull/1552