Skip to content

Instantly share code, notes, and snippets.

View Camwyn's full-sized avatar
🐫
yup

Stephen Page Camwyn

🐫
yup
View GitHub Profile

Goal: To take this: https://graph.facebook.com/105464892820215 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 (http://www.earthtools.org/webservices.htm#timezone and http://www.worldweatheronline.com/time-zone-api.aspx), 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 (http://efele.net/maps/tz/world/) and see if we can

#!/bin/pseudo-bash
# 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
Camwyn / Looping.php
Created April 16, 2014 14:10
Test for multi-dimensional array search optimization
<?php
$loops = 1000000;
$index_array = array(
'Mr. Giggles' => 'first',
'Lucky Pete' => 'second',
'door' => 'third',
'bar' => 'fourth',
'Marius' => 'fifth',
);
$array = array(
@Camwyn
Camwyn / social_Icon_function.php
Last active August 29, 2015 14:17
Function to build social icon list for wordpress
<?php
/**
* 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 )
@Camwyn
Camwyn / OMGGITSVNBBQ.md
Last active May 27, 2022 13:35
PUSH to VIP

#GIT/SVN to VIP (OMG GITSVN BBQ!)

Created and maintained to ease pushing a git repo to VIP (svn)

Notes: <branch name> is the name of your feature/fix/whatever branch so if you’re merging a branch named fix/hot-sauce then substitute “fix/hot-sauce" wherever you see <branch name>

###MERGE:

  • git checkout master
  • git pull
  • git merge --no-ff <branch name>

###SVN PUSH:

@Camwyn
Camwyn / .gitconfig
Last active July 29, 2020 15:19
My aliases for git
[alias]
# archive a branch
ab = !sh -c 'git checkout $1 && git pull && git tag archive/$1 && git push origin $1 && git push origin archive/$1 && git checkout master && git branch -D $1 && git push origin --delete $1' -
# archive a branch (to a remote other than origin)
abb = !sh -c 'git checkout $1 && git pull $2 $1 && git tag archive/$1 && git push $2 $1 && git push $2 archive/$1 && git checkout master && git branch -D $1 && git push $2 --delete $1' -
# list aliases
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /'
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@Camwyn
Camwyn / SassMeister-input-HTML.html
Created October 15, 2015 07:41
Generated by SassMeister.com.
<div class="test">TEST</div>
@Camwyn
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() + container_offset.top);
if ( $this.hasClass( 'is_stuck' )) {
@Camwyn
Camwyn / README.md
Last active October 13, 2016 15:08
Steps to archive a git branch

##ARCHIVING A 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: