Skip to content

Instantly share code, notes, and snippets.

How to install WireGuard

Server

Ubuntu 18.04.4 LTS

$ sudo add-apt-repository ppa:wireguard/wireguard
$ sudo apt update
$ sudo apt install wireguard

$ wg genkey | tee privatekey | wg pubkey > publickey

Back up a Docker volume

To another volume

$ docker volume create --name <target>
$ docker run --rm -v <source>:/from -v <target>:/to alpine /bin/sh -c 'cp -av /from/* /to'

To an archive file

$ docker run --rm -v :/from -v $(pwd):/to alpine /bin/sh -c 'tar -czvf /to/.tar.gz . -C /from'

# Returns a hash result from applying the transform function to
# its keys and values.
#
# The transform function must accept 2 arguments (key, value) and
# return a hash. Given a nested hash, the function must conditionally
# handle non-atomic value.
#
# transform = lambda { |k, v| { k.succ => v.is_a?(Integer) ? v + 1 : v } }
#
def deep_transform(hash, transform)
#
# Example .tmux.conf
#
# By Nicholas Marriott. Public domain.
#
# Some tweaks to the status line
# set -g status-right "%H:%M"
# set -g window-status-current-attr "underscore"
% ? + ? = 8
% + +
% ? - ? = 6
% = =
% 13 8
var 0.0..9.9: A;
var 0.0..9.9: B;
var 0.0..9.9: C;
var 0.0..9.9: D;
config.log_level = :info
config.log_tags = [:remote_ip]
if defined?(Rails::Console)
config.logger = Logger.new('/dev/null')
config.after_initialize { ActiveRecord::Base.logger.level = 0 }
else
config.log_formatter = Logger::Formatter.new
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
// ==UserScript==
// @name mac2hand
// @namespace wulab
// @include http://www.mac2hand.com/*
// @version 1
// @grant none
// ==/UserScript==
var merchants = [
'Asree.BKKApple',
@wulab
wulab / sunflower.py
Last active December 11, 2016 16:58
from time import sleep
from turtle import *
def rhombus(direction, size):
setheading(direction)
for angle in [35, 145, 35, 145]:
forward(size)
left(angle)
$ RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.3.1
$ rbenv global 2.3.1
$ gem install rails --prerelease
$ gem install ruby-debug-ide
$ gem install debase