Skip to content

Instantly share code, notes, and snippets.

View royalgarter's full-sized avatar

Tom (Tung Pham Thanh) royalgarter

View GitHub Profile
@royalgarter
royalgarter / s3.sh
Created March 1, 2022 15:02 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@royalgarter
royalgarter / install_autossh.sh
Last active December 17, 2021 09:01
Permanent autossh & screen with monitor & auto reconnect
sudo apt update
sudo apt install autossh -f
#echo -e "alias assh='f(){ autossh -M 22222 \$@ -t \"screen -DRR autossh\"; unset -f f; }; f'" >> ~/.bashrc
echo -e "alias assh='f(){ X=\$@;while true; do p=\$(shuf -i 2000-65000 -n 1);netstat -lat | grep \$p; if [[ \$? == 1 ]] ; then autossh -M \$p \$X -t \"screen -DRR autossh\"; break; fi; done; unset -f f; }; f'" >> ~/.bashrc
source ~/.bashrc
echo -e "Using:\n assh [email protected]"
@royalgarter
royalgarter / embedded-file-viewer.md
Created November 2, 2021 16:46 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@royalgarter
royalgarter / oneliner.sh
Created October 16, 2021 05:26
Oneliners shellscript
System information commands
===========================
(*) #su Show only errors and warnings: `dmesg --level=err,warn`
(*) View dmesg output in human readable format: `dmesg -T`
(*) Get an audio notification if a new device is attached to your computer: `dmesg -tW -l notice | gawk '{ if ($4 == "Attached") { system("echo New device attached | espeak") } }`
(*) Dmesg: follow/wait for new kernel messages: `dmesg -w`
(*) The proper way to read kernel messages in realtime.: `dmesg -wx`
(*) Query graphics card: `lspci -nnk | grep -i VGA -A2`
@royalgarter
royalgarter / AuthyToBitwarden.md
Created May 4, 2021 03:25
Export TOTP from Authy to Bitwarden

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes (beware, through Google) for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My gues

@royalgarter
royalgarter / clean.sh
Created November 7, 2020 03:35 — forked from Iman/clean.sh
Free up disk space on Ubuntu - clean log, cache, archive packages/apt archives, orphaned packages, old kernel and remove the trash
#!/bin/sh
#Check the Drive Space Used by Cached Files
du -sh /var/cache/apt/archives
#Clean all the log file
#for logs in `find /var/log -type f`; do > $logs; done
logs=`find /var/log -type f`
for i in $logs
@royalgarter
royalgarter / autossh.sh
Last active January 2, 2020 07:36
SSH with auto-reconnect on disconnect
#!/bin/bash
# ------------------------------------------------------------------------------
# FILE: autossh
# DESCRIPTION: This is an SSH-D proxy with auto-reconnect on disconnect
# AUTHOR: Hector Nguyen (hectornguyen at octopius dot com)
# VERSION: 1.0.0
# ------------------------------------------------------------------------------
# For Window user: Create another bat file with below content
# sh autossh.sh %*
# ------------------------------------------------------------------------------
Verifying my Blockstack ID is secured with the address 19tVqjaudPYSxfobds1WQwue3upfVRC3YQ https://explorer.blockstack.org/address/19tVqjaudPYSxfobds1WQwue3upfVRC3YQ
@royalgarter
royalgarter / lnd.service
Created May 23, 2019 13:53 — forked from mariodian/lnd.service
LND Systemd script
[Unit]
Description=LND Lightning Daemon
Requires=bitcoind.service
After=bitcoind.service
[Service]
ExecStart=/home/satoshi/go/bin/lnd
ExecStop=/home/satoshi/go/bin/lncli stop
PIDFile=/home/satoshi/.lnd/lnd.pid
@royalgarter
royalgarter / lightning node.md
Created May 12, 2019 06:40 — forked from dougvk/lightning node.md
Start a lightning full node

Run the lightningd node on mainnet

root@docker-s-6vcpu-16gb-nyc3-01:~# mkdir -p /scratch/bitcoin/mainnet/clightning
root@docker-s-6vcpu-16gb-nyc3-01:~# docker run --rm --name lightning --network container:bitcoind_mainnet -v /scratch/bitcoin/mainnet/bitcoind:/root/.bitcoin -v /scratch/bitcoin/mainnet/clightning:/root/.lightning --entrypoint /usr/bin/lightningd cdecker/lightningd:master --network=bitcoin --log-level=debug

Check the log output

...
lightningd(1): Hello world from 03e71ed1bbedcf41d97e06ef3dfe4cdf79e871e9a3c809ab32b78e71dea45bf78c aka SLICKERGOPHER #03e71e (version v0.5.2-2016-11-21-1414-g5eceaa7)!