Skip to content

Instantly share code, notes, and snippets.

View akari0624's full-sized avatar

Morris-Chen akari0624

View GitHub Profile
@akari0624
akari0624 / 0_reuse_code.js
Created March 28, 2016 17:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@akari0624
akari0624 / rxAndroidClientSample.java
Last active January 2, 2018 07:49
after to retrieving data from DataBase by the withOutAsyncTask( )..... then use RXAndroid to parse them to the UI
subscription = Observable.just(fetchDataHttpCall())
.map(new Func1<String, List<GRO_VO>>() {
@Override
public List<GRO_VO> call(String jsonIn) {
Gson gson = new Gson();
Type listType = new TypeToken<List<GRO_VO>>() {
}.getType();
return gson.fromJson(jsonIn, listType);
}
subscription = Observable
.defer(new Func0<Observable<String>>() {
@Override
public Observable<String> call() {
Log.d("RX",".just( ) then .defer( )");
return Observable.just(withOutAsyncTask());
}
@akari0624
akari0624 / gist:1c3dead4a02299ae828315f6d12c93a9
Last active July 15, 2017 19:23
dollarSignCanDoAggregate.js
(function(global) {
global.$ = function(initNum) {
var aggregate = initNum;
return {
add: function(plusNum) {
aggregate += plusNum;
@akari0624
akari0624 / gist:67187476803da86a0f7c49a25ef1257a
Last active July 17, 2017 18:09
numberMappingObjKey.js
function a(num) {
var result = '';
result += num;
var run = function() {
return parseInt(result, 10);
}
@akari0624
akari0624 / gist:7851632896a06c10f2356a7eb933782e
Last active December 28, 2017 06:28
JAVA apache Dbutils example
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
const Awake = function () {
function Awake(){
}
Awake.prototype.command = {
@akari0624
akari0624 / ftpClientService.java
Last active February 1, 2018 07:10
JAVA Apache FTPClient example - a method for retrieve file from FTPServer
public boolean getFileFromFTP_ServerToThePath(Properties ftpProp){
FTPClient ftpClient = null;
OutputStream fos = null;
boolean isGetFileFromFTP_ServerToThePathSuccess = false;
try{
ftpClient = new FTPClient();
@akari0624
akari0624 / dealByteArrayInputStream.java
Created March 7, 2018 10:26
get byteArrayAsStream from netWork , set into BufferedInputStream and fiil the buffer then out.flush again
// SWT裡不知道哪裡來 invoke了這裡,但這就像填空題, 你只要確保這個method out.flush出去的是正確的 byte array 後面的步驟就應該也是對的
public boolean createpdf(String filename) {
PostMethod post = null;
boolean result;
OutputStream os = null;
try {
/*
@akari0624
akari0624 / FileTransportServlet.java
Created March 7, 2018 10:43
under a Servlet Context, send a request to another AP server , get the Binary response and add some text in the response header then send the response stream back to the original client ,
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException {
OutputStream os = null;
try {
URL url = new URL(urlStr);
URLConnection urlConnection = url.opervlet.nConnection();