Skip to content

Instantly share code, notes, and snippets.

Denis Wang wangyingang

Block or report user

Report or block wangyingang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
wangyingang /
Created Jan 5, 2019 — forked from PurpleBooth/
A template to make good

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.


wangyingang /
Created Jul 13, 2015
Convert InputStream to Byte Array
public class Utils {
public static byte[] getBytes(InputStream is) throws IOException {
int len;
int size = 1024;
byte[] buf;
if (is instanceof ByteArrayInputStream) {
size = is.available();
wangyingang /
Created Jul 10, 2015
URL escape sample ( and Guava UrlEscaper)
public class UrlEscapeSample {
public static void main(String[] args) {
String filename = "中国 地图/? a.docx";
String urlEncoding = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString());
prettyPrint("", urlEncoding);
prettyPrint("UrlEscapers.urlFormParameterEscaper", UrlEscapers.urlFormParameterEscaper().escape(filename));
prettyPrint(" then replace to %20", urlEncoding.replaceAll("\\+", "%20"));
prettyPrint("UrlEscapers.urlPathSegmentEscaper", UrlEscapers.urlPathSegmentEscaper().escape(filename));
prettyPrint("UrlEscapers.urlFragmentEscaper", UrlEscapers.urlFragmentEscaper().escape(filename));
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Environment;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.junit.ClassRule;
import org.junit.Test;
View gist:d2de4dbdab5776cca66d

Sublime Text 2 – Useful Shortcuts (Mac OS X)


⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
wangyingang /
Last active Aug 29, 2015
Clean up useless kernels on partition /boot

do-release-upgrade fail?

May be you got a warinning message when you execute do-release-upgrade:

Not enough free disk space

The upgrade has aborted. The upgrade needs a total of xxx M free space on disk '/boot'. Please free at least an additional xxx M of disk space on '/boot'. Empty your trash and remove temporary packages of former installations using 'sudo apt-get clean'.

Because your /boot partition is filled with old kernels. You can easily remove the old kernels if you know which packages they came in.

View gist:5a1e58e86187793c5fae
// Match

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname
You can’t perform that action at this time.