2018年12月26日

[Eclipse]No Default Proposals提示功能無法使用解決方法

在coding的時候例如 在打某type後 打了那個.的時候 可以提示有什麼method可以用,但! 發現他什麼都沒有 alt+/也說 no proposal

怎麼辦!!

Windows → Preperences → Java > Editor → Content Assist →Advance 把Java Proposale跟Java Type Proposale打勾

done!

[Eclipse] 變數反白

eclipse 有個功能 點兩下變數 ,用到的同一個變數都會反白

但...有可能會這個設定被改掉了

設定的地方在:
Window→Preferences→Java→Editor→Mark Occurrences

Docker安裝sonarQube server(使用mysql資料庫)

1.建立子網路
docker network create --subnet=192.168.100.0/24 sonarqube-net

*不使用設定link的方式是因為link指定對象需為runing狀態,但sonarqube和msyql都需互相認識無法誰先開好

2.mysql server
。安裝mysql
docker pull mysql:5.7
docker run --name mysql_sonarqube --net sonarqube-net --ip 192.168.100.20 -v /root/test/mysql_sonarqube/dbfile:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=密碼 -d mysql:5.7

*未使用最新版8是因為在做連線時會有異常問題,目前不知怎麼解==
*要外掛volume才能確保container掛掉後資料仍留著

。要給Sonarqube使用的相關設定
CREATE USER 'sonar'@'192.168.100.30' IDENTIFIED BY 'sonar';  GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'192.168.100.30';
FLUSH PRIVILEGES;

*5.7版無法用hostname設權限

3.安裝
docker pull sonarqube
docker run -d --name sonarqube \
-p 9096:9000 -p 9094:9094 \
--net sonarqube-net --ip 192.168.100.30 \
-v /root/test/sonarqube/data:/opt/sonarqube/data \
-v /root/test/sonarqube/extensions:/opt/sonarqube/extensions \
-e SONARQUBE_JDBC_USERNAME=sonar \
-e SONARQUBE_JDBC_PASSWORD=sonar \
-e SONARQUBE_JDBC_URL="jdbc:mysql://mysql_sonarqube:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true" \
sonarqube

*「\」為換行符號
*一樣也是外掛volume才能確保container掛掉後資料仍留著

4.確認
Browser開啟 http://ip:9096/about 預設用admin/admin登入

5.在Web UI 產生token,eclipse連線時會需要
第一次登入時,依步驟會提示產生token
或 點選account icon→My Account→Security




MAVEN install skip test case

雖然可以在run的設定裡 勾選skip,但比較想要每次直接右鍵點install 就自動skip

所以在pom檔加裡以下設定

<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>


http://maven.apache.org/plugins-archives/maven-surefire-plugin-2.12.4/examples/skipping-test.html

建 Quartz 在msysql裡的table

ref:
https://github.com/elventear/quartz-scheduler/blob/master/distribution/src/main/assembly/root/docs/dbTables/tables_mysql_innodb.sql


DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE;
DROP TABLE IF EXISTS QRTZ_LOCKS;
DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
DROP TABLE IF EXISTS QRTZ_CALENDARS;

CREATE TABLE QRTZ_JOB_DETAILS(
SCHED_NAME VARCHAR(120) NOT NULL,
JOB_NAME VARCHAR(200) NOT NULL,
JOB_GROUP VARCHAR(200) NOT NULL,
DESCRIPTION VARCHAR(250) NULL,
JOB_CLASS_NAME VARCHAR(250) NOT NULL,
IS_DURABLE VARCHAR(1) NOT NULL,
IS_NONCONCURRENT VARCHAR(1) NOT NULL,
IS_UPDATE_DATA VARCHAR(1) NOT NULL,
REQUESTS_RECOVERY VARCHAR(1) NOT NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP))
ENGINE=InnoDB;

CREATE TABLE QRTZ_TRIGGERS (
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
JOB_NAME VARCHAR(200) NOT NULL,
JOB_GROUP VARCHAR(200) NOT NULL,
DESCRIPTION VARCHAR(250) NULL,
NEXT_FIRE_TIME BIGINT(13) NULL,
PREV_FIRE_TIME BIGINT(13) NULL,
PRIORITY INTEGER NULL,
TRIGGER_STATE VARCHAR(16) NOT NULL,
TRIGGER_TYPE VARCHAR(8) NOT NULL,
START_TIME BIGINT(13) NOT NULL,
END_TIME BIGINT(13) NULL,
CALENDAR_NAME VARCHAR(200) NULL,
MISFIRE_INSTR SMALLINT(2) NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP))
ENGINE=InnoDB;

CREATE TABLE QRTZ_SIMPLE_TRIGGERS (
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
REPEAT_COUNT BIGINT(7) NOT NULL,
REPEAT_INTERVAL BIGINT(12) NOT NULL,
TIMES_TRIGGERED BIGINT(10) NOT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
ENGINE=InnoDB;

CREATE TABLE QRTZ_CRON_TRIGGERS (
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
CRON_EXPRESSION VARCHAR(120) NOT NULL,
TIME_ZONE_ID VARCHAR(80),
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
ENGINE=InnoDB;

CREATE TABLE QRTZ_SIMPROP_TRIGGERS
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
STR_PROP_1 VARCHAR(512) NULL,
STR_PROP_2 VARCHAR(512) NULL,
STR_PROP_3 VARCHAR(512) NULL,
INT_PROP_1 INT NULL,
INT_PROP_2 INT NULL,
LONG_PROP_1 BIGINT NULL,
LONG_PROP_2 BIGINT NULL,
DEC_PROP_1 NUMERIC(13,4) NULL,
DEC_PROP_2 NUMERIC(13,4) NULL,
BOOL_PROP_1 VARCHAR(1) NULL,
BOOL_PROP_2 VARCHAR(1) NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
ENGINE=InnoDB;

CREATE TABLE QRTZ_BLOB_TRIGGERS (
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
BLOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
INDEX (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
ENGINE=InnoDB;

CREATE TABLE QRTZ_CALENDARS (
SCHED_NAME VARCHAR(120) NOT NULL,
CALENDAR_NAME VARCHAR(200) NOT NULL,
CALENDAR BLOB NOT NULL,
PRIMARY KEY (SCHED_NAME,CALENDAR_NAME))
ENGINE=InnoDB;

CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS (
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP))
ENGINE=InnoDB;

CREATE TABLE QRTZ_FIRED_TRIGGERS (
SCHED_NAME VARCHAR(120) NOT NULL,
ENTRY_ID VARCHAR(95) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
INSTANCE_NAME VARCHAR(200) NOT NULL,
FIRED_TIME BIGINT(13) NOT NULL,
SCHED_TIME BIGINT(13) NOT NULL,
PRIORITY INTEGER NOT NULL,
STATE VARCHAR(16) NOT NULL,
JOB_NAME VARCHAR(200) NULL,
JOB_GROUP VARCHAR(200) NULL,
IS_NONCONCURRENT VARCHAR(1) NULL,
REQUESTS_RECOVERY VARCHAR(1) NULL,
PRIMARY KEY (SCHED_NAME,ENTRY_ID))
ENGINE=InnoDB;

CREATE TABLE QRTZ_SCHEDULER_STATE (
SCHED_NAME VARCHAR(120) NOT NULL,
INSTANCE_NAME VARCHAR(200) NOT NULL,
LAST_CHECKIN_TIME BIGINT(13) NOT NULL,
CHECKIN_INTERVAL BIGINT(13) NOT NULL,
PRIMARY KEY (SCHED_NAME,INSTANCE_NAME))
ENGINE=InnoDB;

CREATE TABLE QRTZ_LOCKS (
SCHED_NAME VARCHAR(120) NOT NULL,
LOCK_NAME VARCHAR(40) NOT NULL,
PRIMARY KEY (SCHED_NAME,LOCK_NAME))
ENGINE=InnoDB;

CREATE INDEX IDX_QRTZ_J_REQ_RECOVERY ON QRTZ_JOB_DETAILS(SCHED_NAME,REQUESTS_RECOVERY);
CREATE INDEX IDX_QRTZ_J_GRP ON QRTZ_JOB_DETAILS(SCHED_NAME,JOB_GROUP);

CREATE INDEX IDX_QRTZ_T_J ON QRTZ_TRIGGERS(SCHED_NAME,JOB_NAME,JOB_GROUP);
CREATE INDEX IDX_QRTZ_T_JG ON QRTZ_TRIGGERS(SCHED_NAME,JOB_GROUP);
CREATE INDEX IDX_QRTZ_T_C ON QRTZ_TRIGGERS(SCHED_NAME,CALENDAR_NAME);
CREATE INDEX IDX_QRTZ_T_G ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
CREATE INDEX IDX_QRTZ_T_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_STATE);
CREATE INDEX IDX_QRTZ_T_N_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE);
CREATE INDEX IDX_QRTZ_T_N_G_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE);
CREATE INDEX IDX_QRTZ_T_NEXT_FIRE_TIME ON QRTZ_TRIGGERS(SCHED_NAME,NEXT_FIRE_TIME);
CREATE INDEX IDX_QRTZ_T_NFT_ST ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME);
CREATE INDEX IDX_QRTZ_T_NFT_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME);
CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE);
CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE_GRP ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE);

CREATE INDEX IDX_QRTZ_FT_TRIG_INST_NAME ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,INSTANCE_NAME);
CREATE INDEX IDX_QRTZ_FT_INST_JOB_REQ_RCVRY ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY);
CREATE INDEX IDX_QRTZ_FT_J_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_NAME,JOB_GROUP);
CREATE INDEX IDX_QRTZ_FT_JG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_GROUP);
CREATE INDEX IDX_QRTZ_FT_T_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);

commit;

在linux 打command 登入oracle

sqlplus "帳號/密碼@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=【host】)(Port=【port】))(CONNECT_DATA=(SID=【sid】)))"

2018年9月7日

MAC 新增純文字檔


打開 文字編輯

command + shift + T


DONE! 變純文字編輯模式了!!!

[Eclipse] 如何在不同的 workspace 使用相同設定

關掉 Eclipse

找到舊的 workspace 的設定檔資料夾,路徑在:
${old_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings

複製整個資料夾,在新的 workspace 貼上並覆蓋,路徑在:${new_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings

啟動 Eclipse 

squid proxy

docker run -d --name squid -p 9099:3128 \
-v /root/test/squid/data/log:/var/log/squid \
-v /root/test/squid/data/spool:/var/spool/squid \
sameersbn/squid

掛etc的volume會失敗 所以改成先備份下來etc 修改設定後再寫進去


docker cp squid3:/etc/squid3 /etc/


編輯設定
docker exec -it squid bash


預設沒vi 所以
apt-get update
apt-get install vim


vi squid.conf


在命令模式下,首先執行
gg
這裡是跳至文件首行
再執行:
dG
這樣就清空了整個文件!





#----測試ok 的設定檔內容----

acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal networkq
acl localnet src 10.39.109.232
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines


acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
# example lin deb packages
#refresh_pattern (\.deb|\.udeb)$ 129600 100% 129600
refresh_pattern . 0 20% 4320

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
http_access allow localhost
http_access allow localnet

http_access deny !Safe_ports

# And finally deny all other access to this proxy
#http_access deny all

# Squid normally listens to port 3128
http_port 3128


# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
# example lin deb packages
#refresh_pattern (\.deb|\.udeb)$ 129600 100% 129600
refresh_pattern . 0 20% 4320


dns_nameservers 8.8.8.8 208.67.222.222



#------------------------

SonarQube

1. 用docker起sonarqube
(1) docker pull sonarqube
(2) docker run -d --name sonarqube -p 9096:9000 -p 9094:9094 sonarqube
(先不管db 用embedded的)
(3) http://ip:9096/about 用admin/admin可登入 知道起成功了

2. eclipse安裝SonarLint套件
(1) 依步驟設定指向剛建好的server
(2) 專案按右建SonarLint→Analyze就能分析專案了,但結果只會在本機,不會上到server

3. 非maven專案要把scan結果上到server:需另外下載scanner
(https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner)
(1) Expand the downloaded file into the directory of your choice. We'll refer to it as <install_directory> in the next steps.
(2) Update the global settings to point to your SonarQube server by editing <install_directory>/conf/sonar-scanner.properties:

#----- Default SonarQube server
#sonar.host.url=http://localhost:9000
(3) Add the <install_directory>/bin directory to your path.
(4) Create a configuration file in the root directory of the project: sonar-project.properties
sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=My project
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

(5) Run the following command from the project base directory to launch the analysis:
sonar-scanner
(6) 執行成功就能在server 的web ui上看到這個project了

4. maven專案要把scan結果上到server
(1) 在setting裡設定以下
<settings>
 <pluginGroups>
  <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
 </pluginGroups>
 <profiles>
<profile>
 <id>sonar</id>
 <activation>
  <activeByDefault>true</activeByDefault>
 </activation>
 <properties>
  <!-- Optional URL to server. Default value is http://localhost:9000 -->
  <sonar.host.url>
   http://myserver:9000
  </sonar.host.url>
 </properties>
</profile>
</profiles>
</settings>

(2) 執行maven時 goal寫clean install sonar:sonar 就能在server web ui上看到了



WEB UI的基本講解
https://blog.gss.com.tw/index.php/2017/04/21/sonarqube2/

[CSS] 表格字體變粗變小 又不想表格變大變小 動來動去

用bold 會讓表格自己變大
偷吃步1
letter-spacing: -0.5px;
但我不愛這招 因為感覺得出來變擠了

偷吃步2 用shadow
text-shadow: .25px 0px .1px,
-.25px 0px .1px;

chown – 改變檔案及目錄擁有者

將檔案 test.txt 的擁有者改為 newuser:
chown newuser test.txt

將 testdir/ 目錄的擁有者改為 newuser:
chown newuser testdir

將 testdir/ 目錄下的所有檔案及目錄, 改擁有者為 newuser
chown -R newuser testdir/

REF:
https://www.phpini.com/linux/chown-change-file-dir-owner

mybatis instr 字串 要串接 字串裡又有雙引號

<select id="selectLatestTemplateByVolume" parameterType="String" resultMap="ccpAsyncJobResultMap">
<bind name="jobCmdInfo" value="'volumeId&quot;:&quot;'+_parameter+'&quot;'" /><!-- volumeId":_parameter" -->
SELECT * FROM cloud.async_job
where instance_type='Template'
and job_cmd='org.apache.cloudstack.api.command.user.template.CreateTemplateCmd'
<![CDATA[ and instr(job_cmd_info,#{jobCmdInfo})>0 ]]>
order by id desc
limit 1
</select>


如果傳入是個map ( accountId=1, volumeUuid="123123123")
寫法又不太一樣


<select id="selectLatestTemplateByVolume" parameterType="Map" resultMap="ccpAsyncJobResultMap">
<bind name="jobCmdInfo" value="'volumeId&quot;:&quot;'+volumeUuid+'&quot;'" /><!-- volumeId":#{volumeUuid}" -->

SELECT * FROM cloud.async_job
where instance_type='Template'
and job_cmd='org.apache.cloudstack.api.command.user.template.CreateTemplateCmd'
<![CDATA[ and instr(job_cmd_info,#{jobCmdInfo})>0 ]]>
order by id desc
limit 1
</select>

2018年6月1日

[JAVA] 利用POI 建立excel的簡單範例

public void createWorkBook() throws IOException {

//建excel活頁簿
XSSFWorkbook workBook = new XSSFWorkbook();

//建第一個sheet,命名為 new sheet
XSSFSheet sheet = workBook.createSheet("first sheet");

// 建一row,在sheet上
Row row = sheet.createRow(0);

// 在row上建一個cell
Cell cell = row.createCell(0);

//設cell裡的值
cell.setCellValue("第一個cell");

// Or do it on one line.
row.createCell(1).setCellValue("第一列的第2個cell");
row.createCell(2).setCellValue(new Date());
row.createCell(3).setCellValue(true);
row.createCell(4).setCellValue(2);

//file命名為myExcekbook.xlsx
FileOutputStream fileOut = new FileOutputStream("d:/myExcekbook.xlsx");

// 把workBook寫進FileOutputStream
workBook.write(fileOut);
//關閉FileOutputStream
fileOut.close(); 


}

2018年5月17日

XCODE 快速鍵

command+= xcode幫調大小 (ex變更label字型後要自動調)

ommand+w 關掉模擬器

ommand+ / 模擬時把device往左或往右轉

control+k 刪除游標的一整行

command+delete 刪除游標的一整行

option+delete 刪除一個單字(游標前)

option+command+ 縮合並反白一整個method (游標在method內的任一處都可)

control+i 排版程式碼

control+space 程式碼提示


2018年5月3日

自建proxy-squid

下一步下一步就裝好可用

更多的設定說明
http://pclevin.blogspot.tw/2015/03/squid-27-proxy-server-for-windows_2.html
http://flyfox.pixnet.net/blog/post/31836683-web-proxy---squid

更方便用postman測api

postman 有環境參設的設定很方便
但 如果是要先取token的api 每次複製貼上還是覺得有點煩

原來有更方便的方法
在Tests的地方 可以加入設定
ex 有個取token的api 回傳的token 會是在「access_token」欄位裡
那就在 Tests的地方 輸入下面:
var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("token",data.access_token);


這樣以後只要 就先run 取token的api 直接再run其他要token的api就好了

不用去複製貼上了 oya

[Quartz]刪除quartz的trigger 在mysql裡的設定

1.QRTZ_CRON_TRIGGERS
2.QRTZ_TRIGGERS
3.QRTZ_JOB_DETAILS

2和3相反會刪不掉,因為有constraints的問題

資料來源:
https://mritd.me/2016/06/07/Quartz-%E4%BB%BB%E5%8A%A1%E5%BC%BA%E5%88%B6%E5%88%A0%E9%99%A4/

[Chrome套件]CSSPeeper

可以方便看網頁裡的圖 css

https://chrome.google.com/webstore/detail/css-peeper/mbnbehikldjhnfehhnaidhjhoofhpehk

https://free.com.tw/csspeeper/

2018年4月11日

自印筆記本

http://gridzzly.com/

有網眼(方格點、三角點)、方格、五線譜…

還能調size

很ez用 ui比之前另一個好

2018年4月3日

[JAVA]用JEXL處理算式

/**

* @author Querida
http://solnone.blogspot.tw/2010/06/apache-commons-jexl.html
*/

package testQ;



import org.apache.commons.jexl3.JexlContext;

import org.apache.commons.jexl3.JexlEngine;

import org.apache.commons.jexl3.JexlExpression;

import org.apache.commons.jexl3.MapContext;

import org.apache.commons.jexl3.internal.Engine;



public class TestJEXL {


public static void main(String[] args) {

// Create or retrieve a JexlEngine

JexlEngine jexl = new Engine();

// Create an expression object

String fomula = "quanty * price * 100";

JexlExpression jexlExpression = jexl.createExpression(fomula);



// Create a context and add data

JexlContext jexlContext = new MapContext();

jexlContext.set("quanty", 2);

jexlContext.set("price", 3);

// Now evaluate the expression, getting the result

Object o = jexlExpression.evaluate(jexlContext);

System.out.println(o);

}

}

[JAVA]DATE 的一些處理(joda time)

Date nowDate= new Date();
//java DATE TO joda time
new DateTime(nowDate);


//今天是一個月裡的第幾天
new DateTime(nowDate).getDayOfMonth();


//這個月有幾天
new DateTime(nowDate).dayOfMonth().getMaximumValue();


//上個月有幾天
DateTime dayOfPeriousMonth = new DateTime(nowDate).minusMonths (1);

System.out.println(dayOfPeriousMonth);

int daysInPeriousMonth=dayOfPeriousMonth.dayOfMonth().getMaximumValue();

System.out.println(daysInPeriousMonth);


//取出上個月的12號
DateTime periousM12=dayOfPeriousMonth.withDayOfMonth(12); System.out.println(periousM12 );

//joda time to java Date
new DateTime().toDate();


//本月第一天
DateTime firstDayOfMonth = new DateTime().dayOfMonth().withMinimumValue();

//某個時間是否是在今天內
if( new DateTime( someDateTime).isAfter( DateTime.now().minusDays(1) )){
System.out.println(someDateTime+" is in 24 hours");
}else {
System.out.println("not in!");
}

2018年2月14日

翻譯文章工具

不是翻譯的網頁 是方便用來翻譯文章的線上工具

https://termsoup.com/zh-TW/


提供了ex自動分段落、自動存檔、匯出

文章貼上去後 就會自動分成一句句  TAB就能下一句

也有字典功能  但英文比較派的上用場 

自己翻過的詞 也可以加入自己的字典




2018年2月13日

開始Python...

以下ref 《Python 程式設計實例入門》

直譯器...

Cpython:自由軟體,目前由Python軟體基金會管理,以C編寫的 (書本用他)

ZhPy:可用中文編寫程式

PyPy:用Python寫的,執行速度會比Cpython快

IronPyton:可以呼叫.NET平台的函式庫、編成.NET程式

Jython:用JAVA寫的,可以直接呼叫JAVA函式庫


環境建置...
https://www.python.org →DOWNLOAD

1.執行3.6.X.exe

2.1 勾選 Add Python 3.6 to PATH
2.2 勾選 Install launcher for all users
2.3 點選Customize installation

3. Optional Features 使用預設的選項
(pip是管理python套件的工具、tcl/tk是第三方套件用來寫GUI、IDLE是python內建的IDE)

4.Advanced Options
4.1勾所有選項
4.2預計安裝路徑


測試Python環境...
1.確認環境變數,看path是否有python軟體的執行路徑
( 【win+r】→【sysdm.cpl】)

2.開命令提示字元測試
輸入python 按enter 會顯示python的版本 並進入python shell 互動模式(會顯示「>>>」)
隨便打個數學算式 3+3+3 按enter 會出現結果9 (游標會停留在>>>字元下)

3.寫一個小程式
開記事本 輸入【print('hihihi!')】存檔【hihi.py】

開命令提示字元 打 【python hihi.py】 ENTTER

如何在CMD下結束python shell? 輸入【quit()】

2018年1月23日

[MySQL] Workbench 「Error Code: 1175」 的解決方法

 Edit→Preferences…→SQL Editor

[Forbid UPDATE and DELETE statements without a WHERE clause (safe updates)]不要打勾

OK

要重啟一下Workbench!

[CSS] css 移除 點連結時 會預設有的框


a{
outline: none; /* for Firefox */
hlbr:expression(this.onFocus=this.blur()); /* for IE */
}


https://www.minwt.com/webdesign-dev/css/1144.html

[JQuery] 讓AJAX運作的時候,跳出loding的訊息

[程式][JQuery] 讓AJAX運作的時候,跳出loding的訊息。-Part 1 @ 四處流浪的阿基。I am Vagrant Walker :: 痞客邦 PIXNET ::
http://expect7.pixnet.net/blog/post/39829979-%5B%E7%A8%8B%E5%BC%8F%5D%5Bjquery%5D-%E8%AE%93ajax%E9%81%8B%E4%BD%9C%E7%9A%84%E6%99%82%E5%80%99%EF%BC%8C%E8%B7%B3%E5%87%BAloding%E7%9A%84%E8%A8%8A

[Eclipse] 讓程式碼看的出與git的差異 (不是按compare)

General → Editors → Text Editors → Quick Diff 

ref:

EGit/User Guide/State - Eclipsepedia
http://wiki.eclipse.org/EGit/User_Guide/State

Instead of using a compare editor you can enable quick diff support and see the changes within the text editor. This feature can be enabled via the General > Editors > Text Editors > Quick Diff preference page:

@QueryParam NULL but @RequestParam OK

Q:加了@QueryParam 明明有傳參數但 一直抓到null  why!!

A:改用@RequestParam

ref:
https://stackoverflow.com/questions/36392717/queryparam-always-showing-null

Because you are using Spring MVC, which has no connection whatsoever to JAX-RS, which @QueryParam is for. Spring using @RequestParam. If you are going to use Spring, I suggest you get rid of your JAX-RS Dependency, so you don't get confused on what you can and can't use.

[PowerShell] 看動態LOG

Get-Content myTestLog.log –Wait


https://stackify.com/13-ways-to-tail-a-log-file-on-windows-unix/

查詢被佔用的PORT

Windows如何查詢被佔用的PORT
C:\> netstat -nao |find "0.0.0.0:80"

TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4116

C:\> tasklist /fi "pid eq 4116"

映像名稱 PID 工作階段名稱 工作階段 # RAM使用量

========================= ======== ================

skype.exe 4116 Console 0 6,476 K

C:\> taskkill /pid 4116 /F

成功: 處理程序 PID 4116 已經終止了。



Linux如何查詢被佔用的PORT
# netstat -apn |grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8688/httpd

# lsof -i:80

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME

httpd 8688 apache 3u IPv4 243301 TCP *:http (LISTEN)

httpd 8689 apache 3u IPv4 243301 TCP *:http (LISTEN)

# kill -9 8688


http://herolin.twbbs.org/entry/how-to-check-port-which-used-program-for-windows-and-linux/

[Quartz] 清空QUARTZ排程的mysql table


有時要對Trigger時間修改 或是其他有的沒的 想要先清空DB時

清除DB如下:

delete from QRTZ_SIMPLE_TRIGGERS;

delete from QRTZ_TRIGGERS;

delete from QRTZ_JOB_DETAILS;

delete from QRTZ_CRON_TRIGGERS;


(程式run起來後  排程會自動再寫入)




[Maven]把所有用到的jar 獨立在專案下的資料夾

1.在pom裡增加
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
</configuration>
</plugin>
</plugins>
</build>

2.執行mvn dependency:copy-dependencies

[Eclipse]安裝DECOMPILER 的PLUGIN

Step 1: Go to Help -> Install New Software -> click on 'Add'

Step 2: On pop-up fill these below details:

Name: JavaDecompiler

Location: http://jd.benow.ca/jd-eclipse/update/

Step 3: Click on checkbox - Java Decomplier Eclipse Plug-in.

Step 4: Click -> Next -> Next -> Accept The Agreement -> Finish

Step 5: Click on check-box -> Accept the trust certificate -> OK

Step 6: Restart the eclipse.



https://stackoverflow.com/questions/34368880/eclipse-mars-java-decompiler

[Eclipse]更改eclipse @author的預設名字

在eclipse的目錄下找到eclipse.ini檔,

在-vmargs後邊添加上啟動參數:-Duser.name=XXXX

重啟eclipse

done!