Skip to content

Instantly share code, notes, and snippets.

View gist:21d83e8c491c0cd1f158
###修改ubuntu初始密码
#sudo passwd root
###修改主机名 
#/etc/hostname
#/etc/hosts
###安装ssh服务
#sudo apt-get install openssh-server
View gist:7723f67e18efba06f0cf
[root@Iven sysconfig]# cat iptables
# Generated by iptables-save v1.4.7 on Mon Jun 1 00:04:12 2015
*nat
:PREROUTING ACCEPT [49:4737]
:POSTROUTING ACCEPT [2:144]
:OUTPUT ACCEPT [2:144]
-A PREROUTING -p tcp -m tcp --dport 22222 -j REDIRECT --to-ports 22
COMMIT
# Completed on Mon Jun 1 00:04:12 2015
# Generated by iptables-save v1.4.7 on Mon Jun 1 00:04:12 2015
View gist:1803350
public class Test{
public String a = "hello";
}
View 做有意义的事
<h1>发觉自己的爱好!做有意义的事,倾听</h1>
View Singleton
/**
* see http://caterpillar.onlyfun.net/Gossip/DesignPattern/SingletonPattern.htm
* http://www.jackforfun.com/2007/07/java-synchronized.html
*/
public class Singleton {
private static Singleton instance = null;
private Singleton(){}
public static Singleton getInstance() {
if (instance == null){
synchronized(Singleton.class){
View 剪刀石头布
package test;
import java.util.Scanner;
public class ScissorStoneCloth {
/**
* @param args
*/
public static void main(String[] args) {
View java io.java
private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if (destFile.exists() && destFile.isDirectory()) {
throw new IOException("Destination '" + destFile + "' exists but is a directory");
}
FileInputStream fis = null;
FileOutputStream fos = null;
FileChannel input = null;
FileChannel output = null;
try {
@doubledouble
doubledouble / SingleInstance.java
Last active Oct 6, 2015
SingleInstance原来可以这么写
View SingleInstance.java
public class SingleInstance {
private static class InstanceHolder {
public static final SingleInstance instance = new SingleInstance();
}
public static SingleInstance getInstance() {
return InstanceHolder.instance;
}
}
View SingletonEnum
public enum SingletonEnum {
/**
* 定义一个枚举的元素,它就代表了Singleton的一个实例。
*/
uniqueInstance;
/**
* 单例可以有自己的操作
*/
View AbstractTestBean
package com.iteye.common.test;
import junit.framework.TestCase;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
You can’t perform that action at this time.