Skip to content

Instantly share code, notes, and snippets.

View chriskyfung's full-sized avatar

Chris K.Y. FUNG chriskyfung

View GitHub Profile
@chriskyfung
chriskyfung / importCalendarEventsToSheet.gs
Created May 6, 2024 09:19
This Google Apps Script automatically searches a calendar you specify for events within the last year that contains specific text and writes their details to a Google Spreadsheet. You can further modify and extend this script as needed.
function importCalendarEventsToSheet() {
//Set the calendar ID and text to search for
var calendarId = 'your_calendar_id@group.calendar.google.com';
var searchText = 'your_search_text';
// Get calendar events
var events = getCalendarEvents(calendarId, searchText);
//Write event data to the spreadsheet
writeEventsToSheet(events);
@chriskyfung
chriskyfung / Microsoft.PowerShell_profile.ps1
Last active February 7, 2024 06:45
My PowerShell Profile
# Import the posh-git module that provides Git integration, including autocomplete functionality
# See http://dahlbyk.github.io/posh-git/ for details.
Import-Module posh-git
# Generate the autocompletion script for GitHub CLI
# See https://cli.github.com/manual/gh_completion for details.
Invoke-Expression -Command $(gh completion -s powershell | Out-String)
@chriskyfung
chriskyfung / Dockerfile
Created August 7, 2023 06:41
Dockerfile to build an image from bitnami/git with GitHub CLI and BFG Repo-Cleaner installed
FROM bitnami/git:latest
LABEL maintainer="@chriskyfung"
RUN apt update && apt install -y \
curl \
gpg
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg;
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
| tee /etc/apt/sources.list.d/github-cli.list > /dev/null
@chriskyfung
chriskyfung / Resize-TheBrainNotesYouTubeThumbnail.ps1
Last active November 22, 2023 01:22
A PowerShell script to resize all YouTube thumbnails down to 30% in your theBrain Notes
<#
.SYNOPSIS
Resize YouTube thumbnails down to 30% in theBrain Notes
.DESCRIPTION
Append `#$width=30p$` to the image address within the Markdown files
.PARAMETER None
.INPUTS
@chriskyfung
chriskyfung / Adb-PullAppData.ps1
Created April 1, 2023 17:33
A PowerShell script interactively guides you pull app data from (/sdcard/Android/data/) to your local machine via Android Debug Bridge (adb)
<#
.SYNOPSIS
Pull Android App data from the internal storage of
a device via Android Debug Bridge (adb).
.DESCRIPTION
The Adb-PullAppData.ps1 script uses interavtive prompts to guide you pull app data
from (/sdcard/Android/data/$APPNAME) to the local machine.
@chriskyfung
chriskyfung / Optimize-vEthernet-for-BluestacksNxt.ps1
Last active April 21, 2024 00:10
PowerShell Script to Optimize Virtual Ethernet Adapter Performance for BlueStacks with Hyper-V Enabled
#Requires -RunAsAdministrator
Try {
# Disable all Virtual Ethernet Adapters except the Virtual Ethernet Adapter for BlueStacks
Get-NetAdapter -Name "vEthernet *" | where Name -inotmatch ‘BluestacksNxt’ | Disable-NetAdapter -Confirm:$false
# Ensure the Virtual Ethernet Adapter for BlueStacks is active
Enable-NetAdapter -Name "vEthernet (BluestacksNxt)"
# Disable Large Send Offload (LSO) for all Virtual Ethernet Adapters. Learn more: https://learn.microsoft.com/en-us/windows-hardware/drivers/network/performance-in-network-adapters#supporting-large-send-offload-lso
@chriskyfung
chriskyfung / Code-Snippets-for-WordPress-with-WP-Search-with-Algolia-Plugin.md
Last active February 10, 2023 07:46
Custom Code Snippets for WordPress with WP Search with Algolia Plugin

Files

  1. custom-HTML-for-rendering-Algolia-search-results.html

  2. Exclude-specific-pages-from-Indexing-by-WP-Search-with-Algolia.php

  3. Rewrite-URLs-for-WP-Search-with-Algolia.php

@chriskyfung
chriskyfung / Add-additional-URLs-to-wp2static-crawl-list.php
Last active May 4, 2024 03:37
Custom PHP Snippets for WordPress with WP2Static Plugin
<?php
// Function to add additional URLs to the URL queue
function add_additional_urls( $url_queue ) {
// Array of additional URLs to add
$additional_urls = array(
'/ads.txt',
'/_redirects',
// Add your URL paths below:
// '/en/category/category1/page/2/',
// '/en/category/category1/page/3/',
@chriskyfung
chriskyfung / wordpress-docker-compose.yml
Last active July 12, 2024 09:55
Run WordPress locally using Docker // wp-mysql-minimal
version: '3.9'
services:
wordpress:
image: 'wordpress:latest' # Use the latest WordPress image
depends_on:
- "db" # Ensures that the db service is started before WordPress
env_file: .env # Load environment variables from an external file
environment:
WORDPRESS_DB_HOST: db # Database host, uses the service name 'db'
WORDPRESS_DB_NAME: '${MYSQL_DATABASE}' # Database name, loaded from environment
@chriskyfung
chriskyfung / FbPage2WordPressXMLImport.py
Last active July 25, 2021 21:13
Get Posts from Facebook Pages and Convert them to WordPress XML Import File using Python with Facebook Scraper
# source file: https://gist.github.com/chriskyfung/e4c863699223206c23a05eebb89faa13
# last update at 2021-07-17T19:36:05+00:00
from datetime import datetime
from facebook_scraper import get_posts
import urllib
# Parameters
FBPAGE_ID = 'medium' # e.g. The name of target facebook page
NUMOFPAGES = 3 # How many posts to scrape