Skip to content

Instantly share code, notes, and snippets.

@simongcc
simongcc / batch.sh
Last active August 18, 2020 02:06
Bash batch file notes
for file in *.po; do
po-to-xls ${file%.*}.po -o ${file%.*}.xlsx
done
# https://stackoverflow.com/questions/2664740/extract-file-basename-without-path-and-extension-in-bash
# $file is the file original name
# no extension: ${file%.*}.po
# s=/the/path/foo.txt
# echo "${s##*/}"
# foo.txt
@simongcc
simongcc / functions.md
Created August 16, 2020 11:50
Excel Notes

=INDEX('[Healh-Factor-product list_Health-lookup.xlsx]Sheet1'!$A:$A,MATCH(""&TRIM(E313)&"",'[Healh-Factor-product list_Health-lookup.xlsx]Sheet1'!$D:$D,),0)

@simongcc
simongcc / ExportAllCSVinOneSpreadsheet.gs
Created April 16, 2017 03:34
Google script to export all csv in one spreadsheet
/*
* script to export data in all sheets in the current spreadsheet as individual csv files
* files will be named according to the name of the sheet
* Note: This script uses the DocsList.createFile() method, which is only available for Google Apps accounts.
* author: Michael Derazon
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var csvMenuEntries = [{name: "export as csv files", functionName: "saveAsCSV"}];
@simongcc
simongcc / mysql-notes.md
Last active July 8, 2020 08:10
mysql-notes
<?php
var_dump($this->request);
if( strpos( $this->request, 'SQL_CALC_FOUND_ROWS' ) > 0 ) {
file_put_contents('/volumes/ram/test_'. time() .'.txt', $this->request);
}
@simongcc
simongcc / WordPress-Force-Post-ID.php
Created April 7, 2020 07:09
Force to change current page post object in WordPrress
<?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
?>
@simongcc
simongcc / YouTube API — getting video thumbnail
Last active March 24, 2020 11:04 — forked from protrolium/YouTube API — getting video thumbnail
YouTube API — getting video thumbnail
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<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:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
@simongcc
simongcc / custom-search-acf-wordpress.php
Created March 2, 2020 15:50 — 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
<?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
simongcc / wp-sample-add_post_type_support.php
Created January 21, 2020 05:08
Wordpress - add post type support to existing post types
function sing_update_post_types_support() {
// add_post_type_support( 'events', 'post-formats' );
}
add_action( 'init', 'sing_update_post_types_support' );
@simongcc
simongcc / horizontal-infinite-carousel.html
Created October 30, 2019 06:33 — forked from dongyuwei/horizontal-infinite-carousel.html
infinite loop carousel(vertical or horizontal)