Skip to content

Instantly share code, notes, and snippets.

View TsaiKoga's full-sized avatar
🎯
Focusing

TsaiKoga TsaiKoga

🎯
Focusing
View GitHub Profile
I am attesting that this GitHub handle tsaikoga is linked to the Tezos account tz1hincypNgSCEXBWxDhctvvqDaaTH8WZf42 for tzprofiles
sig:edsigu4GSac8nSMEiCxkoo3bEoJNgA1R6etb3MMATrTg8u6aB35RzYMy4gqSkbfmVZzSnUCJNSnCRRQrtnUCVkbvfKBCmZA3Ham
@TsaiKoga
TsaiKoga / find_cointegrated_pairs.py
Created April 20, 2021 08:05
协整性股票对查询
def find_cointegrated_pairs(dataframe):
"""
判断协整关系的函数
返回协整性p值矩阵,协整性强的股票对
:param :dataframe
:return :pvalue_matrix, :pairs
"""
# 得到DataFrame长度
n = dataframe.shape[1]
# 初始化p值矩阵
@TsaiKoga
TsaiKoga / helper_view_classify.py
Created December 12, 2019 05:58
PyTorch Helper: Plot the MNIST image and percentage graph
import matplotlib.pyplot as plt
import numpy as np
def view_classify(img, ps, version="MNIST"):
''' Function for viewing an image and it's predicted classes.
'''
ps = ps.data.numpy().squeeze()
fig, (ax1, ax2) = plt.subplots(figsize=(6,9), ncols=2)
ax1.imshow(img.resize_(1, 28, 28).numpy().squeeze())
@TsaiKoga
TsaiKoga / php-fpm.sh
Created February 19, 2019 02:44
Start / Stop / Restart php-fpm easily
#!/bin/sh
param=$1
start() {
fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk '{print $2}'`
if [ ! -n "$fpms" ]; then
php-fpm
@TsaiKoga
TsaiKoga / CommonTermCMD.sh
Last active April 12, 2019 05:37
commonly used commands in terminal 常用终端命令
# check the listening ports
# 查看服务器中正在监听的端口:
netstat -tupln
# check if can connect the port of the host server
# 本地查看远程服务器的端口开启是否能够访问
telnet www.xxx.com 3306
# trace how many routes hops
# 查看访问的地址经过多少路由
@TsaiKoga
TsaiKoga / HurstExponent.py
Created June 2, 2018 09:53
Return the Hurst Exponent of the time series vector ts
def hurst(ts):
"""
Return the Hurst Exponent of the time series vector ts
"""
# Create the range of lag values
lags = range(2, 100)
# Calculate the array of the variance of the lagged differences
tau = [sqrt(std(substract(ts[lag:], ts[:-lag]))) for lag in lags]
@TsaiKoga
TsaiKoga / paginate_search_datas.rb
Created October 17, 2017 04:45
Ruby on Rails paginate search products datas
per_page = 100
page = 0
total_page = (Product.count.to_f / per_page).ceil
total_page.times do
products = Product.limit(per_page).offset(page * per_page)
bill_items = bill_inventory_valuation_details products # 符合条件的采购入库单数据,此方法的查找也必须对 products 进行批量查找
sell_items = sell_inventory_valuation_details products # 符合条件的销售出库数据
package_items = package_inventory_valuation_details products # 异常出库数据
adjust = adjust_inventory_valuation_details products # 调整仓库数据
@TsaiKoga
TsaiKoga / rails_bulk_rename_columns.rb
Last active June 30, 2021 19:16
Ruby on Rails rename columns in bulk
class RenameOldOrderAddressRelatedColumn < ActiveRecord::Migration
def up
change_table(:orders, :bulk => true) do |t|
t.rename :order_status_code_id, :state
t.remove :in_process
[:first_name,
:last_name,
:country,
:state].each do |column|
t.rename "shipping_#{column}", "origin_shipping_#{column}"