Skip to content

Instantly share code, notes, and snippets.

@cwchentw
cwchentw / array_list.lua
Last active April 16, 2024 01:49
Array-based List in Pure Lua (Apache 2.0)
local List = {}
package.loaded["List"] = List
List.__index = List
function List:new()
self = {}
self._arr = {}
setmetatable(self, List)
return self
@cwchentw
cwchentw / employee.c
Last active November 1, 2023 17:29
Polymorphism with Function Pointer in C.
#include <stdlib.h>
#include <assert.h>
#include "person.h"
#include "employee.h"
#include "iperson.h"
// Private helper function declaration.
static void check_salary(double salary);
static char* _name(void *self);
static void _set_name(void *self, char *name);
@cwchentw
cwchentw / main.c
Last active September 18, 2023 01:35
Generic Queue by C Macro (Apache 2.0)
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include "queue.h"
queue_declare(int);
int main(void)
{
bool failed = false;
@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 #
@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 / Makefile
Last active April 1, 2023 13:04
Cross-Platform Makefile for Application (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 / animal.c
Last active May 30, 2022 23:35
Polymorphism with Union in C (Apache 2.0)
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include "animal.h"
#include "dog.h"
#include "duck.h"
#include "tiger.h"
struct animal {
@cwchentw
cwchentw / deploy2win
Last active June 18, 2021 07:47
Depoly a MSYS2 Executable to Native Windows Environment
#!/bin/sh
# deploy2win - Deploy a MSYS2 executable to native Windows environment
#
# Copyright (c) 2020, Michelle Chen. Licensed under MIT.
target="$1"
# Check whether `$target` is an executable.
@cwchentw
cwchentw / jmdict2sqlite.groovy
Last active May 3, 2021 10:48
JMdict to SQLite
/* jmdict2sqlite.groovy - Load JMdict into a SQLite database.
Copyright (c) 2020 Michael Chen.
Licensed under MIT.
Copy JMdict_e to the same path of the script.
Then, run it with the following command:
$ groovy -cp path/to/sqlite-jdbc-3.30.1.jar -DentityExpansionLimit=1000000 jmdict2sqlite.groovy
@cwchentw
cwchentw / YahooFinanceCrawler.java
Created October 14, 2018 23:47
Yahoo Finance Crawler as a Java Swing app
/*
YahooFinanceCrawler
Version: 1.0
Copyright: 2018, Michael Chen; Apache 2.0.
System Requirments:
- JDK 8
- Selenium Java package and its dependencies.
- MgntUtils