Skip to content

Instantly share code, notes, and snippets.

View lifecube's full-sized avatar

TANG Hao Peter lifecube

View GitHub Profile
@lifecube
lifecube / .bashrc
Created October 4, 2018 02:20
Change Java Version on Macos
# List Java versions installed
/usr/libexec/java_home -V
# Java 10
export JAVA_HOME=$(/usr/libexec/java_home -v 10)
# Java 9
export JAVA_HOME=$(/usr/libexec/java_home -v 9)
# Java 1.8
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.*;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
@lifecube
lifecube / Data+HexString.swift
Last active September 8, 2017 08:28
Swift Data extension to support converting data to hexadecimal presented string and construct data by hexadecimal string
import Foundation
extension Data {
func hexDescription() -> String {
return map { String(format: "%02X", $0) }
.joined(separator: "")
}
init?(hexString:String) {
// Convert 0 ... 9, a ... f, A ...F to their decimal value,
@lifecube
lifecube / GitHub-Forking.md
Created March 14, 2016 15:23 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, when I started going through the process of forking and issuing pull requests, I had some trouble figuring out the proper method for doing so and made quite a few mistakes along the way. I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your

@lifecube
lifecube / xcode-build-timestamp-version.sh
Created August 22, 2015 07:10
Auto update xcode project build number and build version using the current timestamp
# xcode-build-timestamp-version.sh
# @desc Auto-update the build number and build version every time the project is run using the current timestamp.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Check the checkbox "Run script only when installing"
@lifecube
lifecube / 0_reuse_code.js
Last active August 29, 2015 14:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function bt-ctl(){
case "$1" in
off)
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.blued.plist
sudo kextunload -b com.apple.iokit.IOBluetoothSerialManager
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
;;
on)
sudo launchctl load /System/Library/LaunchDaemons/com.apple.blued.plist
sudo kextload -b com.apple.iokit.IOBluetoothSerialManager
@lifecube
lifecube / gist:da1db41dd81bcf76b40b
Created October 31, 2014 02:30
Show all Security Providers supported algorithm
for (Provider p : Security.getProviders()) {
System.out.println(p.getName()+"====================");
for (Object o : p.keySet()) {
System.out.println(o);
}
}
@lifecube
lifecube / adb-db-pull.sh
Created August 13, 2014 10:30
pull out android db file to current folder
ADB="/Applications/Android\ Studio.app/sdk/platform-tools/adb"
ADB_SHELL="$ADB shell"
SELF=`basename $0`
DEST_DIR="./"
if [ $# -ne 2 ]
then
echo "Usage: $SELF [PACKAGE.NAME [DB_FILE]]"
echo "eg. $SELF com.mydomain.myapp names.db"
exit 0
@lifecube
lifecube / report.sql
Last active August 29, 2015 13:58
oracle sqlplus sample to generate report
SET echo OFF
SET feedback OFF
SET verify OFF
SET heading OFF
SET termout OFF
SET linesize 32767
SET trimspool ON
SET trimout ON
SET serveroutput ON