Skip to content

Instantly share code, notes, and snippets.

View johnwards's full-sized avatar

johnwards johnwards

  • Oxfordshire/Birmingham/London
View GitHub Profile
<script type="text/javascript">
// See MDN: https://developer.mozilla.org/en-US/docs/DOM/MutationObserver?redirectlocale=en-US&redirectslug=DOM%2FDOM_Mutation_Observers
(function(){
// select the target node
var target = document.querySelector('body');
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var i={};
// create an observer instance
var observer = new MutationObserver(function(mutations) {

##Preview

Description

Simple Dashing widget (and associated job) to display current alerts from your server density account.

##Dependencies

//Animation to move the bird left to right
@-moz-keyframes birdy-left-right {
0% { -moz-transform: translate(500px, 0px); }
50% { -moz-transform: translate(0px, 0px); }
100% { -moz-transform: translate(500px, 0px); }
}
//Animation to make the bird flip to point in direction of travel
@-moz-keyframes birdy-flip {
40% { -moz-transform: scaleX(1); }
<div class="scene">
<div class="birdy-left-right">
<div class="birdy-left-right faster">
<div class="birdy-flip">
<div class="birdy"></div>
</div>
</div>
</div>
</div>
<div class="scene">
<div class="birdy-left-right">
<div class="birdy-left-right faster">
<div class="birdy-flip">
<div class="birdy"></div>
</div>
</div>
</div>
</div>
@johnwards
johnwards / lastValue.js
Created May 15, 2012 11:39
get the value of last row in a sheet in google docs
function lastValue(column) {
var parts = column.split("!");
if (parts.length == 2) {
var sheetName = parts[0];
var column = parts[1];
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
} else {
var column = parts[0];
var sheet = SpreadsheetApp.getActiveSheet();
}
@johnwards
johnwards / animate.js
Created October 10, 2011 19:41
Animate a bike or something
function backgroundPosition(obj){
bgPos = obj.css('background-position');
if(typeof(bgPos) === 'undefined') { bgPos = obj.css('background-position-x') + ' ' + obj.css('background-position-y') };
return bgPos;
}
var bike = $("#bike");
var currentPos = parseInt(backgroundPosition(bike).split(" ")[0]);
var frameWidth = parseInt(bike.outerWidth());
var frames = currentPos/frameWidth;
@johnwards
johnwards / bootstrap.php
Created August 4, 2011 14:15
Sending emails in Silex via Swiftmailer spool
<?php
//...your silex bootstrap.
//Configure Swiftmail to use SMTP.
$app->register(new SwiftmailerExtension(), array(
'swiftmailer.options' => array(
'host' => 'smtp.gmail.com',
'port' => 465,
'username' => 'silex.swiftmailer@gmail.com',
@johnwards
johnwards / UploadTest
Created August 2, 2011 15:36
Send yourself to a non existant route. The file should be in the file bag...it's missing :(
<?php
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class UploadTest extends WebTestCase
{
public function testNewPhotos()
{
$client = $this->createClient();
@johnwards
johnwards / MessageLogger.php
Created August 1, 2011 11:14
Testing Swiftmailer in a Silex app
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/