Skip to content

Instantly share code, notes, and snippets.

View mfilej's full-sized avatar

Miha Filej mfilej

View GitHub Profile
#!/usr/bin/env bash
set -euo pipefail
secret=$(aws secretsmanager list-secrets | jq -r '.SecretList | .[].ARN' | fzf)
if [ -z "$secret" ]; then
exit
fi
@mfilej
mfilej / better-git-branch.sh
Last active March 15, 2024 16:05 — forked from schacon/better-git-branch.sh
Better Git Branch output
#!/usr/bin/env bash
# From: https://gist.github.com/schacon/e9e743dee2e92db9a464619b99e94eff
#
# Changelog:
#
# - 2024-03-15: Also output current branch
# Colors
RED='\033[0;31m'
#!/usr/bin/env bash
set -e
usage() {
echo "Usage: gh dependabot <merge|rebase> <pull-request-number>"
echo
echo "Will tell dependabot to merge by commenting on the given pull request number."
}
action="$1"
@mfilej
mfilej / backup.yml
Created January 21, 2023 16:35
Back up a Fly.io Postgres database to S3 using GitHub Actions
name: Back up database
run-name: Task
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
jobs:
backup:
runs-on: ubuntu-latest
env:
@mfilej
mfilej / db_terminate_backend.rake
Created July 7, 2013 11:02
Rake task to terminate idle postgresql connections that prevent a database to be dropped
# http://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection
namespace :db do
desc "Fix 'database is being accessed by other users'"
task :terminate => :environment do
ActiveRecord::Base.connection.execute <<-SQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
@mfilej
mfilej / kent-beck-mastering-programming.md
Created June 19, 2018 07:24
Kent Beck: Mastering Programming

Mastering Programming

[Source][].

From years of watching master programmers, I have observed certain common patterns in their workflows. From years of coaching skilled journeyman programmers, I have observed the absence of those patterns. I have seen what a difference introducing the patterns can make.

Here are ways effective programmers get the most out of their precious 3e9 seconds on the planet.

The theme here is scaling your brain. The journeyman learns to solve bigger problems by solving more problems at once. The master learns to solve even bigger problems than that by solving fewer problems at once. Part of the wisdom is subdividing so that integrating the separate solutions will be a smaller problem than just solving them together.

@mfilej
mfilej / Readme.md
Last active November 5, 2021 09:16
RSpec hook to show current spec in process name

Our suite would sometimes randomly hang when running a certain spec, but we weren't able to tell which one. With the below RSpec around filter you can see the spec that is currently running by inspecting the process name.

$ rspec spec_spec.rb &
[2] 64968
$ ps | grep rspec
64968 ttys005    0:00.24 rspec /Users/miha/spec_spec.rb:10 "Dummy spec waits for 100 seconds"
@mfilej
mfilej / youtube.applescript
Created February 6, 2015 21:54
Open YouTube video in current tab with QuickTime
tell application "Safari"
set youtubeURL to URL of current tab of window 1
end tell
-- set format to item 1 of (choose from list {"22/18", "18"})
set format to "22/18"
set youtubeCmd to "/usr/local/bin/youtube-dl -g -f " & format & " --no-playlist '" & youtubeURL & "'"
set videoURL to do shell script youtubeCmd
tell application "QuickTime Player" to open URL videoURL
tap 'homebrew/cask-fonts'
cask 'font-fira-code'
cask 'font-ibm-plex-mono'
cask 'font-source-code-pro'
cask 'font-monoid'
cask 'font-hack'
cask 'font-iosevka'
cask 'font-jetbrains-mono'
cask 'font-fantasque-sans-mono'
@mfilej
mfilej / Info.plist
Created January 16, 2012 10:13
Make Safari open links from other applications in current space
<key>CFBundleIdentifier</key>
<string>com.apple.AppleScript.SafariURLHelper</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>SafariURLHelper</string>
<key>CFBundleURLSchemes</key>
<array>
<string>http</string>