Skip to content

Instantly share code, notes, and snippets.

View Mirochiu's full-sized avatar

Chiu, Yung-Hsiang Mirochiu

View GitHub Profile
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob
CSV="photos.csv"
echo "Name,Latitude,Longitude,Image" > "$CSV"
for file in *.jpg *.JPG *.jpeg *.JPEG; do
[[ -f "$file" ]] || continue
#!/usr/bin/env bash
set -euo pipefail
# =========================================================
# FFmpeg Static Build Auto Updater
# Test on Ubuntu 22.04
# Source: https://johnvansickle.com/ffmpeg/
# =========================================================
@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>