Skip to content

Instantly share code, notes, and snippets.

View zhiguangwang's full-sized avatar

Zhiguang Wang zhiguangwang

View GitHub Profile
@zhiguangwang
zhiguangwang / GameViewController.m
Created June 4, 2015 03:52
Game Center authentication with third party server.
#pragma mark - GameKit related stuff
// See documentation:
// https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/Users/Users.html#//apple_ref/doc/uid/TP40008304-CH8-SW17
// Call this method in (void)viewDidAppear:(BOOL)animated
- (void) authenticateLocalPlayer {
[GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *viewController, NSError *error) {
if (viewController != nil) {
[self showAuthenticationDialog: viewController];
@zhiguangwang
zhiguangwang / maven-runnable-jar-with-libraries.md
Created November 10, 2015 02:41
Packages maven project as runnable jar and library jars.

##Desired file hierarchy

Run mvn clean package expects the following layouts:

target folder layout

target
├── ${project.artifactId}-${project.version}
│   ├── lib

│   │   ├── jersey-bean-validation-2.22.1.jar

@zhiguangwang
zhiguangwang / elasticbeanstalk-elb-idle-timeout-cli.md
Created November 24, 2015 14:49
Update ELB Idle Timout AWS Elastic Beanstalk via CLI.
aws elasticbeanstalk update-environment \
    --environment-name [environment-name] \

--option-settings \ Namespace=aws:elb:policies,OptionName=ConnectionSettingIdleTimeout,Value=[timeout-seconds]

@zhiguangwang
zhiguangwang / pptp-intranet-route.md
Last active January 27, 2016 07:01
Shell scripts for bypassing PPTP VPN with intranet IP addresses (Mac OS X).

Add shell scripts

Add the following scripts under /etc/ppp/ (requires root privilege):

common

#!/bin/sh

# add/delete route only if device is in a specific intranet IP address block,
@zhiguangwang
zhiguangwang / download-oracle-jdk.md
Last active January 28, 2016 02:48
Download Oracle JDK via CLI with license bypass.
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" [DOWNLOAD-URL]

Example: download JDK 8u66 for Mac OS X

wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-macosx-x64.dmg
@zhiguangwang
zhiguangwang / README.md
Last active April 8, 2016 02:00
Install latest stable Git on Ubuntu

Install latest stable Git on Ubuntu

Install the most current stable version of Git for Ubuntu, using PPA of Ubuntu Git Maintainers team.

For details, see this PPA page.

@zhiguangwang
zhiguangwang / README.md
Last active April 8, 2016 02:05
Install Oracle Java 8 on Ubuntu

Install Oracle Java 8 on Ubuntu

Install Oracle JDK 8 on Ubuntu, using the webupd8team PPA.

@zhiguangwang
zhiguangwang / .vimrc
Created April 8, 2016 04:10
Vim configurations with file indent and syntax highlighting.
" Enable different settings for different file types
" See: http://vim.wikia.com/wiki/Indenting_source_code
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
@zhiguangwang
zhiguangwang / README.md
Last active April 12, 2016 01:57
Increase scrollback buffer of GNU screen

The default setting is 100.

3 ways to set scrollback buffer:

From the .screenrc file

Edit ~/.screenrc:

defscrollback [num]
@zhiguangwang
zhiguangwang / get-process-cpu-usage.md
Last active April 20, 2016 01:43
Get CPU usage of a process by name
top -b -n 1 -p `pgrep $PROCESS_NAME` | grep $PROCESS_NAME | awk {'print $9'}