Skip to content

Instantly share code, notes, and snippets.

@Shourai
Shourai / YouTube_to_Newsboat.py
Created July 21, 2023 20:38
Convert YouTube takeout to newsboat RSS feed
from zipfile import ZipFile
import csv
import os
def find_file():
for file in os.listdir("./"):
if file.endswith(".zip"):
return file
@Shourai
Shourai / TrueColour.md
Created April 4, 2020 17:21 — forked from XVilka/TrueColour.md
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
Shourai / connmanctl.md
Created November 24, 2019 13:52 — forked from kylemanna/connmanctl.md
Connmanctl Cheat Sheet

Keybase proof

I hereby claim:

  • I am Shourai on github.
  • I am shourai (https://keybase.io/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
Shourai / Controlling PWR and ACT LEDs on the Raspberry Pi
Created November 2, 2018 11:09
Controlling PWR and ACT LEDs on the Raspberry Pi
From: https://www.jeffgeerling.com/blogs/jeff-geerling/controlling-pwr-act-leds-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
Shourai / Mount SD Cards within VirtualBox on Mac OS X
Created November 2, 2018 11:00
Mount SD Cards within VirtualBox on Mac OS X
From: https://blog.lobraun.de/2015/06/06/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
Shourai / How to delete a commit in git, local and remote
Created October 29, 2018 15:51
How to delete a commit in git, local and remote
from https://ncona.com/2011/07/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
Shourai / Jailbroken Kindle Upgrade Instructions
Last active October 10, 2018 10:23
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: https://www.mobileread.com/forums/showthread.php?t=225030)
6. enter `;log mrpi` into the search box.
OR
6. install the packages via KUAL if that is working.
@Shourai
Shourai / Keeping a fork up to date
Last active October 18, 2018 08:23 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date
### 1. Clone your fork:
git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
### 2. Add remote from original repository in your forked repository:
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@Shourai
Shourai / namecheap SSL.md
Created October 21, 2017 12:49
Letsencrypt SSL certificate with namecheap hosting

source: https://savedlog.com/uncategorized/letsencrypt-ssl-certificate-namecheap-hosting/

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.