Skip to content

Instantly share code, notes, and snippets.

@necolas
necolas / snippet.js
Created June 14, 2011 20:36
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@nickdunn
nickdunn / extension.driver.php
Created July 27, 2011 08:31
Symphony RDF content negotiation (hacky as crap)
<?php
require_once(CORE . '/class.frontend.php');
Class extension_seme4_semantics extends Extension {
public function about() {
return array('name' => 'Seme4 Semantics',
'version' => '1.1',
'release-date' => '2010-03-01',
'author' => array('name' => 'Nick Dunn',
@peterblazejewicz
peterblazejewicz / gist:1203054
Created September 8, 2011 09:59
drag/minimize/maximize/close using {mdm} script
package
{
import flash.events.MouseEvent;
import mdm.Application;
import mdm.Forms;
import mx.core.UIComponent;
import spark.components.Application;
@andrrr
andrrr / ajax-form.xsl
Created September 30, 2011 08:31
Ajax Form
<!-- ================== -->
<!-- = At Normal Page = -->
<!-- ================== -->
<xsl:template match="data">
<h1>Contact Form</h1>
<form method="post" action="{$current-path}">
<xsl:call-template name="send-message"/>
</form>
<script type="text/javascript">
@bzerangue
bzerangue / iCal.xsl
Created November 3, 2011 04:54
[XSLT] iCal utility
<?xml version="1.0" encoding="utf-8"?>
<!--
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
X-WR-TIMEZONE;VALUE=TEXT:US/Central
METHOD:PUBLISH
PRODID:-//Park Cities Presbyterian Church\(PCA\)//iCal 1.0//EN
X-WR-CALNAME;VALUE=TEXT:Park Cities Presbyterian Church Events Feed
VERSION:2.0
BEGIN:VEVENT
@dalethedeveloper
dalethedeveloper / gist:1503252
Created December 20, 2011 21:00
Mobile Device Detection via User Agent RegEx

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(

<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<link rel="stylesheet" href="workspace/assets/style.css"/>
</head>
<body>
<div id="head">
<h1>Title</h1>
</div>
<div id="package">
@brendo
brendo / ajax-upload.js
Created January 13, 2012 00:54
Uploading a File with AJAX with Symphony
$(document).ready(function() {
// FormData is magic.
var formData = new FormData();
// Listen for drag/drop events.
$('#drop-here')
.on('dragover', function(event) {
event.preventDefault();
})
.on('drop', function(event) {
@DavidOliver
DavidOliver / data.parts.php
Created February 10, 2012 14:33
Calculating parts prices - Symphony CMS
<?php
public function grab(&$param_pool=NULL){
$result = new XMLElement($this->dsParamROOTELEMENT);
try{
include(TOOLKIT . '/data-sources/datasource.section.php');
}
catch(FrontendPageNotFoundException $e){
// Work around. This ensures the 404 page is displayed and
// is not picked up by the default catch() statement below
@hakre
hakre / some-iterator-fun.php
Created February 28, 2012 06:59
Some Iterator Fun
<?php
/*
* Some Iterator Fun
*
* @link http://hakre.wordpress.com/2012/02/28/some-php-iterator-fun/
*/
/**
* Iterator that fetches each iteration value from a