Skip to content

Instantly share code, notes, and snippets.

View thingsinjars's full-sized avatar

Simon Madine thingsinjars

View GitHub Profile
@thingsinjars
thingsinjars / Haversine.js
Created January 22, 2014 15:09
Useful geo functions
function haversineDistance(lat1, lon1, lat2, lon2) {
'use strict';
var R = 6378100; // metres
var dLat = this.deg2rad(lat2 - lat1);
var dLon = this.deg2rad(lon2 - lon1);
var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
@thingsinjars
thingsinjars / JSONformat.json
Created October 21, 2013 18:54
Output of the cucumber JSON formatter
[
{
"id": "Quick-test",
"name": "Quick test",
"description": "",
"line": 1,
"keyword": "Feature",
"uri": "Hardy/tests/quicktests/test.feature",
"elements": [
{
/* "<Given> I wait for "N" seconds */
this.Given(/^I wait for "([^"]*)" seconds$/, function (seconds, callback) {
this.pause(seconds*1000, callback);
});
/* "<Given> I wait for "elementname" to be present" */
this.Given(/^I wait for "([^"]*)" to be present$/, function (selector, callback) {
selector = selectors(selector);
this.waitFor(selector, 1000, function (err, result) {
if(err) {
/* CSS */
html,body, #mapContainer {
font-family:sans-serif;
background:#fff;
color:#444;
height:100%;
padding:0;
margin:0;
}
(function(e,t,n){function h(t,n){this.element=t,this.options=e.extend({},s,n),this._defaults=s,this._plugin=r,this.init()}function p(e,t){var n=new u.kml.Manager;n.addObserver("state",l(function(e){e.state==="finished"&&t.call(this,e)},this)),n.parseKML(e)}function d(t){var n=t.target[t.type];if(e.isFunction(n)){var r=e.Event(t.type,{originalEvent:t,geo:{latitude:t.target.coordinate.latitude,longitude:t.target.coordinate.longitude},target:t.target});n.call(this.element,r)}}function v(e){return typeof e=="function"}var r="jHERE",i="0.2.0",s,o,u,a,f,l=e.proxy,c;s={appId:"_peU-uCkp-j8ovkzFGNU",authToken:"gBoUkAMoxoqIWfxWA5DuMQ",zoom:12,center:[52.49,13.37],enable:["behavior","zoombar","scalebar","typeselector"],type:"map",marker:{text:"",textColor:"#333333",fill:"#ff6347",stroke:"#333333",shape:"balloon",icon:undefined},bubble:{content:"",closable:!0,onclose:e.noop},heatmap:{max:20,opacity:.8,coarseness:2}},e[r]=c={},o=h.prototype,c.defaultCredentials=function(e,t){f={appId:e,authenticationToken:t},a.load().is.d
@thingsinjars
thingsinjars / dabblet.css
Created October 30, 2012 12:45
Strikethrough
/*
* Strikethrough
*/
del {
text-decoration:none;
position:relative;
}
del::after {
@thingsinjars
thingsinjars / step-1.html
Created June 4, 2012 19:02
Web Audio API Example code
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Web Audio API</title>
</head>
<body>
<p class="play">Play</p>
<p class="stop">Stop</p>
@thingsinjars
thingsinjars / dabblet.css
Created February 5, 2012 16:00
Typing animation with pure CSS
/**
* Typing animation with pure CSS
* Revised. Browser support (as of Feb 2012): Firefox, IE10
*/
@keyframes typing { from { width: 0; } }
@keyframes blink-caret { 50% { border-color: transparent; } }
h1 {
font: bold 200% Consolas, Monaco, monospace;
@thingsinjars
thingsinjars / expanded.js
Created February 4, 2012 22:32
A True Tale of Love Lost and Found in an Infinite Number of Acts...
//Our little runner, celebration animation and placeholder
// for an empty set of possible maze generation steps
L="♥",
// q = current font size,
// z = width and generic constant,
// h = animation loop counter
q=z=h=21,
// All the colours we need,
// the hsla is pretty but tricky to shorten
@thingsinjars
thingsinjars / contained.css
Created January 31, 2012 13:25
Background size cover and contain examples
div {
width: 75px;
height: 100px;
background: black url('http://www.developer.nokia.com/Community/Piazza/images/Blog-Icon.png') no-repeat 50%;
background-size: contain;
}