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
import PDFParser from 'pdf2json'; | |
import { test, expect } from '@playwright/test'; | |
test.describe('assert PDF contents using Playwright', () => { | |
let pdfContents: any | |
test.beforeAll(async () => { | |
pdfContents = await getPDFContents('./pdf_sample.pdf') | |
}) | |
test('pdf file should have 6 pages', async () => { |
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_filter('acf/validate_value/name=voucher', 'acf_validate_vocher_code_unique', 10, 4); | |
function acf_validate_vocher_code_unique($valid, $value, $field, $input_name) { | |
// Bail early if value is already invalid. | |
if ($valid !== true) { | |
return $valid; | |
} | |
$result = validate_voucher_unqiue($value); |
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
export const fetchAsBlob = url => fetch(url) | |
.then(response => response.blob()); | |
export const convertBlobToBase64 = blob => new Promise((resolve, reject) => { | |
const reader = new FileReader; | |
reader.onerror = reject; | |
reader.onload = () => { | |
resolve(reader.result); | |
}; | |
reader.readAsDataURL(blob); |
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
# Sample Nginx config with sane caching settings for modern web development | |
# | |
# Motivation: | |
# Modern web development often happens with developer tools open, e. g. the Chrome Dev Tools. | |
# These tools automatically deactivate all sorts of caching for you, so you always have a fresh | |
# and juicy version of your assets available. | |
# At some point, however, you want to show your work to testers, your boss or your client. | |
# After you implemented and deployed their feedback, they reload the testing page – and report | |
# the exact same issues as before! What happened? Of course, they did not have developer tools | |
# open, and of course, they did not empty their caches before navigating to your site. |
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
<?php | |
function acf_update_post_thumbnail( $post_id ) { | |
$thumbnail_id = get_post_meta( $post_id, 'acf_image_field' ); | |
set_post_thumbnail( $post_id, $thumbnail_id ); | |
} | |
// run after ACF saves the $_POST['acf'] data | |
add_action( 'acf/save_post', 'acf_update_post_thumbnail', 20 ); |
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
<?php global $blog_id; ?> | |
<?php if ($blog_id == 2) { ?> | |
<?php } elseif ($blog_id == 1) { ?> | |
<?php } ?> | |
// Add site-id class to body functions.php | |
add_filter('body_class', 'multisite_body_classes'); | |
function multisite_body_classes($classes) { | |
$id = get_current_blog_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
/** | |
* | |
* Force http/s for images in WordPress | |
* | |
* Source: | |
* https://core.trac.wordpress.org/ticket/15928#comment:63 | |
* | |
* @param $url | |
* @param $post_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
[user] | |
name = Pavan Kumar Sunkara | |
email = [email protected] | |
username = pksunkara | |
[init] | |
defaultBranch = master | |
[core] | |
editor = nvim | |
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol | |
pager = delta |