Skip to content

Instantly share code, notes, and snippets.

View kaspergrubbe's full-sized avatar

Kasper Grubbe kaspergrubbe

View GitHub Profile
@kaspergrubbe
kaspergrubbe / jemalloc5.rb
Created July 26, 2022 18:47
Tuning Jemalloc 5
# Inspiration: https://twitter.com/wgjordan/status/1440574986264006659
jemalloc_conf = {
# Maximum number of arenas to use for automatic multiplexing of threads and arenas.
# The default is four times the number of CPUs, or one if there is a single CPU.
narenas: 2,
# Enabling jemalloc background threads generally improves the tail latency for application threads,
# since unused memory purging is shifted to the dedicated background threads.
# In addition, unintended purging delay caused by application inactivity is avoided with background threads.
require "socket"
require "openssl"
class TlsCheckJob
include Sidekiq::Worker
def perform
domains = Domain.all.map(&:domain_name)
(domains).each do |org_domain|
+ ./configure --build=x86_64-linux-gnu --disable-install-doc --enable-shared --with-jemalloc
checking for ruby... /usr/bin/ruby
tool/config.guess already exists
tool/config.sub already exists
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
@kaspergrubbe
kaspergrubbe / calculate_backoff.rb
Last active October 31, 2018 14:55
Calculate Redis-rb backoff and print a nice table
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'markdown-tables', '1.0.2'
end
attempts = ARGV[0].to_i
reconnect_delay = ARGV[1].to_f
reconnect_delay_max = ARGV[2].to_f
{
"red": {
"50": "#ffebee",
"100": "#ffcdd2",
"300": "#e57373",
"500": "#f44336",
"700": "#d32f2f",
"800": "#c62828",
"900": "#b71c1c"
},
#!/bin/bash
set -euxo pipefail
LABEL maintainer="docker@kaspergrubbe.com"
REPOOWNER="kaspergrubbe"
REPONAME="grubruby-jemalloc"
VERSION="2.5.1"
echo "Building and pushing ${REPOOWNER}/${REPONAME} version ${VERSION}" \
#!/bin/bash
while true; do
FILENAME=$(date +%s)
openssl rand -out $(echo $FILENAME).bin -base64 $(( 2**30 * 3/4 ))
curl -T $(echo $FILENAME).bin ftp://ftp.example.com --user user:password
rm $(echo $FILENAME).bin
done
<iframe allowtransparency="true" data-event-id="192964" frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="true" src="javascript:void(0)" vspace="0" width="100%" height="189" id="billetto_tickets_widget_embed_192964"></iframe><div class="js-event-widget-powered-by" style="overflow: hidden!important;margin-top: 5px!important;margin-bottom: 5px!important">
<a href="https://billetto.dk/l/saelg-billetter-online" style="line-height: 18px!important;font-size: 10px!important;important;color: #666!important;" target="_blank">
<img alt="Billetto" height="18" src="https://assets.billetto.com/assets/logos/logo_text_dark.fallback-240dc3b964adf73b857a290b10e8070bbf018a4f18747af4ae1d328dd1ffa617.png" style="float: right!important;line-height: 18px!important;height: 18px!important;width: 60px!important;margin-left: 5px!important;display: block!important;outline: none!important;border : 0!important;" width="60">
<span style="float: right!important;font-family: sans-serif!important;">Powered by</span>
</a>
@kaspergrubbe
kaspergrubbe / geonames_postgres.rb
Last active September 2, 2024 04:30
Import files from Geonames.com into a PostgreSQL database that runs Postgis
#!/usr/bin/env ruby
require 'open3'
require 'fileutils'
def run_command(command)
puts("+: " + command)
Open3.popen2e(command) do |stdin, stdout_stderr, wait_thread|
Thread.new do
stdout_stderr.each {|l| puts l }
@kaspergrubbe
kaspergrubbe / build_termite_and_vte.sh
Created February 3, 2017 03:08
Build termite terminal and vte/vte-ng on Ubuntu
# VTE
apt-get install autoconf libglib2.0-dev gtk-doc-tools libpcre2-dev libgirepository1.0-dev gperf libvte-2.91-dev libvte-dev valac unzip
wget https://github.com/thestinger/vte-ng/archive/0.46.0.a.zip
unzip 0.46.0.a.zip
rm 0.46.0.a.zip
cd vte-ng-0.46.0.a
bash autogen.sh
make && make install
cd ~
rm -rf vte-ng-0.46.0.a/