Skip to content

Instantly share code, notes, and snippets.

@wangyingang
wangyingang / Quicksort.java.md
Created March 16, 2012 01:46
quick sort algorithms
package info.wangyg.algorithms.sort;


import java.util.Comparator;


/**
 * 
 * @author wangyingang
@wangyingang
wangyingang / Mergesort.java.md
Created March 16, 2012 01:47
merge sort algorithms
package info.wangyg.algorithms.sort;

import java.lang.reflect.Array;
import java.util.Comparator;

/**
 * 
 * @author wangyingang
 * 
@wangyingang
wangyingang / HibernateTest.java
Created November 17, 2012 05:35 — forked from yclian/HibernateTest.java
Mocking a Hibernate session / testing Criteria
package yourpackage;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.function.SQLFunctionRegistry;
@wangyingang
wangyingang / private.xml
Created June 27, 2013 06:53
KeyRemap4MacBook:private.xml
<?xml version="1.0"?>
<root>
<!--
<item>
<name>Use caps lock key to extra modifier</name>
<appendix>(You need to change the key code of caps lock to 80 on PCKeyboardHack)</appendix>
<identifier>private.capslock_extra_modifier</identifier>
<block>
<modifier_only>ModifierFlag::CAPSLOCK</modifier_only>
<autogen>
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text 2 if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Docker Cheat Sheet

Why

Why Should I Care (For Developers)

"Docker interests me because it allows simple environment isolation and repeatability. I can create a run-time environment once, package it up, then run it again on any other machine. Furthermore, everything that runs in that environment is isolated from the underlying host (much like a virtual machine). And best of all, everything is fast and simple."

TL;DR, I just want a dev environment

@wangyingang
wangyingang / some_useful_command.md
Last active August 29, 2015 13:57
Some userful shell commands

Command and arguments reuse

1.^r in bash begins a reverse-search-history with command completion

Press ctrl+r in a bash shell and type a few letters of a previous command

I can't imagine how much typing this has saved me.

2.history and !number

@wangyingang
wangyingang / clean_old_kernel.md
Last active August 29, 2015 13:58
Ubuntu cleanup. Remove All Unused Linux Kernel Headers, Images and Modules

Remove All Unused Linux Kernel Headers, Images and Modules

list all installed kernels

dpkg --list | grep linux-image

clean up

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

if you’ve upgraded your system, or had an update with a new kernel, please reboot your machine before running above the command

@wangyingang
wangyingang / install_pandoc_on_mac.sh
Last active August 29, 2015 13:58 — forked from schmurfy/gist:3199254
Install pandoc on Mac OS
# Install MacTex: http://mirror.ctan.org/systems/mac/mactex/mactex-basic.pkg
$ sudo chown -R `whoami` /usr/local/texlive
$ tlmgr update --self
$ tlmgr install ucs
$ tlmgr install etoolbox
# Install pandoc view homebrew
$ brew install haskell-platform
$ cabal install pandoc