Skip to content

Instantly share code, notes, and snippets.

View perguth's full-sized avatar
🎈

Per Guth perguth

🎈
View GitHub Profile
@perguth
perguth / nano
Last active May 26, 2022 13:33
⏲️📝 Back ups every file that gets touched by `nano`.
#!/bin/sh
# Back ups every file that gets touched by `nano`.
# Install by:
# 1. `sudo mv /bin/nano /bin/nano-real`
# 2. Put this file in `/usr/local/bin` and make it executable.
# 3. Set your user:
backupFolder=$HOME/.system-changes
currentFolder=$(pwd)
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
export PATH="$PATH:`yarn global bin`"
export MOSH_TITLE_NOPREFIX=1
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
export PATH=$PATH:~/.cargo/bin
@perguth
perguth / index.html
Last active August 16, 2019 14:56
Some website starter.
<!doctype html>
<title>My website</title>
<!-- Validate your own here: https://validator.w3.org/ -->
<main>
<h1>My website</h1>
<p>Some texts.</p>
</main>
@perguth
perguth / computer
Last active July 23, 2019 14:01
Sleep host when Mosh is idle. Wake up on reconnect.
#!/bin/sh
wake-computer
echo 🚀 Connecting Mosh.
mosh [email protected]
// https://github.com/cjdelisle/cjdns/blob/77259a49e5bc7ca7bc6dca5bd423e02be563bdc5/doc/proxying.md
function FindProxyForURL(url, host) {
// If we can't resolve this means that this host is IPv4 only. Trying cjdns won't hurt.
// It also make IPv4 only hosts connect ot clearnet IPv6 hosts if proxy is IPv6 capable.
// If we can resolve check if the host is insice cjdns network space.
if (shExpMatch(host, "fc*:*") || !dnsResolve(host) || shExpMatch(dnsResolve(host), "fc*:*")) {
return "SOCKS5 localhost:8080";
}
return "DIRECT";
#!/bin/bash
# Source: https://superuser.com/a/1030779
# standard sshd config path
SSHD_CONFIG=/etc/ssh/sshd_config
# helper functions
function tablize {
awk '{printf("| %-7s | %-7s | %-47s |\n", $1, $2, $3)}'
@perguth
perguth / choo-test.js
Last active August 2, 2016 18:02
Playing around with Yoshs Choo.
const choo = require('choo')
const app = choo()
app.model({
state: { title: 'Set the title' },
reducers: {
update: (action, state) => ({ title: action.value })
},
subscriptions: [
(send) => setInterval(() => {send('print', { payload: 'dog?' })}, 1000)
@perguth
perguth / hyperlog-test.js
Last active August 2, 2016 18:02
Playing around with Mafintoshs Hyperlog.
var hyperlog = require('hyperlog')
var levelup = require('levelup')
var steed = require('steed')
var db1 = levelup('./db1', { db: require('memdown') })
var db2 = levelup('./db2', { db: require('memdown') })
var db3 = levelup('./db3', { db: require('memdown') })
var log1 = hyperlog(db1)
var log2 = hyperlog(db2)
/*
A proper divisor of a positive integer n is any divisor
of n other than n itself.
A number n is called deficient if the sum of its proper
divisors is less than n and it is called abundant if
this sum exceeds n.
As 12 is the smallest abundant number,
1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be
@perguth
perguth / .htaccess
Last active October 7, 2024 10:34
Apache reverse proxy `.htaccess` file eg. for NodeJS. @Uberspace
SetEnvIf Request_URI "^(.*)" PORT=65300
RewriteEngine On
RewriteBase /
# CORS
Header add Access-Control-Allow-Origin "*"
# HTTPS
RewriteCond %{HTTPS} !=on