Skip to content

Instantly share code, notes, and snippets.

View raoulwegat's full-sized avatar

Raoul Wegat raoulwegat

View GitHub Profile
@raoulwegat
raoulwegat / override puppeteer default browser.md
Created October 18, 2023 00:29
override puppeteer default browser.md

override puppeteer default browser

When using criticalCSS on Apple Silicon hardware in an arm64 linux virtual machine, puppeteer installs an x86-64 version of chromium which will not launch and will cause and npm run command to fail.

This problem can be solved by firstly installing chromium-browser which is a native arm64 and x86-64 build:

sudo apt install chromium-browser
@raoulwegat
raoulwegat / Get PHP-FPM Average Memory Usage.md
Last active September 16, 2023 04:32
PHP-FPM Average Memory Usage.md

Get PHP-FPM Average Memory Usage

ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | grep php-fpm
@raoulwegat
raoulwegat / _readme.txt
Last active May 2, 2023 08:16
Including Photoswipe 5.2+ with laravelmix/webpack 4
Photoswipe 5.2 was rewritten in ES6 and it needs to be transpiled to ES5 to work with Laravel Mix 4 (which used Webpack 4).
If you try a regular import as per the Photoswipe docs, it won't work. You'll need to add this webpack config to your
webpack.mix.js and import the modules in your js file as per below.
@raoulwegat
raoulwegat / md2html.py
Last active November 18, 2022 02:34
Convert a directory of *.md to *.html. Based on https://gist.github.com/jiffyclub/5015986
#!/usr/bin/python3
import sys
import os
import re
import jinja2
import markdown
TEMPLATE = """<!DOCTYPE html>
@raoulwegat
raoulwegat / convert-svg-png.sh
Created February 16, 2017 19:26
Convert SVG to PNG
#!/bin/bash
# Batch convert SVG to PNG. Useful for creating new sizes of twemoji.
# Uses https://wiki.gnome.org/Projects/LibRsvg. On macOS install with 'brew install librsvg'
for file in svg/*.svg
do
filename="$(basename $file)"
name=$(echo $filename | cut -f 1 -d '.')
echo "Converting $file to $name.png"
rsvg-convert -h 36 -w 36 $file > 36x36/$name.png
done
@raoulwegat
raoulwegat / Set parent height of absolutely positioned child.js
Last active December 16, 2015 21:29
Set parent height of absolutely positioned child
// set figure heights based on child image + figcaption heights
$(document).ready(function(){
setFigureHeight();
$(window).on('resize', setFigureHeight);
});
function setFigureHeight() {
$('.story-image').each(function(index,value) {
imgHeight = $(this).outerHeight(true);
capHeight = $(this).next('figcaption').outerHeight(true);
figHeight = imgHeight + capHeight;
@raoulwegat
raoulwegat / Add Site to DNS.scpt
Created November 25, 2012 08:43
OS X service to add folder name to localhost DNS
tell application "Finder"
set theItems to selection
set folderName to name of item 1 of theItems
do shell script "sudo dscl localhost -create /Local/Default/Hosts/" & folderName & ".dev IPAddress 127.0.0.1"
end tell
@raoulwegat
raoulwegat / gist:fc8e1b7a95e97eca70e5
Created April 1, 2015 01:49
WordPress custom post type with custom ordered post navigation
<?php
/*
* I have a custom post type for my Portfolio, using Advanced Custom Fields for extra fields including a field for me to
* order the portfolio entires how I want. Standard single navigation using previous_post_link and next_post_link don't work as they
* return the order the posts were added. This fixes things:
*/
// New query
$args = array(
@raoulwegat
raoulwegat / gist:f3aa71e103e59ef7105f
Created March 26, 2015 00:16
Ubuntu 14 Varnish 4 init.d
sudo update-rc.d varnish defaults 91 9
@raoulwegat
raoulwegat / gist:c9bf43b056debd3eb584
Created March 24, 2015 17:09
Varnish 4 WordPress VCL found on Dropbox
# This is my VCL file for Varnish 4.0.2 & Wordpress 4.0
#
# ASSUME The builtin VCL is called afterwards.
#
# Specify VCL new 4.0 format.
vcl 4.0;
# Imports
import std;