Skip to content

Instantly share code, notes, and snippets.

View geminixiang's full-sized avatar
🦜

Ying Xiang geminixiang

🦜
  • GliaCloud
  • Taipei
View GitHub Profile
@geminixiang
geminixiang / clone_single_folder.sh
Created August 31, 2023 16:50
git只下載單一資料夾
# source: https://dev.to/kiwicopple/quick-tip-clone-a-single-folder-from-github-44h6
# 1. Copy an empty repo
git clone --no-checkout https://github.com/bitnami/containers.git
# 2. Move into the empty repo
cd containers
# 3. Initialize sparse-checkout
git sparse-checkout init --cone
@geminixiang
geminixiang / gcloud_service_account.sh
Created August 10, 2023 06:02
gcloud switch to another service account
SERVICE_ACCOUNT_NAME=""
PROJECT_ID=""
gcloud config configurations create $CONFIG_NAME
gcloud config set account $SERVICE_ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com
# you need to go https://console.cloud.google.com/iam-admin/serviceaccounts, and generate a new key
gcloud auth activate-service-account $SERVICE_ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com --key-file=key.json
@geminixiang
geminixiang / bq_table_sizes.py
Last active July 10, 2023 01:41
Top N table size of BigQuery
# ref. https://stackoverflow.com/a/59633371
# Before using
# pip install oauth2client google-api-python-client google-cloud-bigquery
# export GOOGLE_APPLICATION_CREDENTIALS=<CREDENTIALS>.json
from google.cloud import bigquery
from google.cloud.bigquery import Dataset
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
This file has been truncated, but you can view the full file.
#!/usr/bin/env python
#
# Hi There!
#
# You may be wondering what this giant blob of binary data here is, you might
# even be worried that we're up to something nefarious (good for you for being
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
# an entire copy of pip (version 20.3.4).
#
# Pip is a thing that installs packages, pip itself is a package that someone
@geminixiang
geminixiang / NewPartitionsForKafka.py
Created September 12, 2022 12:23
讓kafka topic partition增加
from kafka import KafkaAdminClient
from kafka.admin.new_partitions import NewPartitions
client = KafkaAdminClient(bootstrap_servers='0.0.0.0:19092',
api_version=(0, 11, 5))
rsp = client.create_partitions({
'YOUR-TOPIC': NewPartitions(4)
})
@geminixiang
geminixiang / matplotlib中文顯示
Last active November 20, 2021 08:08
Colab 中 matplotlib 顯示中文問題[快速解決]
# 下載台北黑體
!wget -O TaipeiSansTCBeta-Regular.ttf https://drive.google.com/uc?id=1eGAsTN1HBpJAkeVM57_C7ccp7hbgSz3_&export=download
import matplotlib as mpl
from matplotlib.font_manager import fontManager
# 修改字體設定
fontManager.addfont('TaipeiSansTCBeta-Regular.ttf')
mpl.rc('font', family='Taipei Sans TC Beta')
@import url("https://fonts.googleapis.com/css?family=Changa One");
@import url("https://fonts.googleapis.com/css?family=Imprima");
body {
--yt-live-chat-background-color: rgba(0,0,0,0);
}
yt-live-chat-renderer {
background-color: transparent;
}
/*gemini add*/
img.Text += "<div class='item johnny_fix'><img src='images/" + rs["filenm"] + "' alt='Technology' /><div class='plex'><div class='plex_subhead'><h3>Technology</h3></div><div class='plex_head'><h1>Pre-activated <p style='text-transform: lowercase;display:inline;color:rgb(34,34,34);'>&pi;</p>Code MicroDisc</h1></div><div class='plex_btn'><a href='http://www.plexbio.com.tw/about.aspx?unitid=221&lang=en'><button type='button'>More</button></a></div></div></div>"; rs.Read();
img.Text += "<div class='item johnny_fix'><img src='images/" + rs["filenm"] + "' alt='Product' /><div class='plex'><div class='plex_subhead'><h3>Product</h3></div><div class='plex_head'><h1>IntelliPlex&trade; 1000 <p style='text-transform: lowercase;display:inline;color:rgb(34,34,34);'>&pi;</p>Code Processor</h1></div><div class='plex_btn'><a href='http://www.plexbio.com.tw/about.aspx?unitid=125&lang=en'><button type='button'>More</button></a></div></div></div>"; rs.Read();
img.Text += "<div class='
<table class="TB_COLLAPSE TB_ORDER">
<tbody>
<tr>
<td colspan="4" style="padding:0px;line-height:30px;border-radius:4px;">
<p><span style="color: #4d6fd2;"><strong>Order Information</strong></span></p>
</td>
</tr>
<tr style="background-color: rgb(242, 242, 242);">
<td class="or_title or_line or_left">Category</td>
<td class="or_title or_line">Product Name</td>
<p><style type="text/css">
a.button {
padding: 9px 15px;
border: 3px solid #555;
letter-spacing: 5px;
cursor: pointer;
font-size: 1.3em;
color: #555;
background: rgba(0,0,0,0);
transition: 0.3s;