Skip to content

Instantly share code, notes, and snippets.

View nathanchen's full-sized avatar

Nathan nathanchen

View GitHub Profile
@nathanchen
nathanchen / beans-web.xml
Created July 11, 2014 03:30
spring beans-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
@nathanchen
nathanchen / TestCase.java
Created November 5, 2013 09:12
throw exception in one go
public void runBare() throws Throwable {
Throwable exception = null;
setUp();
try {
runTest();
} catch (Throwable running) {
exception = running;
} finally {
try {
tearDown();
@nathanchen
nathanchen / Assert.java
Created November 4, 2013 08:45
compare two doubles with delta
static private boolean doubleIsDifferent(double d1, double d2, double delta) {
if (Double.compare(d1, d2) == 0) {
return false;
}
if ((Math.abs(d1 - d2) <= delta)) {
return false;
}
return true;
}
@nathanchen
nathanchen / Assert.java
Created November 4, 2013 08:25
equalsRegardingNull
private static boolean equalsRegardingNull(Object expected, Object actual) {
if (expected == null) {
return actual == null;
}
return isEquals(expected, actual);
}
private static boolean isEquals(Object expected, Object actual) {
return expected.equals(actual);
__author__ = 'feng'
import string
articles = [
'Familiarize Yourself with IntelliJ IDEA editor',
'While keeping the Ctrl key pressed, rotate the mouse wheel. As you rotate the mouse wheel forward',
'font size grows larger; as you rotate the mouse wheel backwards, font size decreases',
'In the popup frame, type Reset font size, and click Enter.',
'These operations apply to the active editor only. In the other editor tabs, font size is not affected.',

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

折腾Pi,解决疑难杂症最好还是去官网论坛

image http://www.raspberrypi.org/phpBB3/

支持Apple TimeMachine,实现Mac备份

在磁盘中创建备份目录 mkdir /media/usbdisk/mactimebak 推荐使用ext4分区(打开notime)

安装nettalk

@nathanchen
nathanchen / gist:4631387
Created January 25, 2013 03:03
StringTokenizer的用法
public int compare(String a, String b) {
StringTokenizer aTokens = new StringTokenizer(a, ".");
StringTokenizer bTokens = new StringTokenizer(b, ".");
while (aTokens.hasMoreTokens()) {
int aToken = Integer.parseInt(aTokens.nextToken());
System.out.println(aToken);
if (bTokens.hasMoreTokens()) {
int bToken = Integer.parseInt(bTokens.nextToken());
System.out.println(bToken);
@nathanchen
nathanchen / JAVA - Long parseLong
Created December 29, 2012 08:24
JAVA - Long parseLong
public static long parseLong(String s, int radix)
throws NumberFormatException
{
if (s == null) {
throw new NumberFormatException("null");
}
if (radix < Character.MIN_RADIX) {
throw new NumberFormatException("radix " + radix +
" less than Character.MIN_RADIX");
@nathanchen
nathanchen / 插入元素到一个无序的数组里.java
Created December 13, 2012 02:45
JAVA - 插入元素到一个无序的数组里
public class InsertingElementsToArray {
public static void insertUnsortedArray(String toInsert) {
String[ ] unsortedArray = { "A", "D", "C" };
String[ ] newUnsortedArray = new String[unsortedArray.length + 1];
System.arraycopy(unsortedArray, 0, newUnsortedArray, 0, 3);
newUnsortedArray[newUnsortedArray.length - 1] = toInsert;
System.out.println(Arrays.toString(newUnsortedArray));