Skip to content

Instantly share code, notes, and snippets.

View tmichel's full-sized avatar

Tamás Michelberger tmichel

View GitHub Profile
@tmichel
tmichel / index.html
Created November 9, 2013 22:07
simple websocket example with golang
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<div>
<form>
<label for="numberfield">Number</label>
<input type="text" id="numberfield" placeholder="12"/><br />
@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 / email_test.go
Created October 12, 2014 11:58
Sending and testing email in Go -- appendix
package email
import (
"net/smtp"
"testing"
)
type EmailConfig struct {
Username string
Password string
@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+:
@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) {
func rangeOf(from, to int) []int {
if from > to {
return nil
}
result := make([]int, to-from)
for i := 0; i < to-from; i++ {
result[i] = i + from
}
return result
}
@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 / constant_lookup.rb
Created July 6, 2015 14:14
Rails constant lookup WTF
# Rails autoloading constant functionality is useful until it's not.
# Every class is placed in the right file on the right path.
# in app/models/users/serializer.rb
module Users
class Serializer
#...
end
end