Skip to content

Instantly share code, notes, and snippets.

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

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