Skip to content

Instantly share code, notes, and snippets.

View cecilemuller's full-sized avatar

Cecile Muller cecilemuller

View GitHub Profile
@cecilemuller
cecilemuller / script.js
Created March 4, 2012 12:34
Dynamic template from an arbitrary string, using Jquery Templates
/**
* Dynamic template from an arbitrary string
* (which could be stored in an external file or even in a database).
*
* Works even without the "plus" extension of the Templates plugin.
* http://github.com/nje/jquery-tmpl
*/
var MyData = {hello: "world"};
$.template("MyInlineTemplate", "<div>Hello ${hello}</div>");
$.tmpl("MyInlineTemplate", MyData).appendTo("#contents");
@cecilemuller
cecilemuller / _extensions.js
Created March 4, 2012 12:53
Extend Bing Maps AJAX 6.3 to create pushpins, polylines and polygons easily
/**
* VEMap.CreatePushpin(point, options) and similar functions
* to create advanced pins, polylines & polygons easily in Bing Maps.
*/
function _addshapeoptions(scope_, type_, points_, options_){
var shape = new VEShape(type_, points_);
options_ = options_ || false;
if (options_){
for (var key in options_){
@cecilemuller
cecilemuller / _extensions.js
Created March 4, 2012 12:59
Animated pushpins in Bing Maps AJAX 6.3
/**
* This snipplet adds the following methods:
* VEMap.DropPushpin
* VEShapeLayer.DropPushpin
*
* This is similar to VEMap.AddPushpin except the pin is animated (it "falls" on the map).
*
* Works even in IE6 and the IPhone. Generic solution based on this proof of concept:
* http://www.garzilla.net/vemaps/DropPushPin.aspx
*/
@cecilemuller
cecilemuller / _extensions.js
Created March 4, 2012 13:23
Touch support for Bing Maps 6.3 (e.g. for Iphone webapps)
/**
* Adds pan and zoom support for touch-based devices.
* Works best with fixed-size viewports, however VEMap.ZoomIn & VEMap.ZoomOut
* are very unreliable on the IPhone, you should keep the mini dashboard as a fallback.
*/
VEMap.prototype.EnableTouch = function(){
if (typeof Touch == "object"){
var map = this;
// Whether a gesture is being performed currently or not.
@cecilemuller
cecilemuller / FragmentShader.wrl
Created March 4, 2012 13:30
Three ways to embed an HLSL shader in VRML/X3D
#VRML V2.0 utf8
Transform {
translation -4 2 0
children Shape {
appearance Appearance{
material Material{
diffuseColor 0 0 0
emissiveColor 1 1 1
}
@cecilemuller
cecilemuller / gist:1973043
Created March 4, 2012 13:43
Bounding box of a MULTIPOLYGON column in PostGIS
-- If `polygons` is a column that contains MULTIPOLYGON values,
-- this returns one row per polygon.
SELECT
id AS id,
ST_Box2D((ST_Dump(polygons)).geom) AS bbox
FROM
mytable
WHERE
polygons IS NOT NULL
@cecilemuller
cecilemuller / gist:1973079
Created March 4, 2012 13:47
Programmatically log out the user in Drupal 6
<?php
global $user;
$tmp = NULL;
session_destroy();
user_module_invoke('logout', $tmp, $user);
$user = drupal_anonymous_user();
?>
@cecilemuller
cecilemuller / gist:1973090
Created March 4, 2012 13:51
Force the admin theme on additional non-admin paths in Drupal 6
<?php
/**
* In this example, it uses the administration theme on "node creation", "node edition",
* "user registration", "user profile" and "forgot password" pages.
*/
function MODULENAME_init(){
// The list of paths on which to use the administration theme
@cecilemuller
cecilemuller / example-1.js
Created March 4, 2012 13:58
Infoboxes for Bing Maps AJAX 7.0 (standard, custom, ajax and sticky)
/*********************************************************************************************
* Pin 1: Standard non-sticky autogenerated infobox.
*********************************************************************************************/
var pin1 = map.AddPushpin(
new Microsoft.Maps.Location(50, 0),
{
text: '1',
// Standard infobox settings
title: 'Standard (non-sticky) infobox',
@cecilemuller
cecilemuller / gist:1973130
Created March 4, 2012 14:03
Full-width dashboard in Bing Maps AJAX 7.0
/**
* By default, the new dashboard (the white components bar on top of the map) is only 350 pixels wide,
* but you can easily make it use the whole space available with CSS.
*
* "mapContainer" is the id of the div that contains the Map.
* If you are using only one map on the map, you can use ".MicrosoftMap .NavBar" directly
*/
#mapContainer .MicrosoftMap .NavBar {
width: 100%;