Skip to content

Instantly share code, notes, and snippets.

View Eworm's full-sized avatar
💭
Happy

Wout Mager Eworm

💭
Happy
View GitHub Profile
@mishterk
mishterk / LocalValetDriver.php
Last active March 1, 2024 22:00
A local Valet driver for proxying images to a remote host
<?php
/**
* Class LocalValetDriver
*
* This class demonstrates how we might go about proxying any missing local images to a remote host. i.e; the production
* site. This has been created with WordPress in mind but could be adjusted to work with any other system.
*/
class LocalValetDriver extends WordPressValetDriver {
@bacoords
bacoords / grab_vimeo_thumbnail.php
Last active January 24, 2024 09:40
Grab a thumbnail of a private (but embeddable) Vimeo video
<?php
/**
* Grab the url of a publicly embeddable video hosted on vimeo
* @param str $video_url The "embed" url of a video
* @return str The url of the thumbnail, or false if there's an error
*/
function grab_vimeo_thumbnail($vimeo_url){
if( !$vimeo_url ) return false;
$data = json_decode( file_get_contents( 'http://vimeo.com/api/oembed.json?url=' . $vimeo_url ) );
@cfaria
cfaria / migrateorders.php
Last active February 12, 2024 16:45 — forked from maddisondesigns/migrateorders.php
Migrate WooCommerce Orders
<?php
//increase max execution time of this script to 150 min:
ini_set('max_execution_time', 9000);
//increase Allowed Memory Size of this script:
ini_set('memory_limit','960M');
// Copies woocommerce orders and users over from source to target.
// I use this on my local machine - loading both db's up there side by side
// could easily adjust the connect strings to connect elsewhere if needed.
@davidjb
davidjb / acceleration-demo.html
Last active June 7, 2019 22:16
Web API demos for acceleration, compass (non-standard), directions, geolocation and more.
<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<body>
<script type="text/javascript" charset="utf-8">
var counter = 0;
var timeout;
window.addEventListener('devicemotion', function(event) {
var accel = event.acceleration;
@seebz
seebz / iCal.php
Last active February 21, 2024 13:03
iCal PHP Parser
<?php
class iCal
{
/**
* @var string
*/
public $title;
@willpatera
willpatera / Google-Sheet-Form-Post.md
Last active November 20, 2023 06:53
Post to google spreadsheet from html form

Overview

This collection of files serves as a simple static demonstration of how to post to a google spreadsheet from an external html <form> following the example by Martin Hawksey

Depreciation Warning: This code is not maintained, and should be seen as reference implementation only. If you're looking to add features or update, fork the code and update as needed.

Run example

You should be able to just open index.html in your browser and test locally.

@hdragomir
hdragomir / sm-annotated.html
Last active March 5, 2024 08:57
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@benlumley
benlumley / migrateorders.php
Created December 5, 2013 22:57
Script to migrate woocommerce orders from one wordpress database into another, along with associated data.
<?php
// Copies woocommerce orders and users over from source to target.
// I use this on my local machine - loading both db's up there side by side
// could easily adjust the connect strings to connect elsewhere if needed.
// will change order ids
// My use case for this is when I've got a staging/test version of a site with new posts/products/pages etc, that needs
// to go live without the loss of any orders placed on the site site since we copied it to the staging site.
@stefthoen
stefthoen / functions.php
Last active February 12, 2016 21:33
WordPress function to create picturefill HTML.
function get_responsive_image($id, $src, $alt = "") {
$large = wp_get_attachment_image_src( $id, 'large' );
$medium = wp_get_attachment_image_src( $id, 'medium' );
$small = wp_get_attachment_image_src( $id, 'thumbnail' );
$output = '<div class="img-responsive">';
$output.= ' <div data-picture data-alt="' . $alt . '">';
$output.= ' <div data-src="' . $small[0] . '"></div>';
$output.= ' <div data-src="' . $medium[0] . '" data-media="(min-width: 786px)"></div>';
$output.= ' <div data-src="' . $large[0] . '" data-media="(min-width: 920px)"></div>';
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 14, 2024 08:46
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation