Skip to content

Instantly share code, notes, and snippets.

@lalyos
lalyos / Dockerfile
Last active December 4, 2017 07:43
docker neovim golang dev setup
FROM golang:alpine
RUN apk add -U \
bash \
git \
neovim
CMD ["bash", "--login"]
@lalyos
lalyos / README.md
Last active November 23, 2017 20:01
go-get test

Custom Domain name in golang importpath

https://golang.org/cmd/go/#hdr-Remote_import_paths

There are well-known code repositories and there associated golang ImportPath:

  • github.com/user/project -> Github (git)
  • launchpad.net/project -> LaunchPad (bazaar)
  • bitbucket.org/user/project -> BitBucket (git/mercurial)

If your ImportPath starts with your custom domain, like "example.com/mypkg" then the go tool will

@lalyos
lalyos / README.md
Last active January 29, 2018 21:52
glide version fix hack

Glide utils

Replace a glide locked version for a package:

fix-glide () 
{ 
    repo=${1:?required repo};
    version=${2:?required version};
    sed -i "/${repo}/ {n;s/: .*$/: ${version}/;}" glide.lock
}
@lalyos
lalyos / go-list.md
Last active November 8, 2017 14:58
go list tricks

Find go package:

god(){ go list -f '{{.Dir}}' -e .../${1:?required go package} 2>/dev/null; }

Find missing dependencies:

go get -v -d $(go list -f '{{range .DepsErrors}}{{join .ImportStack ":"|println }}{{end}}' | sed "s/.*://")
@lalyos
lalyos / vim-setup.sh
Last active September 11, 2017 10:58
vim setup
# solarized-colors https://github.com/altercation/vim-colors-solarized
curl -fLo ~/.vim/colors/solarized.vim --create-dirs https://raw.githubusercontent.com/altercation/vim-colors-solarized/master/colors/solarized.vim
cat >> ~/.vimrc <<EOF
syntax enable
set background=dark
colorscheme solarized
EOF
@lalyos
lalyos / README.md
Last active May 7, 2017 11:48
Iban verifier in bash

For reference see: https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN

Let the bank account (in ΙΒΑΝ format): GR1601101250000000012300695

  • The first four characters “GR16” are moved to the end of the number, so the account number becomes 01101250000000012300695GR16.
  • The letters are translated into numbers, according to the following table, so the account number becomes 01101250000000012300695162716.
  • Interpret the string as a decimal integer and compute the remainder of that number on division by 97

Hungarian IBAN verification

HU<2 digits check> <12digits account num>

@lalyos
lalyos / debounce.lua
Created March 20, 2017 17:44 — forked from marcelstoer/debounce.lua
Debounce with NodeMCU with two separate functions for down/up trigger
-- inspired by: http://www.esp8266-projects.com/2015/03/buttons-pushbuttons-and-debouncing-story.html
local GPIO14 = 5
local debounceDelay = <however-many-ms-your-sensor-requires>
local debounceAlarmId = <0-6>
gpio.mode(GPIO14, gpio.INT, gpio.PULLUP)
gpio.trig(GPIO14, "down", doorLocked)
function doorLocked()
-- don't react to any interupts from now on and wait 50ms until the interrupt for the up event is enabled
-- within that 50ms the switch may bounce to its heart's content
@lalyos
lalyos / debounce-with-tmr.lua
Created March 20, 2017 17:44 — forked from marcelstoer/debounce-with-tmr.lua
NodeMCU debounce based on timer with GPIO pullup
-- inspired by https://github.com/hackhitchin/esp8266-co-uk/blob/master/tutorials/introduction-to-gpio-api.md
-- and http://www.esp8266.com/viewtopic.php?f=24&t=4833&start=5#p29127
local pin = 4 --> GPIO2
function debounce (func)
local last = 0
local delay = 50000 -- 50ms * 1000 as tmr.now() has μs resolution
return function (...)
local now = tmr.now()
@lalyos
lalyos / README.md
Last active June 12, 2018 18:08
encrypted usb for ssh keys

Store your ssh private keys on an encrypted usb drive!

Format USB

You have to erase it twice Use DiskUtility:

    1. Erase with format: OS X Extendes (Journaled) and GUID Partition Map scheme
    1. Erase with format: OS X Extendes (Case-sensitive, Journaled, Encrypted) and GUID Partition Map scheme

Create rsa key on USB

@lalyos
lalyos / keybase.md
Created February 13, 2017 19:42
keybase proof

Keybase proof

I hereby claim:

  • I am lalyos on github.
  • I am lalyos (https://keybase.io/lalyos) on keybase.
  • I have a public key whose fingerprint is 86B0 8FDE D682 B0F6 B5E3 5A4C 90C9 D18C C812 6B0E

To claim this, I am signing this object: