Skip to content

Instantly share code, notes, and snippets.

View ryenus's full-sized avatar
😀

ryenus

😀
  • Shanghai
  • 12:59 (UTC +08:00)
View GitHub Profile
@ryenus
ryenus / jv.sh
Last active May 30, 2019 15:00
show, list or set java version for current shell, mac only
# show, list or set java version for current shell
# usage: jv; jv -l; or jv 8
jv() {
local d v="$1"
if [ $# -ge 1 ]; then
[ -z "${v#-[lLV]}" ] && { /usr/libexec/java_home -V; return; }
[ -z "${v##-*}" ] && { /usr/libexec/java_home "$@"; return; }
[ ${#v} -eq 1 -a -z "${v#[0-8]}" ] && v="1.$v"
[ -n "$v" ] && d=$(/usr/libexec/java_home -v "$v") && \
export JAVA_HOME="$d"
@ryenus
ryenus / tmux-cheatsheet.markdown
Created November 20, 2018 20:51 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ryenus
ryenus / readlink_f.sh
Last active September 28, 2018 03:43
portable readlink_f implementation
: sd
#*TAG:39985 20:1973-09-17:0755:../d.proj-sd/sd
# Author: Brian Hiles <bsh@iname.com>
# Date: 1998/11/20
# Description: sed debugger with conditional spypoints
# License: copyright (c) 1996-2002
# Name: sd
# Project: @(#)sd-standalone.sh 3.3 2001-04 bsh@iname.com (Brian Hiles)
# Requires: echon(3S), expr(1), rm(1), sed(1)
# Thanks-to: Walter Briscoe <w.briscoe@ponl.com> for AIX compatibility
@ryenus
ryenus / htop_with_mouse.sh
Last active June 16, 2018 09:27
build htop with mouse support on macOS
#!/bin/bash
# install ncurses if not yet
# [ -z "$(brew info ncurses | grep 'Not installed')" ] || \
brew install ncurses
# setup $LDFLAGS and $CPPFLAGS
# source <(brew info ncurses | grep 'FLAGS' | sed -r -e 's/: +/=/' -e 's/^ +/export /')
export LDFLAGS=-L/usr/local/opt/ncurses/lib
export CPPFLAGS=-I/usr/local/opt/ncurses/include
@ryenus
ryenus / CheckednessRemover.java
Last active May 21, 2018 09:03
java exception checkness remover
// http://johannesbrodwall.com/2018/05/15/a-wicked-java-trick-to-make-the-jvm-forget-to-check-exceptions/
// https://www.reddit.com/r/java/comments/8kz1tl/a_wicked_java_trick_to_make_the_jvm_forget_to/
// https://www.reddit.com/r/programming/comments/8kz1vf/a_wicked_java_trick_to_make_the_jvm_forget_to/
static RuntimeException softenException(Exception e) {
return checkednessRemover(e);
}
static <T extends Exception> T checkednessRemover(Exception e) throws T {
throw (T) e;
@ryenus
ryenus / brew_deps.sh
Created April 16, 2018 02:44
Homebrew: List packages and what uses them
# see https://www.thingy-ma-jig.co.uk/blog/22-09-2014/homebrew-list-packages-and-what-uses-them
brew list -1 | while read cask; do echo -ne "\x1B[1;34m $cask \x1B[0m"; brew uses $cask --installed | awk '{printf(" %s ", $0)}'; echo ""; done
@ryenus
ryenus / gist:cd755727bdd53e9b8b80b145b8ac235a
Created December 13, 2017 13:39 — forked from tonymtz/gist:714e73ccb79e21c4fc9c
Uninstall XQuartz.app from OSX Yosemite
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg
# Log out and log in
#!/bin/sh
# to run this, use the following:
# curl https://matthewbauer.us/kernel-panic.sh | sh
cfile=$(mktemp).c
cat <<EOF >> $cfile
#include <unistd.h>
#include <sys/syscall.h>
#include <signal.h>
@ryenus
ryenus / bashrc
Created February 15, 2017 02:29 — forked from theBull/bashrc
How to change cursor shape, color, and blinkrate of Linux Console
##############
# pretty prompt and font colors
##############
# alter the default colors to make them a bit prettier
echo -en "\e]P0000000" #black
echo -en "\e]P1D75F5F" #darkred
echo -en "\e]P287AF5F" #darkgreen
echo -en "\e]P3D7AF87" #brown
echo -en "\e]P48787AF" #darkblue