Skip to content

Instantly share code, notes, and snippets.

View raoulwegat's full-sized avatar

Raoul Wegat raoulwegat

View GitHub Profile
@raoulwegat
raoulwegat / gist:ded7ec7892e017b6d3c5
Created March 19, 2015 01:51
Wordpress RICG Responsive Images + Advanced Custom Fields in a Gallery + Cycle2
// Responsive Slideshow in Wordpress
// https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images
// http://www.advancedcustomfields.com/pro
// http://jquery.malsup.com/cycle2/
$images = get_field('gallery');
if( $images ): ?>
<div class="cycle-slideshow"
@raoulwegat
raoulwegat / gist:93be8af56bb4cc062073
Created March 20, 2015 23:22
Varnish4 on Ubuntu 14 startup runlevel priorities
sudo update-rc.d varnish defaults 91 9
@raoulwegat
raoulwegat / gist:0b4ad458f2c74f4c0723
Created March 24, 2015 03:18
Bulk edit apache config ports
sudo find . -type f -print0 | sudo xargs -0 sed -i 's/:8080/:80/g'
@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;
@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: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 / 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 / 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 / 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 / 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>