Skip to content

Instantly share code, notes, and snippets.

View gnosis23's full-sized avatar
🏀
have fun

bhwang gnosis23

🏀
have fun
View GitHub Profile
@gnosis23
gnosis23 / Main.java
Created April 23, 2014 14:22
Mybatis Generator Maven plugin
package app;
import dao.HeroUserMapper;
import entity.HeroUser;
import entity.HeroUserExample;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Created with IntelliJ IDEA.
@gnosis23
gnosis23 / CompositeWriter.java
Created April 24, 2014 15:03
spring-batch compositeWriter sample
package batch;
import entity.TblReport;
import entity.TblReportExample;
import mapper.TblReportMapper;
import org.springframework.batch.item.ItemWriter;
import java.util.ArrayList;
import java.util.List;
@gnosis23
gnosis23 / Moneyconvert.java
Created April 25, 2014 09:18
Money converter
public static String formatFen2Yuan2(long amt) {
boolean neg = false;
if(amt < 0) {
neg = true;
amt = -amt;
}
long left = amt / 100L;
long right = amt % 100L;
StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws Exception {
InputStream fis = app.class.getClassLoader().getResourceAsStream("input.txt");
InputStreamReader isr = new InputStreamReader(fis, "GBK");
Reader in = new BufferedReader(isr);
FileOutputStream fos = new FileOutputStream("D:/download/test.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
Writer out = new BufferedWriter(osw);
int ch;
while ((ch = in.read()) > -1) {
@gnosis23
gnosis23 / batch.sql
Created May 19, 2014 05:55
spring batch
select
b.*
from batch_job_execution_params b
where b.job_execution_id in (
select a.job_execution_id from BATCH_JOB_EXECUTION a where end_time is null);
update BATCH_JOB_EXECUTION t set t.end_time = SYSDATE where t.job_execution_id = '1581'
@gnosis23
gnosis23 / app.html
Last active August 29, 2015 14:01
closure
<style type="text/css">
.red .x-progress-bar{
background: palevioletred none;
}
.x-progress.red {
border-color: #D3279C;
}
</style>
@gnosis23
gnosis23 / server.xml
Created May 21, 2014 15:22
Spring MVC encoding
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- access -->
<property name="driverClass" value="${db.driverclass}" />
<property name="jdbcUrl" value="${db.url}" />
<property name="user" value="${db.user}" />
<property name="password" value="${db.password}" />
<!-- pool sizing -->
<property name="initialPoolSize" value="3" />
<property name="minPoolSize" value="6" />
<property name="maxPoolSize" value="25" />
@gnosis23
gnosis23 / 2fork.c
Created June 3, 2014 14:17
double fork
int main(void){
pid_t = pid;
if((pid = fork()) < 0){
err;
}
else if(pid == 0){
if((pid = fork()) < 0) err;
else if(pid > 0) exit(0);
sleep(2);
@gnosis23
gnosis23 / logback.xml
Created June 9, 2014 13:22
logback configuration file
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>