Skip to content

Instantly share code, notes, and snippets.

Shourai /
Created Apr 4, 2020 — forked from XVilka/
True Colour (16 million colours) support in various terminal applications and terminals

Terminal Colors

There exists common confusion about terminal colors. This is what we have right now:

  • Plain ASCII
  • ANSI escape codes: 16 color codes with bold/italic and background
  • 256 color palette: 216 colors + 16 ANSI + 24 gray (colors are 24-bit)
  • 24-bit true color: "888" colors (aka 16 milion)
Shourai /
Created Nov 24, 2019 — forked from kylemanna/
Connmanctl Cheat Sheet

Keybase proof

I hereby claim:

  • I am Shourai on github.
  • I am shourai ( on keybase.
  • I have a public key whose fingerprint is 5EAC 6DD6 CB6A 24BF D337 965F D929 E4C2 C221 663A

To claim this, I am signing this object:

Shourai / Controlling PWR and ACT LEDs on the Raspberry Pi
Created Nov 2, 2018
Controlling PWR and ACT LEDs on the Raspberry Pi
View Controlling PWR and ACT LEDs on the Raspberry Pi
March 15, 2015
All Raspberry Pi models have a few built-in LEDs; the earlier models had PWR, ACT, and networking status LEDs all lined up on the board itself; for the B+ and model 2 B, the networking LEDs moved onto the network jack itself, leaving just two LEDs; PWR (a red LED) and ACT (a green LED).
Normally, whenever the Pi is powered on—except if the power supply dips below something like 4.5VDC—the red PWR LED remains lit no matter what. If you wanted to 'disable' the LED, you'd have to put a piece of tape or something else over the LED, or get out a soldering iron and modify the hardware a bit.
Raspberry Pi model 2 B, B+ and A+
Luckily, with the Pi 2 model B, B+, A+, and Zero, you can control the LEDs in software, in a few different ways. The simplest way to change the way these LEDs work is to modify the trigger for each LED by setting it in /sys/class/leds/led[LED_ID]/trigger, where you replace [LED_ID] wi
Shourai / Mount SD Cards within VirtualBox on Mac OS X
Created Nov 2, 2018
Mount SD Cards within VirtualBox on Mac OS X
View Mount SD Cards within VirtualBox on Mac OS X
Mount SD Cards within VirtualBox on Mac OS X
Sometimes you need to mount your SD cards inside a VirtualBox machine to work with the files on the card. Working with the Raspberry Pi SD card on Mac OS X is an example for this.
My Raspberry Pi runs on Linux with some version of the EXT file system. While there is some support for this on Mac OS X, the available solutions have a lot of limitations, especially when it comes to write support on EXT file systems. As I do not have an USB keyboard, I sometimes need to mount the filesystem on another system to fix a startup problem when some of my experiments go wrong.
VirtualBox in theory allows for passing the internal card reader of the MacBooks to the virtual machine. Unfortunately, this does not work for me (and it seems for many other people).
Shourai / How to delete a commit in git, local and remote
Created Oct 29, 2018
How to delete a commit in git, local and remote
View How to delete a commit in git, local and remote
It has happened to me more than once that I make a commit without verifying the changes I am committing. Time after that I review the commit and I notice that there is something in the commit that doesn’t belong there.
In those times what I want to do is make a patch with the changes of the commit, delete the commit, apply the patch and then redo the commit only with the changes I intended. In this post I will only explain how to delete a commit in your local repository and in a remote repository in case you have already pushed the commit.
Delete a local commit
Anthony Dentinger showed me in the comments that you can delete a local commit by doing:
git reset –hard HEAD~
Shourai / Jailbroken Kindle Upgrade Instructions
Last active Oct 10, 2018
Jailbroken Kindle Upgrade Instructions
View Jailbroken Kindle Upgrade Instructions
1. Copy system upgrade file to main directory of Kindle.
2. Disconnect Kindle from computer.
3. Go to the main menu, settings, device options, update your kindle.
4. After the update/restart plug the kindle back into the computer
5. Copy Screensaver and Python update files into the mrpackages folder and eject kindle
(Files can be found here:
6. enter `;log mrpi` into the search box.
6. install the packages via KUAL if that is working.
Shourai / Keeping a fork up to date
Last active Oct 18, 2018 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date
View Keeping a fork up to date
### 1. Clone your fork:
git clone
### 2. Add remote from original repository in your forked repository:
cd into/cloned/fork-repo
git remote add upstream git://
git fetch upstream
Shourai / namecheap
Created Oct 21, 2017
Letsencrypt SSL certificate with namecheap hosting
View namecheap


The “Positive SSL” certificate I bought along with my domain is invalid with any of my subdomains and cannot be used with wildcards. One annoying thing is that namecheap doesn’t offer auto installation of free let’s encrypt certificates, even though, they are saying “Namecheap is dedicated to data security and privacy for all internet users. We believe the movement to encrypt nearly all web traffic is a positive direction. As more sites embrace HTTPS and use of security products, providers of free SSL are beginning to come online.”

Let me show you what it needs to be done in order to “encrypt nearly all web traffic”.

First, not required but it’s helpful to enable ssh access, it is not enabled by default on the base hosting plans, just go an start a live chat and request ssh access.

Shourai / Allowing SSH on a server with an active OpenVPN
Last active Apr 30, 2022
Allowing SSH on a server with an active OpenVPN client
View Allowing SSH on a server with an active OpenVPN

If you want to SSH to a VPS which is running openVPN do the following:


The problem is that the default gateway gets changed by OpenVPN, and that breaks your current SSH connection unless you set up appropriate routes before you start OpenVPN.

What follows works for me. It uses iptables and ip (iproute2). Below, it is assumed that the default gateway interface before OpenVPN is started is "eth0". The idea is to ensure that when a connection to eth0 is made, even if eth0 is not the default gateway interface anymore, response packets for the connection go back on eth0 again.

You could use the same number for the connection mark, firewall mark and routing table. I used distinct numbers to make the diffences between them more apparent.