Skip to content

Instantly share code, notes, and snippets.

@ChaosJohn
ChaosJohn / ramdisk.sh
Created October 11, 2018 07:26 — forked from rxin/ramdisk.sh
ramdisk create/delete on Mac OS X.
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then
#!/bin/sh
# Sublime Text 3 Install (last update: Monday 13 March 2017)
#
# No need to download this script, just run it on your terminal:
#
# curl -L git.io/sublimetext | sh
# Detect the architecture
@ChaosJohn
ChaosJohn / axios-catch-error.js
Created September 27, 2018 10:02 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
axios.put(this.apiBaseEndpoint + '/' + id, input)
.then((response) => {
// Success
})
.catch((error) => {
// Error
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data);
@ChaosJohn
ChaosJohn / clean-macports.sh
Created July 4, 2018 13:35 — forked from jbub/clean-macports.sh
Clean macports temporary build files and remove inactive ports.
# remove all temporary build files
sudo port clean --all installed
# remove all inactive ports
sudo port -f uninstall inactive
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.9/rx.lite.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
1, 2
<script id="jsbin-javascript">
@ChaosJohn
ChaosJohn / proxy.py
Created April 19, 2018 10:05 — forked from darkwave/proxy.py
Python proxy server to redirect calls from localhost to different address (change forward_to variable)
#!/usr/bin/python
# This is a simple port-forward / proxy, written using only the default python
# library. If you want to make a suggestion or fix something you can contact-me
# at voorloop_at_gmail.com
# Distributed over IDC(I Don't Care) license
import socket
import select
import time
import sys
@ChaosJohn
ChaosJohn / installDockerMachine.sh
Last active April 12, 2018 10:09
Install docker-machine executable from official (Automatically check the running system)
#!/bin/sh
# Extract the value for the key
function jsonValue() {
KEY=$1
num=$2
awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p
}
# Get the latest version name from github
{"sig":"e6257cca04ab5f2659e9093fd2d61d648b98adceb700bc665a3560886bbe003593799b821cde23035134a73dfbf50d31bde2b7b815516ed6f5707cab77a9b5b30","msghash":"8e8a4b38a0d90aa23c3a9168902bf4f166f88f403a96057c1f9869b00f77307f"}
@ChaosJohn
ChaosJohn / KotlinGson.java
Last active January 20, 2018 07:02 — forked from leoleozhu/Foo.java
Use gson to parse integer array
package com.foo;
import java.util.Arrays;
import java.util.List;
import com.google.gson.Gson;
public class KotlinGson {
private static List<Integer> toList(String json, Gson parser) {
@ChaosJohn
ChaosJohn / changeUnicodeToAsciiOfOhMyZshDefaultTheme.sh
Created November 22, 2017 06:26
Fix "➜" and "✗" of oh-my-zsh default theme making the cursor position wrong under some terminals(such as Mosh Chrome App, Termius[Chrome App Version, Mac Version, Windows Version])
#!/bin/sh
DIR="$HOME/.oh-my-zsh/custom/themes"
mkdir -p $DIR
cd $DIR
sed "s/➜/→/g;s/✗/×/g" $HOME/.oh-my-zsh/themes/robbyrussell.zsh-theme > robbyrussell.zsh-theme