Skip to content

Instantly share code, notes, and snippets.

@cwchentw
cwchentw / index.html
Last active March 12, 2020 23:09
Respond to an AJAX call with a CGI program
<!--
Program: inch to centimeter converter
Author: Michael Chen
License: Apache 2.0
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@cwchentw
cwchentw / Makefile
Created January 24, 2020 11:56
Cross-Platform Makefile for Library (Apache 2.0)
# Detect underlying system.
ifeq ($(OS),Windows_NT)
detected_OS := Windows
else
detected_OS := $(shell sh -c 'uname -s 2>/dev/null || echo not')
endif
export detected_OS
# Set default C compiler.
@cwchentw
cwchentw / yahoo-finance-promise.js
Last active April 29, 2023 04:00
Yahoo Finance Crawler in Puppeteer, Promise Version
/* Author: Michael Chen; License: MIT */
const fs = require('fs');
const path = require('path');
const puppeteer = require('puppeteer');
const delay = function (ms) {
return new Promise(function (resolve) {
setTimeout(resolve, ms);
});
};
@cwchentw
cwchentw / yahoo-finance-async.js
Last active October 27, 2019 20:37
Yahoo Finance Crawler in Puppeteer, Async Version
/* Author: Michael Chen; License: MIT */
const fs = require('fs');
const path = require('path');
const puppeteer = require('puppeteer');
const delay = function (ms) {
return new Promise(function (resolve) {
setTimeout(resolve, ms);
});
};
@cwchentw
cwchentw / fetchTAIEX.py
Created April 26, 2019 04:35
TAIEX web crawler
#!/usr/bin/env python
##############################################################################
# fetchTAIEX.py #
# #
# Requirements #
# #
# - Python 3 #
# - Selenium package for Python #
# - The web driver for Chrome #
@cwchentw
cwchentw / zhConvert.js
Last active February 9, 2019 07:09
Convert from zh-TW to zh-CN (Apache 2.0)
document.addEventListener("DOMContentLoaded", function () {
var isSimplifiedChinese = function (lang) {
var l = lang.toLowerCase();
return l === "zh-cn" || l === "zh_zn" ||
l === "zh-sg" || l === "zh_sg" ||
l === "zh-hans" || l === "zh_hans" ||
l === "zh";
};
@cwchentw
cwchentw / text.md
Created November 13, 2018 08:33 — forked from ukyo/text.md
mallocとfreeだけ使いたい

wasmのメモリ管理つらい問題

とりあえずmallocとfreeがあればokなんだが・・・。

解決策1 emscripten使う

  • pros: 何も考えなくてもmallocとfreeが手に入る。
  • cons: でかい。

解決策2 https://github.com/dcodeIO/webassembly から取り出す

@cwchentw
cwchentw / integer.c
Last active November 4, 2019 16:01
Generic Queue in Void Pointer (Apache 2.0)
#include <stdbool.h>
#include <stdlib.h>
#include "integer.h"
struct int_t {
int data;
};
int_t* int_new(int n)
{
@cwchentw
cwchentw / fetchCurrencyData.py
Created October 21, 2018 13:55
ESun Bank Forex Historical Data Crawler as a Python script
#!/usr/bin/env python
##############################################################################
# fetchCurrencyData.py #
# #
# Requirements #
# #
# - Python 3 #
# - Selenium package for Python #
# - The web driver for Chrome #
@cwchentw
cwchentw / fetchForeclosureData.py
Last active August 28, 2023 05:08
Taiwan Foreclosure Data Crawler as a Python script
#!/usr/bin/env python
##############################################################################
# fetchForeclosureData.py #
# #
# Requirements #
# #
# - Python 3 #
# - Selenium package for Python #
# - The web driver for Chrome #