Skip to content

Instantly share code, notes, and snippets.

View kaspergrubbe's full-sized avatar

Kasper Grubbe kaspergrubbe

View GitHub Profile
@kaspergrubbe
kaspergrubbe / geonames_postgres.rb
Last active April 4, 2024 08:12
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 }
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | gdisk /dev/sda
n # new partition
1 # partition number 1
2048 # first sector
4095 # end sector
ef02 # BIOS boot partition
n # new partition
2 # partition number 2
4096 # first sector
1028095 # end sector
@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.
@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/
{
"red": {
"50": "#ffebee",
"100": "#ffcdd2",
"300": "#e57373",
"500": "#f44336",
"700": "#d32f2f",
"800": "#c62828",
"900": "#b71c1c"
},
@kaspergrubbe
kaspergrubbe / install-graphite-ubuntu-13.04.sh
Last active October 4, 2020 11:53 — forked from jgeurts/install-graphite-ubuntu-12.04.sh
Don't overwrite the local_settings.py
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 16. June 2013
####################################
# This is apparantly needed for python when running manage.py
# described here: http://stackoverflow.com/questions/11593556/django-createsuperuser-not-working
export LANG=en_US.UTF-8
<?php
# Insert code here
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