Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ptz0n's full-sized avatar

Erik Eng ptz0n

View GitHub Profile
@ptz0n
ptz0n / example.php
Created March 18, 2011 08:42
Tågtider API - Example Request
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<h1>Tågtider API - Exempel</h1>
<pre><?php
// Setup
$url = 'http://api.tagtider.net/v1/stations.json';
$key = 'tagtider';
$secret = 'codemocracy';
@ptz0n
ptz0n / timetable.db.php
Created July 21, 2011 14:25
Magic call method for setting and removing object references with Redis
/**
* Basic call method for setting and removing object properties
*
* @param String $method
* @param Array $args
*
* @return Mixed
*
* @access public
*/
@ptz0n
ptz0n / gist:1217080
Created September 14, 2011 16:51
Validate JSONP Callback
<?php
/**
* Validate JSONP Callback
*
* https://github.com/tav/scripts/blob/master/validate_jsonp.py
* https://github.com/talis/jsonp-validator/blob/master/src/main/java/com/talis/jsonp/JsonpCallbackValidator.java
* http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html
* http://news.ycombinator.com/item?id=809291
*
@ptz0n
ptz0n / gist:1246066
Last active February 9, 2017 12:20
Trafikverket exponerar API
<!DOCTYPE html>
<html><head><meta charset="UTF-8" /><title>Trafikverket exponerar API</title></head><body><pre><?php
/**
* @author Erik Eng <erik@eng.se>
*
* @url http://tagtider.net/blogg/tjanster/trafikverket-exponerar-api/
*
*/
$headers = array(
@ptz0n
ptz0n / gist:1361995
Created November 13, 2011 11:17
YN string to dates
/**
* YN string to dates
*
* @param string $from
* @param string $to
* @param string $yn
*
* @return array $dates
*/
function ynToDates($from, $to, $yn)
@ptz0n
ptz0n / gist:1362197
Created November 13, 2011 15:06
Seconds since midnight to date
<?php
/**
* Seconds since midnight to date
*
* @param string $date
* @param int $seconds
*
* @return string
*/
@ptz0n
ptz0n / gist:1432870
Created December 5, 2011 08:35
Image manipulation
<?php
/**
* Resize Image Class
*
* @author Erik Pettersson <mail@ptz0n.se>
* @copyright 2011 Erik Pettersson <mail@ptz0n.se>
* @license http://www.opensource.org/licenses/mit-license.php MIT
*/
class Image {
@ptz0n
ptz0n / gist:1560274
Created January 4, 2012 14:30
Convert geographical coordinates with Triona
<?php
/**
* Convert coordinates with projection
*
* @param string $easting X coordinate
* @param string $northing Y coordinate
* @param string $projection
*
* @return array
@ptz0n
ptz0n / gist:1646171
Created January 20, 2012 08:43
Recursive merge of arrays with integer keys
<?php
/**
* Merge two dimensional arrays my way
*
* Will merge keys even if they are of type int
*
* @param array $array1 Initial array to merge.
* @param array ... Variable list of arrays to recursively merge.
*
@ptz0n
ptz0n / _respond.scss
Created July 22, 2012 10:11
Sass respond to mixin
@mixin respond-to($media) {
@if $media == landscape {
@media screen and (min-width: 321px) { @content; }
}
@else if $media == tablet {
@media only screen and (min-width: 768px) { @content; }
}
@else if $media == desktop {
@media only screen and (min-width: 992px) { @content; }
}