Skip to content

Instantly share code, notes, and snippets.

View Camwyn's full-sized avatar

Stephen Page Camwyn

View GitHub Profile
Camwyn / Looping.php
Created April 16, 2014 14:10
Test for multi-dimensional array search optimization
$loops = 1000000;
$index_array = array(
'Mr. Giggles' => 'first',
'Lucky Pete' => 'second',
'door' => 'third',
'bar' => 'fourth',
'Marius' => 'fifth',
$array = array(
Camwyn / social_Icon_function.php
Last active August 29, 2015 14:17
Function to build social icon list for wordpress
* Output social icons for a post.
* Assumes you have filters for building share URLs named build_twitter_url & etc.
* @param integer $post_id: the id of the post
* @param string $classes: a space-separated list of classes to add to the section
* @param boolean $circled: use circled icons
* @return string HTML section containing the list of icon links
public function social_icons( $post_id = NULL, $classes = '', $circled = FALSE )
# Alot of these configs have been taken from the various places
# on the web, most from here
# Set the colours you can use
Camwyn / SassMeister-input-HTML.html
Created October 15, 2015 07:41
Generated by
<div class="test">TEST</div>
Camwyn / fade.js
Last active October 27, 2015 20:18
Proportionate fade on scroll
( function ( $, document ) {
var fadeItem = function () {
$('.fader').first().each( function() {
var $this = $(this),
$container = $this.parents( '.container' ),
height_percentage = $container.height() / $( document ).height(),
container_offset = $container.offset(),
scroll_percent = $(window).scrollTop() / ($(document).height() - $(window).height() +;
if ( $this.hasClass( 'is_stuck' )) {

Goal: To take this: And derive this: America/Los Angeles From which we can then derive UTC-0800 or UTC-0700, as appropriate under the daylight madness scheme in effect on the date of interest.

It seems oddly hard to figure out what timezone a given point in space is located in. Looking around, there are only a few APIs which provide this information ( and, and only a few datasets which seem to contain it; most of them are in serious GIS formats, and expect you to query them in some manual fashion using a proprietary GIS tool.

I'm not really interested in that; I want a piece of code I can just ask "what timezone is this in" and get an answer, without installing some huge piece of software I don't have a license to or worrying about rate limits from somebody's API. So I'm going to take a shapefile I found here ( and see if we can

# Read through this and modify to taste.
# Tested on:
# dataset_uuid: c36a3d28-80c2-11e1-9ec6-df5bd8b43f76
# sdc:sdc:smartosplus:3.2.0
mkdir /data
useradd -d /data dev
groupadd dev
cd /data
Camwyn /
Last active October 13, 2016 15:08
Steps to archive a git branch


  • git checkout <branch name>
  • git tag archive/<branch name> (yes, this would be "archive/fix/hot_sauce")
  • git push origin <branch name> (pushes the tag(s) to the server)
  • git checkout master (could be any branch other than the one you'r archiving, most repos have a "master")
  • git branch -D <branch name> (delete the branch locally)
  • git push origin —delete <branch name> (push the delete - delete the branch on the server)

##To re-use the branch:

Camwyn / visual-focus.scss
Created November 2, 2016 14:23
Visual focus mixins
// Add styles on active/focus/hover
@mixin visual-focus {
&:hover {
// Remove outline on active/focus/hover
Camwyn / svg-icons.scss
Created November 2, 2016 14:55
Mixin for creating svg icons
* Icon
* Allows easy insertion of an svg icon.
* $icon-name: name of the icon used in the symbol-defs (needs quotes)
* $fill: icon fill color
* $property: background-image or content?
* example: @include icon('cross', '#000', content);
@mixin icon($icon-name, $fill: false, $property: background-image) {