Skip to content

Instantly share code, notes, and snippets.

@Shourai
Shourai / adb.sh
Last active August 19, 2020 08:34 — forked from olivier-m/adb.sh
Remove all Google apps from an android phone/tablet (Nexus 5 / Nexus 9 | Marshmallow 6.0.1).
# With your phone in debug mode, etc.
adb start-server
adb remount
adb shell < remove.sh
@Shourai
Shourai / Android platform tools
Created January 8, 2017 20:51
Latest android platform tools (ADB and Fastboot) Raw
Ever wanted to download adb or fastboot without having to download the whole of Android Studio?
...but didn't want to download executables from some random warez site?
Good news this week:
https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
https://dl.google.com/android/repository/platform-tools-latest-linux.zip
@Shourai
Shourai / Nightshift mac
Last active March 29, 2017 08:29
Nightshift on unsupported macs
This was written by Ryanmcv over at https://pikeralpha.wordpress.com/2017/01/30/4398/comment-page-1/#comment-9146
1. Disable System Integrity Protection by booting into Recovery mode (hold down Command + R during boot-up), opening Terminal, and typing csrutil disable
2. Restart your Mac and open Finder. Navigate to System/Library/PrivateFrameworks/
Make a copy of the entire CoreBrightness.framework folder (save it to your desktop or a similar place).
3. In Xcode, open the copy of CoreBrightness.framework that you just created. File > Open; Browse to where you just saved CoreBrightness.framework; from within that .framework folder, choose the CoreBrightness icon at the top that looks like a shortcut.
4. In Xcode, press Shift + Command + J on your keyboard. A navigation column will appear on the left-hand side. Secondary/right-click CoreBrightness at the top of that column and choose Open As > Hex.
## enable changes inside brackets e.g. <di+)>, <ci+[>
# autoload -U select-bracketed
# autoload -U select-quoted
# zle -N select-quoted
# zle -N select-bracketed
# for km in visual viopp; do
# bindkey -M $km -- '-' vi-up-line-or-history
# for c in {a,i}${(s..)^:-\'\"\`\|,./:;-=+@}; do
# bindkey -M $km $c select-quoted
# done
@Shourai
Shourai / git prompt in zsh
Last active October 18, 2018 08:23
git prompt in zsh
# Adapted from https://joshdick.net/2017/06/08/my_git_prompt_for_zsh_revisited.html
# PROMPT='%~ ❯ '
setopt prompt_subst
autoload -U colors && colors # Enable colors in prompt
# Echoes a username/host string when connected over SSH (empty otherwise)
ssh_info() {
[[ "$SSH_CONNECTION" != '' ]] && echo "%(!.%{$fg[red]%}.%{$fg[yellow]%})%n%{$reset_color%}@%{$fg[green]%}%m%{$reset_color%}:" || echo ""
@Shourai
Shourai / Raspberry Pi headless installation.md
Last active October 15, 2017 20:46
Raspberry Pi headless installation

SSH over USB

To edit files on a raspberry pi when you are unable to mount ext4 disks, it is possible to enable SSH over USB. This is also useful if you do not have any peripherals you can attach to the pi. If however you are running linux you can directly edit /etc/wpa_supplicant/wpa_supplicant.conf, etc/network/interfaces and /etc/dhcpcd.conf.

Enable SSH

There was a security update to the Raspian images. To enable ssh you need to put a blank ssh file in the boot directory.

@Shourai
Shourai / Allowing SSH on a server with an active OpenVPN client.md
Last active October 5, 2023 06:32
Allowing SSH on a server with an active OpenVPN client

If you want to SSH to a VPS which is running openVPN do the following:
source: https://serverfault.com/questions/659955/allowing-ssh-on-a-server-with-an-active-openvpn-client

Enable

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.

@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.

@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 / 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.