Skip to content

Instantly share code, notes, and snippets.

View tmichel's full-sized avatar

Tamás Michelberger tmichel

View GitHub Profile
@tmichel
tmichel / aws.fish
Created October 11, 2022 18:57
fish completions for awscli
function __fish_complete_aws
env COMP_LINE=(commandline -pc) aws_completer | tr -d ' '
end
complete -c aws -f -a "(__fish_complete_aws)"
@tmichel
tmichel / databricks.fish
Created October 11, 2022 18:40
fish shell completion for databricks-cli
# Put this in ~/.config/fish/completions
function __fish_complete_databricks
set -l cl (commandline -pc)
set -l help_command (echo $cl | sed 's/[[:alnum:]-]*$/--help/')
if string match -r -- '--?\w*' $cl
# complete options
eval $help_command \
| sed -e '1,/Options:/ d' -e '/Commands:/,$ d' \
@tmichel
tmichel / project-template.sublime-project
Created December 1, 2019 11:24
Sublime Text 3 Rails+Rspec project config template
{
"folders":
[
{
"path": "/path/to/project",
"folder_exclude_patterns": [
".vscode",
"tmp",
"vendor/bundle",
"log"
@tmichel
tmichel / exif.go
Created April 10, 2019 19:14
Extract Exif info from an image
package main
import (
"bufio"
"bytes"
"encoding/binary"
"errors"
"io"
)
@tmichel
tmichel / disable-shift-augmentation.sh
Created January 24, 2018 14:48
Disable annoying shift augmentation for ctrl+up and ctrl+down on macOS
/usr/libexec/PlistBuddy -c "set AppleSymbolicHotKeys:34:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "set AppleSymbolicHotKeys:35:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "set AppleSymbolicHotKeys:37:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
# 34 and 35 might not exists. Add them.
/usr/libexec/PlistBuddy -c "add AppleSymbolicHotKeys:34:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "add AppleSymbolicHotKeys:35:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
# Restart your computer. Log out then log in did not work for me.
@tmichel
tmichel / abbrev-path.sh
Last active January 17, 2018 09:34
Abbreviated path: keeping first letter of parent dirs
#!/bin/sh
# Print $PWD where parent directories are abbreviated to their first letters.
# $HOME is replaced with ~.
# Based on: https://unix.stackexchange.com/a/26885
sed -e "s:$HOME:~:" -e 's:\([^/]\)[^/]*/:\1/:g' <<<$PWD
# PWD=/home/me/foo/bar/baz
# => ~/f/b/baz
@tmichel
tmichel / table_helper.rb
Last active December 29, 2017 11:23
Very simple table_for and attribute_table_for for Rails
# Drop this into app/helpers and then in your views:
#
# <%= table_for(User.all) do |t| %>
# <% t.column :username %>
# <% t.column :email do |user| %>
# <%= mail_to user.email %>
# <% end %>
# <% t.actions :show, :edit %>
# <% end %>
#
@tmichel
tmichel / Fixtures.java
Created September 1, 2017 15:13
List files on the classpath with guava Resources
public static List<String> getFiles() {
String fixturesRoot = Resources.getResource("fixtures").getPath();
final Path fixturesRootPath = Paths.get(fixturesRoot);
try {
return Files.walk(fixturesRootPath)
.filter(Files::isRegularFile)
.map(path -> fixturesRootPath.relativize(path).toString())
.collect(Collectors.toList());
} catch (IOException e) {
@tmichel
tmichel / Main.java
Created August 28, 2017 18:09
Schema validation example
package io.sspinc.validator.example;
import io.sspinc.validator.Schema;
import io.sspinc.validator.ValidationErrors;
import static io.sspinc.validator.Validators.allowNull;
import static io.sspinc.validator.Validators.inclusion;
import static io.sspinc.validator.Validators.length;
import static io.sspinc.validator.Validators.presence;
@tmichel
tmichel / bash_cheatsheet.md
Created June 16, 2017 12:57
Bash cheat sheet

Shell cheat sheet

Setting up iTerm

  • Use option as meta key:

Go to Preferences->Profiles tab. Select your profile on the left, and then open the Keyboard tab. At the bottom is a set of buttons that lets you select the behavior of the Option key. For most users, Esc+ will be the best choice.

  • Setting up word-by-word movement with Option+: