- Create project in Local by Flywheel
- Pull git project to ~/Local Sites/(project name)/app/public
- Go to Local by Flywheel, right click the project > Open Site SSH
- cd ./app/public folder
- Import the database using: wp db import xxxxx (If it comes in .sql.gz form, we may need to run 'gunzip' on the file first)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: https://stackoverflow.com/questions/57901493/pyspark-defining-custom-schema-for-a-dataframe | |
table_schema = StructType([StructField('ID', StringType(), True), | |
StructField('Name', StringType(), True), | |
StructField('Tax_Percentage(%)', IntegerType(), False), | |
StructField('Effective_From', TimestampType(), False), | |
StructField('Effective_Upto', TimestampType(), True)]) | |
df = spark.read.format(file_type) \ | |
.option("header", "true") \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add ACF Columns | |
function add_new_events_column($columns) { | |
$columns['event_date'] = 'Event Date'; | |
return $columns; | |
} | |
add_filter('manage_events_posts_columns', 'add_new_events_column'); | |
function add_new_events_admin_column_show_value( $column, $post_id ) { | |
if ($column == 'event_date') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form role="search" method="get" id="searchform" | |
class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>"> | |
<div> | |
<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label> | |
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" /> | |
<input type="submit" id="searchsubmit" | |
value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" /> | |
</div> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add ACF Columns | |
function add_new_product_cat_column($column) { | |
$column['english_name'] = 'English Name'; | |
return $column; | |
} | |
add_filter('manage_edit-product_category_columns', 'add_new_product_cat_column'); | |
function add_new_product_cat_admin_column_show_value( $content, $column_name, $term_id ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run this in console when the invite list page is opened e.g. click the number of likes on each post | |
// Caution: use at your own risk! Facebook may temporarily ban your action if you invite too many (100+) at a time. | |
var x = document.querySelectorAll('._42ft._4jy0._4jy3._517h._51sy:not(._5f0v)') | |
for(var i=0; i<x.length; i++){ | |
x[i].click(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thank you Ranatchai Chernbamrung for sample socketIO singleton pattern | |
// This code is originally for my React project, but should work with any ES6 project that support `import` statement | |
// How it works | |
// 1. Create webSocket.js to establish the connection and retrieve the connection | |
// 2. In main file, import webSocket.js to establish the connection | |
// 3. In other component files, import webSocket.js to retrieve the connection | |
// webSocket.js | |
let client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PDF extends FPDF | |
{ | |
// Inline Image | |
function InlineImage($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') | |
{ | |
// ----- Code from FPDF->Image() ----- | |
// Put an image on the page | |
if($file=='') | |
$this->Error('Image file name is empty'); | |
if(!isset($this->images[$file])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get Youtube URL | |
$yturl = 'https://www.youtube.com/watch?v=HhAKNSsb4t4'; | |
preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $yturl, $matches); | |
$video_id = $matches[1]; | |
// Get Thumbnail | |
$file_headers = get_headers( 'http://img.youtube.com/vi/' . $video_id . '/maxresdefault.jpg' ); | |
$is_404 = $file_headers[0] == 'HTTP/1.0 404 Not Found' || false !== strpos( $file_headers[0], '404 Not Found' ); | |
$video_thumbnail_url = $is_404 ? 'http://img.youtube.com/vi/' . $youtube_id . '/maxresdefault.jpg' : 'http://img.youtube.com/vi/' . $video_id . '/hqdefault.jpg'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); | |
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); | |
// Run ngrok by: | |
// ./ngrok http -host-header=dev.test.com 80 |
NewerOlder