Skip to content

Instantly share code, notes, and snippets.

@ruario
ruario / terminal-beats.md
Last active March 24, 2024 13:32
Swatch .beats to centibeat level from the terminal

To print the time in Swatch .beats from the terminal, issue the following:

printf @;TZ=UTC-1 date '+scale=2;((%H*60+%M)*60+%S)/86.4'|bc

You can save this as a shell alias so that you can check the time in .beats whenever you like alias beat="printf @;TZ=UTC-1 date '+scale=2;((%H*60+%M)*60+%S)/86.4'|bc".

Notes:

@ruario
ruario / make_dated_directory.md
Last active March 24, 2024 22:20
This script creates a directory named with the current date, followed by the current Swatch .beat (down to "decibeat" level, which gives ≈ 9 seconds of time resolution)

This is a short shell script to make date named directories.

#!/bin/sh
a=`TZ=UTC-1 date +%y%m%d-%T`;b=${a#*-};c=${b#*:}
mkdir -v ${a%-*}`printf %04d $(echo "((${b%%:*}*60+${c%:*})*60+${c#*:})/8.64"|bc)`|grep -Eo \[0-9]+

Usage

@ruario
ruario / 1-signal-linux-manual-unpack.md
Last active November 11, 2024 21:31
Steps to fetch and run Signal on a Linux desktop that is not deb or apt based

The following is a quick guide on how to manually download, extract and run Signal for Linux on a non-(deb)apt based distro (and includes a shell script that automates the entire process). This is for use when no suitable, native (re)package is available. It also includes some additional instructions on how to integrate with your desktop environment. Almost any recent distro (configured for desktop use) will likely have all the dependencies already installed—especially so if you already have any other Electron apps or a Chromium based browser installed, since they will require the same things.

[Note: Triple-click to easily select any of the lines below for copy and pasting into the terminal]

Fetch, extract and launch

  • Switch to a directory you think is suitable for housing Signal (for example ~/opt)
mkdir -p ~/opt && cd ~/opt
@ruario
ruario / dtime.sh
Created October 16, 2023 13:29
Show the current Decimal time or convert from "Standard time" to Decimal time
#!/bin/sh -eu
# Check for -s as an argument and if so convert decimal time to 'standard time'
if [ "${1-}" = '-s' ]; then
if [ -n "${2-}" ]; then
TIME_IN_SECS="$(echo 864*$(echo "$2" | tr -d :)/10 | bc)"
if [ "$(uname -s)" = Darwin ]; then
date -j -f "%s" "$(expr $(date -j -f '%H:%M:%S' '00:00:00' '+%s') + $TIME_IN_SECS)" '+%H:%M'
exit 0
else
date --date="0 today + $TIME_IN_SECS seconds" '+%H:%M'
@ruario
ruario / register-vivaldi.md
Last active June 22, 2023 22:56
This script simply extracts and registers a Vivaldi Linux deb or rpm package with your Desktop Environment. Not a proper "install" but basically usable as such without the need for an appropriate package manager or root access.
@ruario
ruario / dailycountdown.sh
Last active October 20, 2023 20:32
Script to post every time a further 5% (1h12m) of the day is depleted.
#!/bin/sh -eu
# Minutes past the hour that could *potentially* be when a percentage lands, to be used as a
# simple cron tab entry.
#
# 0,12,24,36,48 * * * * [path]/dailycountdown.sh >/dev/null 2>&1
# Define account username
PUBLISHER_USERNAME="[email protected]"
@ruario
ruario / slack-desktop-fetch-extract-snap.md
Last active August 9, 2022 09:22
How to download and install Slack Desktop messaging app on a desktop Linux system without snap support
  • Make an install directory somewhere convenient and switch to it
mkdir -p ~/.local/share/slack-desktop
cd ~/.local/share/slack-desktop
  • Fetch the current Slack Desktop snap
@ruario
ruario / totp.sh
Last active March 15, 2023 08:00
This is a short script to display TOTP codes using MinTOTP, with code seeds encrypted with GPG
#!/usr/bin/env bash
# This is a short script to display TOTP codes using MinTOTP
# <https://github.com/susam/mintotp>
#
# You will need to add your secret keys into an encrypted file (called
# '~/.totp-seeds.dat') formatted like so:
#
# amazon:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# github:YYY YYY YYY YYY YYYY
# paypal:ZZZZZZZZZZZZZZZZ
@ruario
ruario / authy-fetch-extract-snap.md
Last active July 31, 2024 17:01
How to download and install Twilio Authy on a desktop Linux system without snap support
  • Make an install directory somewhere convenient and switch to it
mkdir -p ~/.local/share/authy
cd ~/.local/share/authy
  • Fetch the current Authy snap
@ruario
ruario / viv2slk.sh
Last active July 22, 2022 18:42
This script will convert an official Vivaldi Linux package into Slackware package format (it should work on any Linux distro, under macOS or even using BusyBox tools)
#!/bin/sh -eu
# This script will convert an official Vivaldi Linux package into Slackware
# package format.
#
# To use, just run this script, followed by the name of the Vivaldi package.
#
# Note: Since this script was created with Slackware 15 and above in mind, it
# uses the new 'douninst.sh' script to clear down any proprietary media libs
# fetched by 'update-ffmpeg' during post install.