Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
ChrisLTD / waitForGraphQL.ts
Created April 18, 2023 00:45
Helper you can use to wait for specific graphql queries to finish in Playwright
import { Page } from '@playwright/test';
export async function waitForGraphQL(
page: Page,
operationName: string
): Promise<void> {
await page.waitForResponse(async (response) => {
if (response.url().endsWith('/graphql')) {
const responseText = await response.text();
const responseData = JSON.parse(responseText);
/*
Launch Darkly Context Provider using their JavaScript Client SDK
This component is used to provide the feature flags context to the rest of the app.
This is how you can use feature flags in your components:
1) Add your flag to the `Flags` constant in this file if it's not already there:
myFlag: { slug: 'my-flag', defaultValue: false },
(function keepVideoFromSkipping() {
// modified from https://stackoverflow.com/a/39754847
function modifyBehavior(video) {
var timeTracking = {
watchedTime: 0,
currentTime: 0
};
var lastUpdated = 'currentTime';
@ChrisLTD
ChrisLTD / functions.php
Last active July 20, 2020 20:41
Change slug / permalink of WordPress 'posts' post type
<?php
/**
* Rewrite blog posts so they start with /blog
*/
function change_posts_post_type_args( $args, $post_type ) {
if ( $post_type == "post" ) {
$args['rewrite'] = array(
'slug' => 'blog',
@ChrisLTD
ChrisLTD / ProgressBar.html
Created February 27, 2020 16:12
HTML / JS / SCSS progress bar
<progress value="0"></progress>
<style>
progress { width: 100%; height: 5px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
background-color: white;
color: @green;
@ChrisLTD
ChrisLTD / scroll-locking.html
Last active July 17, 2019 19:15
Scrolling Locking
<script>
// Scroll locking
var overlayShown = false;
var scrollPosition = 0;
function toggleScrollLock() {
if (!overlayShown) {
showOverlay();
} else {
@ChrisLTD
ChrisLTD / simple-modal.css
Created June 13, 2019 22:17
Simple Modal CSS
.modal, .modal-bg {
display: none;
}
.modal-active .modal-bg {
display: block;
background-color: rgba(0, 0, 0, 0.7);
position: fixed;
top: 0;
left: 0;
@ChrisLTD
ChrisLTD / key-fingerprint
Last active December 2, 2018 23:19 — forked from hasssan/key-fingerprint
view your ssh public key's fingerprint; compare this to what Github has listed in the ssh key audit
# Old format
$ ssh-keygen -l -f ~/.ssh/id_rsa.pub
# New format
$ ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub
// AUTO TWEET UNLIKER
//
// Go to your Twitter profile
// Click on the tab for your likes
// Open up your JS console
// Paste this script in, and hit [return]
var scrollDelay = 1000; // milliseconds
var scrollAmount = 5;
var clickDelay = 600; // milliseconds
@ChrisLTD
ChrisLTD / recalculate-acf-locations.php
Last active November 22, 2021 15:40 — forked from RadGH/recalculate-acf-locations.php
Update ACF location fields
<?php
// Update google map latitude/longitude after importing, using address
//
// https://support.advancedcustomfields.com/forums/topic/how-to-update-google-map-latitudelongitude-after-importing-using-address/
// https://gist.githubusercontent.com/RadGH/428bd8133c34dae60c0c/raw/fbfb0536abd1afc0fad1d2ed2b51c69304406c78/recalculate-acf-locations.php
//
// INSTRUCTIONS
// 1. Grab the file from this Gist and upload it to your theme.
// 2. Configure the options in the variable $ld_recalc. You MUST set the post type, and set the different field keys (see Finding the Field Key).
// 3. Call the file at the top of your functions.php script using include "recalculate-acf-locations.php";