Skip to content

Instantly share code, notes, and snippets.

simongcc / WordPress-Force-Post-ID.php
Created Apr 7, 2020
Force to change current page post object in WordPrress
View WordPress-Force-Post-ID.php
// $post = get_post( 33, OBJECT ); // use ID or
$post = get_page_by_path( $path ); // url path such as /people/staff or /people/staff/ both work
setup_postdata( $post ); // change global post object
$post->ID; // new ID
wp_reset_postdata(); // reset to original post data
View YouTube API — getting video thumbnail
Each YouTube video has 4 generated images. They are predictably formatted as follows:<insert-youtube-video-id-here>/0.jpg<insert-youtube-video-id-here>/1.jpg<insert-youtube-video-id-here>/2.jpg<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:<insert-youtube-video-id-here>/default.jpg
simongcc / custom-search-acf-wordpress.php
Created Mar 2, 2020 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
View custom-search-acf-wordpress.php
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
simongcc / wp-sample-add_post_type_support.php
Created Jan 21, 2020
Wordpress - add post type support to existing post types
View wp-sample-add_post_type_support.php
function sing_update_post_types_support() {
// add_post_type_support( 'events', 'post-formats' );
add_action( 'init', 'sing_update_post_types_support' );
simongcc / horizontal-infinite-carousel.html
Created Oct 30, 2019 — forked from dongyuwei/horizontal-infinite-carousel.html
infinite loop carousel(vertical or horizontal)
View horizontal-infinite-carousel.html
View 日中歌對照 俺たちの旅/中村雅俊 (羅文 前程錦繡 原曲) それが大事/大事MANブラザーズバンド (李克勤 紅日 原曲) 愛は勝つ/KAN (張學友 壯志驕陽 原曲) 悲しい気持ち/桑田佳祐 (古巨基 藍天與白雲 原曲) 負けないで/ZARD (坂井泉水係才女,但係好慘,死果時只有四十) My revolution/渡辺美里 (電影反轉豬腩是王子主曲) Tsunami/Southern All Stars (感人情歌)どんなときも/槇原敬之 (槇原敬之成名作) 遥かなる夢に/Beyond (海闊天空日文版)
View gist:d10f3f9d3534ab479035a5e13798cc81
# Mac OS 10.12.16
1. Open Disk Util
2. New Image > Blank Image
3. Settings:
Image Format: DVD/CD Master
Partition map: (No Partition map), if set, it will fail
Format: ExFat / MacOS both working
Size: Size needed
simongcc /
Created May 9, 2019
Export Exif files from jpeg using shell script
# #!/bin/sh is called shebang
# ref:
# #!/usr/bin/env bash means looking into the path and call the first bash found in the path
# ref:
# bash script if or
# ref:
# check file extension
simongcc / auto-put-back.scpt
Created May 2, 2019
Apple script for auto put back files
View auto-put-back.scpt
# original:
# keyboard keycodes:
tell application "System Events"
tell process "Finder"
repeat 100 times
tell application "Finder" to open trash
tell application "Finder" to activate
key code 126
key down command
key code 51
simongcc / _archive-project.bat
Created Apr 26, 2019
Windows batch zip project files with date stamp (legacy backup method by Schedule)
View _archive-project.bat
@echo off
rem get local date time
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
rem set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,6%
set ldt=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2%-%ldt:~8,2%%ldt:~10,2%%ldt:~12,2%
set destination=U:\Project-by-Set-Grp
set destination2=Z:\_Project_Bak
set zip_exe="C:\Program Files\7-Zip"
set config_file="C:\Users\XXXXX\Dropbox\_work\_backup_data"
set dropbox_bak="U:\Project-by-Set-Grp"