Skip to content

Instantly share code, notes, and snippets.

@akccakcctw
akccakcctw / README.md
Last active November 29, 2023 07:36
POI ViewBuilder Template (pc / mweb)

用來記錄及同步 POI page template 格式

@akccakcctw
akccakcctw / gist:38d3689e72c74111a0056ff0fe4be056
Last active June 12, 2023 08:23
convertHtmlToMarkdown_20230612
function convertHtmlToMarkdown(html) {
let markdown = html;
// Remove excess tab characters
markdown = markdown.replace(/\t+/g, '');
// Convert links
markdown = markdown.replace(/<a\s+href="([^"]*)"\s*>(.*?)<\/a>/g, '[$2]($1)');
markdown = markdown.replace(/<a\s+target="_blank"\s+rel="noopener"\s+href="(.*?)">(.*?)<\/a>/g, '[$2]($1)');
<template>
<button
class="add-to-calendar-button"
@click="windowOpen(getCalendarUrl('google'))"
>
<slot />
</button>
</template>
<script>
echo "auto_prepend_file=/opt/www/proxy.php" >> /etc/php5/cli/php.ini
@akccakcctw
akccakcctw / promise_vs_async.js
Created February 24, 2022 10:56
difference between finally in promise and finally after try..catch
// https://dev.to/annarankin/finally-in-promises--trycatch-2c44
async function fnA() {
try {
await sleep(300);
console.log('fnA success');
return 'yooo';
} catch {
console.error('fnA error');
} finally {
console.log('fnA finally');
// Set up Roboto for old browsers, only regular + bold
@font-face {
font-family: Roboto;
src: url('Roboto-Regular.woff2');
font-weight: normal;
}
@font-face {
font-family: Roboto;
src: url('Roboto-Bold.woff2');
font-weight: bold;
@akccakcctw
akccakcctw / check_string_exist_in_project.sh
Last active October 28, 2020 15:32
確認 string 在 project 內是否存在
#!/usr/bin/env bash
set -e
helpFunction() {
echo ""
echo "Usage: $0 -f file_path -o output_path"
echo -e "\t-f file path"
echo -e "\t-o output path"
exit 1
@akccakcctw
akccakcctw / scroll_to_bottom.js
Last active September 17, 2018 04:16
檢測是否捲動到頁面底部
window.addEventListener('scroll', function() {
var pageHeight = document.documentElement.offsetHeight;
var windowHeight = window.innerHeight;
var scrollPosition = window.scrollY || window.pageYOffset || document.body.scrollTop + (document.documentElement && document.documentElement.scrollTop || 0);
console.log({pageHeight, windowHeight, scrollPosition});
if (pageHeight <= windowHeight + scrollPosition) {
console.log('At the bottom');
}
@akccakcctw
akccakcctw / imei-generstor.js
Created August 28, 2018 03:00
產生手機 IMEI 碼
function imeiGen() {
var pos;
var str = new Array(15).fill(0);
var sum = 0;
var finalDigit = 0;
var t = 0;
var lenOffset = 0;
var len = 15;
var issuer;