Skip to content

Instantly share code, notes, and snippets.

View thstarshine's full-sized avatar
🏔️

starshine thstarshine

🏔️
  • Taipei, Taiwan
View GitHub Profile
@thstarshine
thstarshine / swagger.json
Last active December 4, 2020 05:24
III TDCC API swagger
{
"openapi": "3.0.0",
"info": {
"description": "### 相關說明:\n* 目前僅提供最近一年數據\n* 日期時間格式為GMT+0",
"version": "0.1.0",
"title": "Taiwan Stock Holding Distribution API",
"contact": {
"email": "development@fugle.tw"
},
"license": {
@thstarshine
thstarshine / encrypt_decrypt_example.js
Created October 29, 2018 08:14 — forked from erans/encrypt_decrypt_example.js
Example of encryption and decryption in node.js
var crypto = require("crypto")
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(text, 'utf-8', 'hex');
crypted += cipher.final('hex');
return crypted;
}
@thstarshine
thstarshine / crawler.vba
Last active July 14, 2018 07:36
Crawl website by Excel VBA
' # Show developer tab in Excel:
' https://spreadsheeto.com/developer-tab/
' # This vba example opens IE with finance.yahoo.com website, auto clicks "Quarterly" button, and then copies all td values
' of financial report into "Sheet1" sheet.
' # Can possibly use HTTP Request alternatively: http://excelerator.solutions/2017/08/28/excel-http-get-request/ (instead of open ie)
Sub test()
Dim RowCount As Integer
Dim sht As Worksheet
@thstarshine
thstarshine / mongodb_collection_sizes.js
Created December 28, 2017 08:00 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.fugle.tw/picture/cards?cards[]={%22c%22:%22FCRD000002%22,%22s%22:%222330%22}
// @grant none
// ==/UserScript==
@thstarshine
thstarshine / replace.sh
Created October 21, 2017 09:40
replace ssh authorized_keys by sed
#!/bin/bash
export NEW_SSH_KEY=ssh-rsa\ ....\ user@host
sed -e "s#ssh-rsa.*OLD_KEY_ID#$NEW_SSH_KEY#" ~/.ssh/authorized_keys
# ssh root@host 'bash -s' < this_script.sh
@thstarshine
thstarshine / cards.js
Last active October 20, 2017 15:06
cards
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.fugle.tw/picture/cards?cards[]={"c":"FCRD000002","s":"2330"}');
await page.waitForSelector('line.candle-stem');
await page.addScriptTag({
content: `
d3.selectAll(".candleRect").each(function(d,i){
@thstarshine
thstarshine / gist:7df5cd021a8d0b9c5976
Last active December 17, 2015 16:36
mongoose w/ bluebird promise performance test
mongoose schema:
update: function(row){
return this.update({}, row).exec();
}
// method 1
batchUpdate: function(rows){
return Promise.map(rows, function(row){
return self.update({}, row).exec();
console.log(angular);