Skip to content

Instantly share code, notes, and snippets.

View klappradla's full-sized avatar

Max Mulatz klappradla

View GitHub Profile
@klappradla
klappradla / debugging_in_jruby.md
Last active March 22, 2024 12:10
Debugging in JRuby

Debugging in JRuby

Step-by-step debugging and stack navigation for JRuby code.

Problem: the common tools byebug and pry-byebug are MRI-only.

Prerequisites

Force JRuby to run in fully interpreted mode:
(otherwise next would behave like step)

@klappradla
klappradla / lame.sh
Last active December 10, 2022 20:02
Using lame command line tool (e.g. convert flac to mp3
# Convert .flac to .mp3 (lossless)
for f in *.flac; do ffmpeg -i "$f" -aq 1 "${f%flac}mp3"; done
# Convert .flac to .mp3, compress to ~ 120k
for f in *.flac; do ffmpeg -i "$f" -aq 5 "${f%flac}mp3"; done
# Convert .flac to mp3, compress to ~ 128k
for f in *.flac; do ffmpeg -i "$f" -b:a 128k "${f%flac}mp3"; done
# Convert .flac to mp3, compress to variable 190k
@klappradla
klappradla / downgrade_tmux.md
Last active June 17, 2022 07:40
Downgrade homebrew's tmux to 2.9a

Downgrade tmux installed via homebrew to v 29.a.

Uninstall current version and install from the old formula:

brew uninstall tmux
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c8cff106b17b90472cc6e251b9e5c2daf4fd8d46/Formula/tmux.rb

Pin the version to prevent it from accidental upgrades:

@klappradla
klappradla / post-deploy.yml
Created November 27, 2015 12:12
Rake tasks as post deploy hooks for AWS Elastic Beanstalk Puma-Rails applications
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/01_do_stuff.sh" :
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#! /usr/bin/env bash
# Using similar syntax as the appdeploy pre hooks that is managed by AWS
set -xe
@klappradla
klappradla / np_example.sh
Created May 14, 2020 22:38
Minimal example to explore custom versions problem with np
#!/bin/sh
set -o errexit
set -o nounset
# Create directory
mkdir example && cd example
# Initialize Git repository
git init && git commit --allow-empty -m "init commit"
@klappradla
klappradla / postgres_4_2.md
Last active February 13, 2020 21:58
Install Postgres 9.4 and Postgis 2.1 server on EC2 Ubuntu instance (14.04)

Create Postgres / Postgis Server EC2 Box

Launch Ubuntu instance

  1. Click on Launch Instance` button
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type
  3. Configure Security Group
    In step 6 Configure Security Group add the rule:
    Type: PostgreSQL
    Protocol: TCP
    PortRange: 5432 (default postgres port)
@klappradla
klappradla / validation_example.rb
Created August 6, 2017 12:00
Single file rails app to illustrate acceptance only validations
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@klappradla
klappradla / procs_vs_lambdas.md
Last active October 21, 2016 21:27
Procs vs. Lambdas (example)

Procs vs. Lambdas

Seem the same:

[1] pry(main)> pr = proc { p "Hi" }
=> #<Proc:0x007fdc7a1398f0@(pry):8>
[2] pry(main)> lam = -> { p "Hi" }
=> #<Proc:0x007fdc79c53110@(pry):9 (lambda)>
[3] pry(main)> pr.class
@klappradla
klappradla / homebrew_fix_updates.sh
Created September 20, 2016 16:47
Reset Homebrew if updates are no longer working
cd `brew --prefix`
git fetch origin
git reset --hard origin/master
@klappradla
klappradla / docker.sh
Last active August 21, 2016 11:00
Stop and remove all Docker containers (running or not), interactive console in container
# Stop and remove all docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# Run an interative console (like byebug or pry)
docker-compose run --service-ports appname