Skip to content

Instantly share code, notes, and snippets.

View SanCoder-Q's full-sized avatar
💭
I may be slow to respond.

JmQu SanCoder-Q

💭
I may be slow to respond.
View GitHub Profile
function git-revert-batch {
echo "$@" | xargs -n1 git revert --no-commit
}
alias grb='git-revert-batch'
# use like:
# grb ee5c95a 981da8b
# list commits in reverse order, and it's ready to make one neat+tidy revert-commit
@SanCoder-Q
SanCoder-Q / unload-keyboard
Last active July 25, 2016 07:24 — forked from JohnMurray/unload-keyboard
Disable Mac OS X Keyboard (built-in only)
#!/bin/bash
# Unload the keyboard so I can use my external keyboard
# and not worry about accidentally pressing buttons on
# the built-in. This may not be a problem for you but, you
# should see my desk sometimes (Oh no!!) ;-)
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
# enableIt
#!/bin/sh
COURSIER_URL=https://raw.githubusercontent.com/alexarchambault/coursier/v1.0.0-M12/coursier
test -e ./.coursier/cr || (mkdir -p ./.coursier && curl -s --output ./.coursier/cr $COURSIER_URL && chmod +x ./.coursier/cr)
CLASSPATH="$(./.coursier/cr fetch -q -p \
\
com.chuusai:shapeless_2.11:2.3.1 \
com.lihaoyi:ammonite-repl_2.11.8:0.5.8 \
\
)" java ammonite.repl.Main --predef 'import shapeless._'
@SanCoder-Q
SanCoder-Q / Git-GPG-commit.md
Created August 22, 2016 07:05
Git GPG commit
gpg --gen-key
gpg --list-secret-keys --keyid-format LONG
gpg --armor --export <sec-key>

Add to github setting.

git commit -S ...
@SanCoder-Q
SanCoder-Q / Future-retry.scala
Created November 12, 2016 05:54 — forked from viktorklang/Future-retry.scala
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
@SanCoder-Q
SanCoder-Q / !react-enzyme-render-methods.md
Created February 8, 2017 03:37 — forked from richardscarrott/!react-enzyme-render-methods.md
react-enzyme - `shallow` vs `mount` vs `render` lifecycle methods

An exploration of the different render methods available in react-enzyme.

@SanCoder-Q
SanCoder-Q / command.magic.sh
Last active September 18, 2017 09:42
Command Magic
# Find out the connections of a process
lsof -i -a -p <PID>
# Find out the route table
netstat -nr
netstat -A inet -p | grep <pattern of process>
# Find out the ip of a domain name
nslookup <domain name>
@SanCoder-Q
SanCoder-Q / jq-with-wget.sh
Created June 5, 2017 02:07
Install jq with wget
wget -O jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
chmod +x ./jq
cp jq /usr/bin
@SanCoder-Q
SanCoder-Q / useful.yum.repo
Created June 22, 2017 11:26
Useful yum repo
==================
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
@SanCoder-Q
SanCoder-Q / Shortcuts.org
Last active July 17, 2017 10:14
Emacs Magics
  • Show / resume / recover the Helm result in mini buffer

C-x c b

  • Add new word in dictionary

C-c $ then select save word

  • In addition to showing entities as UTF-8 characters, this command will also format sub- and superscripts in a WYSIWYM way.

C-c C-x \