Skip to content

Instantly share code, notes, and snippets.

install.packages("quantmod") #有安裝過quantmod套件可以不用
require("quantmod") #或是library(quantmod) 去引用quantmod
getSymbols("2330.TW",src="yahoo",from="2016-01-01",to=Sys.Date()) #from改成自己要的起日
TSMCTW<-get("2330.TW") #因為台股股號是數字,用數字繪圖會有問題
chartSeries(TSMCTW) #或是barChart(TSMCTW)
#備註:
#如果要把遠端Linux主機跑的繪圖結果傳到本機要用X11 forwarding
#WINDOWS可以下載安裝Xming X Server for Windows ( https://sourceforge.net/projects/xming/ )
--http://stackoverflow.com/questions/1435935/how-to-get-the-logical-name-of-the-transaction-log-in-sql-server-2005
--get transaction log name
--select Name from sys.database_files
SELECT name as 'transaction log name' FROM sys.master_files WHERE database_id = db_id()AND type = 1;
--http://dba.stackexchange.com/questions/73850/shrink-transaction-log-while-using-alwayson-availability-group
--Execute on Primary Only
if (SELECT role
FROM sys.dm_hadr_availability_replica_states AS a
@imrexhuang
imrexhuang / Create Persistent MySQL DB in podman.txt
Last active May 2, 2022 01:18
使用podman指令建立Persistent Storage的MySQL容器資料庫,並藉由systemctl設為Host重開機自動啟動
#環境:RHEL 8.3
#目的:透過podman建立一個Persistent Storage的MySQL 8.0資料庫,並藉由systemctl設為Host重開機自動啟動
#備註1:podman run指令不支援--restart=always(因為podman有別於Docker架構,不使用Daemon機制(daemonless Container),無法透過Daemon機制去自動重啟)
#參考資料 https://igene.tw/podman-intro
#備註2:如果rm刪除容器重新建立,需要重新產生 podman generate systemd --name mysql-80-persist > mysql80-container.service
#建立Permanent Storage Location
sudo mkdir -p /var/podmandata/db/mysql80
#加入合適的SELinux context
--TSQL利用CASE WHEN處理欄位的NULL值
SELECT 'new CustomersEntity("'+ [CustomerID] + '" , "' + [CompanyName] + '" , "' + [ContactName] + '" , "' + [ContactTitle] + '" , " ' + [Address] + '" , "' + [City] + '" , "'
+ CASE WHEN [Region] IS NULL THEN '' ELSE [Region] END + '" , "'
+ CASE WHEN [PostalCode] IS NULL THEN '' ELSE [PostalCode] END + '" , "'
+ [Country] + '" , "' + [Phone] + '" , "'
+ CASE WHEN [Fax] IS NULL THEN ' ' ELSE [Fax] END + '" ' --SQL結尾
+');'
FROM [dbo].[Customers]
@imrexhuang
imrexhuang / capitalzmdb.py
Last active March 24, 2021 17:46
capitalzmdb
import pandas as pd
import requests,datetime
from bs4 import BeautifulSoup
url = 'http://stock.capital.com.tw/z/zm/zmd/zmdb.djhtm'
res = requests.get(url)
#res.encoding = 'cp950'
#print("encoding: %s" % res.encoding)
#print("content: \n%s" % res.text)
@imrexhuang
imrexhuang / ajax_t05st01.py
Last active March 20, 2021 11:36
Python取得公開資訊觀測站的重大訊息公告(無法正常使用)
# ※此版本會被證交所主機擋,無法正常使用,僅供示範※
# 請先pip install beautifulsoup4
# https://rexpyblog.blogspot.com/2021/03/html.html 文章範例程式
import requests
from bs4 import BeautifulSoup
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'}
# 公開資訊觀測站的重大訊息公告
url = 'https://mops.twse.com.tw/mops/web/ajax_t05st01?firstin=1&TYPEK=sii&co_id=2330&year=107&month=&b_date=&e_date='
res = requests.get(url, headers=headers).text
@imrexhuang
imrexhuang / PagesArticles20210302.sql
Last active March 16, 2021 14:29
SQL Server全文檢索搜尋不到的資料
--搜尋java關鍵字
/*
搜尋語法:
SELECT [url],title,[text]
FROM PagesArticles20210302
WHERE CONTAINS([title], 'java')
OR CONTAINS([text], 'java')
order by [url]
*/
@imrexhuang
imrexhuang / settings.xml
Last active March 9, 2021 16:13
Maven使用Proxy
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>PROXY.xxxyyy.com</host>
<port>8080</port>
<nonProxyHosts>intraDomain.com|localhost|127.*|[::1]|192.168.*|[::1]</nonProxyHosts>
</proxy>
@imrexhuang
imrexhuang / systemctl無法啟動podman容器.txt
Last active March 6, 2021 06:59
systemctl無法啟動podman容器
直接ssh用sudo systemctl start mysql80-container.service指令是可以啟動
### RHEL 8.3重開機後的資訊 ###
[linuxuser@localhost ~]$ sudo podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[linuxuser@localhost ~]$ sudo podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
35f94aedd9d8 registry.redhat.io/rhel8/mysql-80 run-mysqld 22 minutes ago Exited (137) 13 minutes ago 0.0.0.0:3306->3306/tcp mysql-80-persist
[linuxuser@localhost ~]$ systemctl is-enabled mysql80-container.service
package ohcache;
import org.caffinitas.ohc.CacheSerializer;
import org.caffinitas.ohc.OHCache;
import org.caffinitas.ohc.OHCacheBuilder;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;