Skip to content

Instantly share code, notes, and snippets.

/**
Fetch from Weather
This fetches a JSON feed from the Weather system.
*/
var weatherWidget = {
fetch: function ( locId ) {
var weatherForecastUrl = 'http://news.bbc.co.uk/weather/forecast/' + locId + '/Next3DaysJSON.json',
cachebusterStr = 'cachebuster=' + ( new Date().valueOf() ),
locator.geo.getCurrentPosition(
function ( pos ) {
var lat = pos.coords.latitude,
lon = pos.coords.longitude;
// now use locator to search for a matching location
// in the gazetter
locator.searchByCoordinatesWithRadius(
lon,
lat,
@andrewn
andrewn / detect_css_transforms.js
Created February 18, 2011 13:43
Detect if CSS Transforms are supported
var el;
var prefixes = ["Webkit", "Moz", "O"];
// Test whether browser supports the given CSS property
// Name of CSS property to test must be in CamelCase i.e. borderRadius
function testProperty(prop) {
// create element to peform property detection against
el = el \|\| document.createElement("div");
require(['carouselfactory'], function( cf ) {
cf.createCarousel('#mycarousel');
});
@andrewn
andrewn / argh.js
Created May 27, 2011 11:23
attachedTo is not accessible from outside the object
define(['jquery-1'], function($){
var attachedTo = [],
selector = '.toggle';
function init() {
attachedTo = $(selector);
}
function destroy() {
attachedTo = [];
// HACK: Is there a supported way of fetching all
// variables from the view?
// Used to propagate variables to subviews.
$viewData = $this->view->_spectrumViewData;
$this->view->assign("viewData", $viewData);
~$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
ether 70:cd:60:f2:05:3d
media: autoselect (none)
~$ traceroute 192.168.192.10
traceroute to 192.168.192.10 (192.168.192.10), 64 hops max, 52 byte packets
1 * * *
traceroute: sendto: No route to host
2 traceroute: wrote 192.168.192.10 52 chars, ret=-1
*traceroute: sendto: Host is down
traceroute: wrote 192.168.192.10 52 chars, ret=-1
*traceroute: sendto: Host is down
traceroute: wrote 192.168.192.10 52 chars, ret=-1
*
function setCacheMaxAge($ageInSecs)
{
$this->blq->setContentMaxAge($ageInSecs);
$this->blq->setIsUK(true);
$this->blq->setShowAdverts(false);
$this->blq->setCountry('uk');
$this->blq->setContentCacheability('public');
}
@andrewn
andrewn / grid.js
Created September 14, 2011 18:53
GEL bookmarklet
javascript:if(document.createElement && document.childNodes){var bm = document.createElement('script');var head = document.getElementsByTagName('head')[0];head.appendChild(bm);bm.setAttribute('src', 'https://raw.github.com/gist/1217428/grid.js');}else{alert('Sorry, your browser cannot do this')}