Skip to content

Instantly share code, notes, and snippets.

View didenko's full-sized avatar
💭
I may be slow to respond.

Vlad Didenko didenko

💭
I may be slow to respond.
View GitHub Profile
@didenko
didenko / syncthing.sh
Created August 28, 2017 23:31
Enable Syncthing automatic startup on login in macOS
#!/bin/bash
#----------------------------------------------------
#
# Copyright (C) 2017 Vlad Didenko
#
# This Source Code Form is subject to the terms
# of the Mozilla Public License, v. 2.0. If a copy
# of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/
function fusr() {
[ -f "${1}" ] || return 1;
find /proc -lname "${1}" 2>/dev/null | cut -d/ -f3 | sort -nu | xargs ps -fp;
}
@didenko
didenko / lockdemo
Last active November 28, 2018 09:45
Locking daemon in bash example
#!/bin/bash
# As detailed at http://blog.didenko.com/2010/08/locking-for-daemons-in-bash.html
pidf=/tmp/$(basename ${0}).pid
exec 221>${pidf}
flock --exclusive --nonblock 221 ||
{
echo "Another instance is apparently running."
exit 1
@didenko
didenko / timein.sh
Last active November 11, 2018 04:32
Cross-timezone calculations
function timein ()
{
[ "${#}" -lt 3 ] && {
echo 'timein <dest loc> [when] <src loc> [is] <src time>' 1>&2
echo -e 'e.g.:\ntimein America/Chicago when Europe/Berlin is tomorrow 14:30' 1>&2
echo -e 'or:\ntimein Asia/Ho_Chi_Minh America/New_York 2019/01/02 08:00' 1>&2
return 1
}
dest=${1}; shift
@didenko
didenko / yubikey_install.sh
Last active January 21, 2018 23:50
Yubikey on openSUSE
sudo zypper install u2f-server u2f-host pam_u2f ykclient
package main
import (
"fmt"
"log"
"github.com/pkg/errors"
)
type HTTPError struct {
package main
import (
"fmt"
"log"
"github.com/pkg/errors"
)
type HTTPError struct {
@didenko
didenko / .bash_profile
Last active December 21, 2017 17:27
BASH profile
alias l="ls -AFGhlO "
alias ll="ls -alFgeh "
alias lll="ls -alFgeh@@ "
alias hig="history | grep "
alias less="less -i -~ "
alias ci="vi "
alias bb="bbedit"
alias gdc="godoc -http=:6060; open \"http:\\\\localhost:6060\\\""
function lg(){
@didenko
didenko / CLA.md
Last active December 13, 2017 14:10
CLA

Preamble

This Contributor License Agreement is a derivative from the GitHub, Inc's version 298f3afd updated August 9, 2017, copied and modified under the individually granted CC-BY-4.0 terms on November 14, 2017.

Contributor License Agreement

The following terms are used throughout this agreement:

  • You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it.

The license file referred to in this Developer Certificate of Origin is the LICENSE.md file located in the root directory of this project's repository.

Developer Certificate of Origin

Version 1.1

Copyright © 2004, 2006 The Linux Foundation and its contributors.

1 Letterman Drive