Skip to content

Instantly share code, notes, and snippets.

View Mirochiu's full-sized avatar

Chiu, Yung-Hsiang Mirochiu

View GitHub Profile
@Mirochiu
Mirochiu / index.mjs
Last active June 14, 2024 06:32
a sample code for puppeteer
import { createClient, destroyPage } from './puppeteerClient.mjs';
const waitMs = (msec) => new Promise(res => setTimeout(() => res(), msec));
const getLastPageFromPage = async (page) => {
return await page.evaluate(() => {
const urls = Array.from(document.querySelectorAll('.pagination a[href]'))
if (urls.length) {
const lastUrl = urls.pop().href;
return lastUrl.match(/\d+/g).map(Number)[0];
@Mirochiu
Mirochiu / clientApp.js
Created June 13, 2024 03:32
a client side utilities for init firebase auth, firestore, firebase storage
'use client';
import { initializeApp, getApps } from "firebase/app";
import { getAuth, connectAuthEmulator } from "firebase/auth";
import { getFirestore, connectFirestoreEmulator } from "firebase/firestore";
import { getStorage, connectStorageEmulator } from "firebase/storage";
import { firebaseConfig } from "./config"; // replace with your firebase config
const init = () => {
const appNotAvailable = getApps().length === 0
@Mirochiu
Mirochiu / genkeystore.sh
Created March 31, 2023 02:53
Use pk8 and x509.pem files in AOSP to generate the keystore file for Android Studio
#!/usr/bin/bash
# generate the keystore and show the result
storepassword="password"
outkeystore="mygen.keystore"
if [ $# -gt 0 ]; then
outkeystore="$1"
fi
if [ $# -gt 1 ]; then
@Mirochiu
Mirochiu / upload-to-imgur.html
Created March 10, 2023 07:38
upload image to Imgur with Client ID
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery.min.js"></script>
</head>
<body>
<input id="imgurClientId" type="text">
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css" rel="stylesheet" />
</head>
<body>
@Mirochiu
Mirochiu / index.js
Created March 15, 2022 03:40
Access Google calendar API with node.js
const { google } = require('googleapis');
const dotenv = require('dotenv');
dotenv.config();
const auth = new google.auth.GoogleAuth({
//keyFile: './client_secret.json', // GOOGLE_APPLICATION_CREDENTIALS
scopes: [
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.events',
],
@Mirochiu
Mirochiu / index.js
Created October 21, 2021 01:34
express sample code for uploading files
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const crypto = require('crypto');
const multer = require('multer');
const upload = multer();
app.use(bodyParser.urlencoded({ extended: true }));
// app.use(express.urlencoded()); // deprecated
@Mirochiu
Mirochiu / simple_upload.html
Last active October 19, 2021 03:18
sample to upload html file in appscript
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head><base target="_top"><meta charset="UTF-8"></head>
<body>
<h1>上傳HTML檔案</h1>
<form id="upload_form" onsubmit="onSubmit(event)">
<label for="html_name">網頁名稱</label>
<input id="html_name" type="text" name="the-name" required />
<br />
<label for="file_chooser">請選檔案</label>
@Mirochiu
Mirochiu / adb-completion.bash
Last active September 17, 2021 01:38 — forked from otobrglez/adb-completion.bash
feat: handle the logcat subcommand
# /* vim: set ai ts=4 ft=sh: */
#
# Copyright 2011, The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@Mirochiu
Mirochiu / build-gnutls-static-library.sh
Created September 3, 2021 06:19
build gnutls for ffmpeg 4.4
echo "install uncompress utils"
sudo apt install xz-utils lzip
echo "download source codes"
wget -c https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.16.tar.xz -O - | tar -xJ
wget -c https://ftp.gnu.org/gnu/nettle/nettle-3.4.1.tar.gz -O - | tar -xz
wget -c https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz -O - | tar --lzip -x
wget -c http://ftp.gnu.org/gnu/libtasn1/libtasn1-4.9.tar.gz -O - | tar -xz
wget -c https://ftp.gnu.org/gnu/libunistring/libunistring-0.9.10.tar.xz -O - | tar -xJ
wget -c https://github.com/libffi/libffi/archive/refs/tags/v3.0.9.tar.gz -O - | tar -xz