Skip to content

Instantly share code, notes, and snippets.

Tamás Michelberger tmichel

View GitHub Profile
@tmichel
tmichel / project-template.sublime-project
Created Dec 1, 2019
Sublime Text 3 Rails+Rspec project config template
View project-template.sublime-project
{
"folders":
[
{
"path": "/path/to/project",
"folder_exclude_patterns": [
".vscode",
"tmp",
"vendor/bundle",
"log"
@tmichel
tmichel / exif.go
Created Apr 10, 2019
Extract Exif info from an image
View exif.go
package main
import (
"bufio"
"bytes"
"encoding/binary"
"errors"
"io"
)
View keybase.md

Keybase proof

I hereby claim:

  • I am tmichel on github.
  • I am tmichel (https://keybase.io/tmichel) on keybase.
  • I have a public key ASA8sv-0DFsLtpoBSeIrahfwWt3A1_VRicx0sQBktUYZcwo

To claim this, I am signing this object:

@tmichel
tmichel / disable-shift-augmentation.sh
Created Jan 24, 2018
Disable annoying shift augmentation for ctrl+up and ctrl+down on macOS
View disable-shift-augmentation.sh
/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 Jan 17, 2018
Abbreviated path: keeping first letter of parent dirs
View abbrev-path.sh
#!/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 Dec 29, 2017
Very simple table_for and attribute_table_for for Rails
View table_helper.rb
# 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 Sep 1, 2017
List files on the classpath with guava Resources
View Fixtures.java
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 Aug 28, 2017
Schema validation example
View Main.java
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;
View bash_cheatsheet.md

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+:
@tmichel
tmichel / search-engine.js
Created May 2, 2017
Mass remove Chrome search engines.
View search-engine.js
document.querySelectorAll('#other-search-engine-list > div.deletable-item').forEach(function(el) {
var url = el.querySelector('.url-column div.static-text');
if (url && ( url.textContent.match(/\.blog\.hu/) || url.textContent.match(/wordpress\.com/) )) {
console.log(url.textContent);
var button = el.querySelector('.row-delete-button');
if (button) {
button.click(button);
}
}
})
You can’t perform that action at this time.