Skip to content

Instantly share code, notes, and snippets.

View AndreKelling's full-sized avatar

André J. Kelling AndreKelling

View GitHub Profile
@ryanrosello-og
ryanrosello-og / assert PDF contents using Playwright.ts
Created July 8, 2022 10:29
assert PDF contents using Playwright
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 () => {
@sudarshann
sudarshann / validate-acf-field-repeater.php
Last active May 2, 2023 06:52
Custom validation for ACF Repeater Field values
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);
@bvandenbon
bvandenbon / cookieservice.service.ts
Last active December 4, 2020 10:29
CookieService
import { Injectable } from '@angular/core';
@Injectable()
export class CookieService {
constructor() {
}
set(key: string, value: string): void;
set(key: string, value: string, expires: Date): void;
@n1ru4l
n1ru4l / index.js
Created August 7, 2017 10:47
Fetch blob and convert to base64
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);
@philipstanislaus
philipstanislaus / sane-caching.nginx.conf
Last active January 1, 2025 14:28
Sample Nginx config with sane caching settings for modern web development
# 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.
@kevinwhoffman
kevinwhoffman / acf-update-post-thumbnail.php
Created January 30, 2016 16:40
Update post thumbnail with value of ACF Image field
<?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 );
@barbwiredmedia
barbwiredmedia / multisite-conditional.php
Last active February 18, 2021 11:05
Wordpress Multisite body class addition and blog conditional.
<?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();
@mathetos
mathetos / ssl-for-images.php
Last active July 3, 2018 08:21
Force http/s for images in WordPress
/**
*
* Force http/s for images in WordPress
*
* Source:
* https://core.trac.wordpress.org/ticket/15928#comment:63
*
* @param $url
* @param $post_id
*
@pksunkara
pksunkara / config
Last active May 6, 2025 17:23
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[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