發表文章

溝通障礙?

發覺自己愈來愈不會溝通... 聊天變成一件很困難的事情,並不想要談自己,對其他人也沒興趣 成了一個死結,一下子就沒話題 是因爲太久沒聯絡還是生活上的差異... 缺乏耐心也是,以後只能跟機器溝通?沒這麼悲劇吧...

gradle : multiple spring boot project

file structure : application - build.gradle - settings.gradle - core -- src --- main ---- java ----- com ------ application ---- resouces ----- application.properties -- build.gradle - db -- build.gradle - model -- build.gradle application : build.gradle setting allprojects {     group = 'com.test'     version = '1.0.0.1' } subprojects {     apply plugin: 'java'     project.ext {         springBootVersion = '1.3.6.RELEASE'     }     repositories {         mavenLocal()         mavenCentral()     } } application : settings.gradle rootProject.name = 'application' include 'core', 'model', 'db' core : build.gradle buildscript {     repositories {         mavenLocal()         mavenCentral()     }     dependencies {         classpath 'org.spr...

Web SVG 載入img

Web 通常是用 hyper link的方式載入圖片 但是有時會遇到圖片內容是byte[] 這時候可以用BASE64 把byte[] encode成 string web 就可以用 <img src="data:image/jpg;base64,"+string> 來顯示圖片 就算是這樣,當情況是 <svg>     <img src="data:image/jpg;base64,"+string></img> </svg> 一樣會無法顯示 這時候就要感謝CSS了 可以改成 <svg style="background-image:url(data:image/jpg;base64,string); background-size: 10px 10px;  background-repeat: no-repeat;"></svg>

postgresql streaming replication on windows

step 1: master pg_hba.conf : add host    replication     rep             127.0.0.1/32           trust master postgresql.conf : modify listen_addresses = '*' wal_level = hot_standby archive_mode = on archive_command = 'copy "%p" "D:\\cliScript\\I.ECViewProDB\\%f"' max_wal_senders = 1 wal_keep_segments = 10 step 2: slave postgresql.conf : listen_addresses = '*' hot_standby = on slave create recovery.conf add restore_command = 'copy "D:\\cliScript\\I.ECViewProDB\\%f" "%p"' standby_mode = 'on' primary_conninfo = 'host = 127.0.0.1 port = 5557 user = rep password = rep' trigger_file = 'D:\\cliScript\\I.ECViewProDB\\failover.txt' step 3: sql command : select pg_start_backup('ecview') copy db content to slave exclude pg_hba.conf, pg_ident.conf, postgresql.conf, postmaster.pid sql command : select pg_stop_backup() reference :  postgresql stream replication on wi...

Eclipse zest note

基本zest viewer建立 public class BaseViewer extends ViewPart implements IZoomableWorkbenchPart { @Override public void createPartControl(Composite parent) {     view = new GraphViewer(parent, SWT.NONE);     view.setContentProvider(new NodeContentProvider());     view.setLabelProvider(new NodeLabelProvider());     view.setLayoutAlgorithm(new MultiLayoutAlgorithm(), true);  //設定layout並執行     fillToolbar(); } //設定viewer的toolbar提供zoom的選項 private void fillToolbar() {     ZoomContributionViewItem toolbarZoomContributionViewItem = new ZoomContributionViewItem( this);     IActionBars bars = getViewSite().getActionBars();     bars.getMenuManager().add(toolbarZoomContributionViewItem); } @Override public AbstractZoomableViewer getZoomableViewer() { return view; } } viewer.applyLayout(); //執行layout /* 把有連線的node獨立出來執行baselayout  * 沒有連線的node用類似gridlayout的方式處理,避免交互影響讓layout不好看 ...

lua call C function

C file : test.c ============================ #include <lua.h> #include <lauxlib.h> #include <lualib.h> #include <string.h> static int square( lua_State *L){               //用來取的lua參數,參數是以stack的狀態存在     float value = lua_tonumber (L, -1);       //轉型成C的型態     lua_pushnumber (L, value*value);         //回傳     return 1; } static int merge(lua_State *L){     const char *str1 = lua_tostring(L, -2);  //注意取的參數的順序     const char *str2 = lua_tostring(L, -1);     char str[80];     strcpy(str, str1);     strcat(str, str2); } int luaopen_ gg (lua_State *L){               // luaopen_*,載入時的主要進入點必需與.so和lua的lib同名     lua_register (L, "square", square);       //跟lua註冊function     lua_register(L, "cube", cube);     lua_register...

簡單的Junit4 case

在junit4的架構下,直接用 Annotation表示要執行的test method import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; /* * if unit test need run many times with different parameter and result */ @RunWith(Parameterized.class) public class IPUtil_UT_HasIP {         private List<String> ipList;     private String ip;     private boolean result;         @SuppressWarnings("rawtypes")     @Parameters     public static Collection data()  {         List<String> ips = new ArrayList<String>(300);   ...