Skip to content

Instantly share code, notes, and snippets.

View steffex's full-sized avatar

Stefan Jansen steffex

View GitHub Profile
@shospodarets
shospodarets / Chrome headless Puppeteer- capture DOM element screenshot using
Last active January 17, 2023 18:52
Chrome headless Puppeteer- capture DOM element screenshot using
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1});
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'});
@denvers
denvers / wordpress-asset-browser-cache.php
Created April 20, 2017 08:01
Use this simple WordPress function to avoid browser cache issues after updating your CSS / JS assets. Each time you update your assets the URL will change to force browsers to re-download your asset. Yeah, dab!
<?php
// add to functions.php
/**
* cache_proof_asset_url
* @param string $asset_file (relative, eg: /css/style.css)
* @return string $asset_file_url (absolute, eg: https://www.domain.com/css/style.css?v=123456789)
*/
function cache_proof_asset_url($asset_file) {
$full_asset_url = bloginfo('stylesheet_directory') . $asset_file;
@benshimmin
benshimmin / gist:4088493
Created November 16, 2012 16:03
Scale to fit and centre-align an image with FPDF
<?php
/* Caveat: I'm not a PHP programmer, so this may or may
* not be the most idiomatic code...
*
* FPDF is a free PHP library for creating PDFs:
* http://www.fpdf.org/
*/
require("fpdf.php");
class PDF extends FPDF {
@kconragan
kconragan / keyrepeat.shell
Last active December 4, 2023 03:40
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.