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>