Skip to content

Instantly share code, notes, and snippets.

@wangyingang
wangyingang / cleanup_old_kernels.md
Last active August 29, 2015 14:23
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.

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
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.assertj.core.data.MapEntry;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.junit.ClassRule;
import org.junit.Test;
@wangyingang
wangyingang / Utils.java
Created July 13, 2015 18:06
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
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