Skip to content

Instantly share code, notes, and snippets.

@guettli
guettli / ssh-tunnel@.service
Created December 22, 2017 11:40
Reliable persistent SSH-Tunnel via systemd (not autossh)
# Reliable persistent SSH-Tunnel via systemd (not autossh)
# https://gist.github.com/guettli/31242c61f00e365bbf5ed08d09cdc006#file-ssh-tunnel-service
[Unit]
Description=Tunnel for %i
After=network.target
[Service]
User=tunnel
ExecStart=/usr/bin/ssh -o "ExitOnForwardFailure yes" -o "ServerAliveInterval 60" -N tunnel@%i
@vankasteelj
vankasteelj / gunzipbase64.js
Last active June 15, 2021 21:41
gzip without header and base 64 encode, in Node
var fs = require('fs');
var zlib = require('zlib');
// Read local subtitle, gunzip it, encode to base64
var toUpload; // future gunzipped/base64 encoded string
var path = 'foo/bar.srt'; // path to subtitle
fs.readFile(path, function(err, data) { // read subtitle
if (err) throw err; // handle reading file error
zlib.deflate(data, function(err, buffer) { // gunzip it
if (err) throw err; // handle compression error
@BFTrick
BFTrick / update-tax-status.sql
Created July 25, 2013 16:25
Update the tax status of all WooCommerce products.
UPDATE `wp_postmeta`
SET meta_value='taxable'
WHERE meta_key='_tax_status'
@19h
19h / reset.js
Created February 19, 2013 22:51
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}
@bjodah
bjodah / mount_encfs.sh
Created August 26, 2011 22:33
Mounts an EncFS folder for sharing with other group members
#!/bin/bash
# BASH shell script for mounting an encrypted EncFS folder for
# for sharing with other user/users who are member of $GROUP
# Since EncFS runs in userland, no root privileges are needed.
# Remember to uncomment user_allow_other in /etc/fuse.conf
# It is currently configured to mount the encrypted folder:
# ~/.private
# on the unencrypted mount point (which is created upon mount):
# ~/private