Skip to content

Instantly share code, notes, and snippets.

View cecilemuller's full-sized avatar

Cecile Muller cecilemuller

View GitHub Profile
@cecilemuller
cecilemuller / gist:1973138
Created March 4, 2012 14:05
Draggable Pushpins in Bing Maps AJAX 7.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=de-de" type="text/javascript" charset="UTF-8"></script>
</head>
<body onload="init();">
<div id="myMap" style="position: relative; width: 800px; height: 300px;"></div>
@cecilemuller
cecilemuller / gist:1973161
Created March 4, 2012 14:11
Nicer dashboard and Map.setView padding in Bing Maps AJAX 7.0
/**
* Moves the NavBar "outside" of the map so that it doesn't interfer with Map.setView
* and adds a subtle shadow on the NavBar and its dropdown menus.
*/
#YourMapContainer {
overflow: hidden;
}
#YourMapContainer .MicrosoftMap {
@cecilemuller
cecilemuller / _extension.js
Created March 4, 2012 14:14
jQuery events from non-DOM objects (supports chaining)
/************************
* Class definition
************************/
var MyObjectClass = function(parameters){
var $ = jQuery;
var context = this;
/**
@cecilemuller
cecilemuller / gist:1973187
Created March 4, 2012 14:18
Get the current map style, even in automatic mode, in Bing Maps AJAX 7.0
var map = new Microsoft.Maps.Map(
document.getElementById("map"),
{
credentials: "YOUR-BING-KEY",
mapTypeId: Microsoft.Maps.MapTypeId.auto
}
);
Microsoft.Maps.Events.addHandler(map, "imagerychanged",
function(){
@cecilemuller
cecilemuller / gist:1973197
Created March 4, 2012 14:22
Programmatically change the active theme in Drupal 6
<?php
function MODULENAME_init(){
global $custom_theme;
$custom_theme = 'garland';
}
/**
* Theme name callback: without parameters.
@cecilemuller
cecilemuller / gist:1973201
Created March 4, 2012 14:23
Programmatically change the active theme in Drupal 7
<?php
/**
* Defines a theme callback function per registered path.
*/
function MODULENAME_menu_alter(&$items) {
$items['node/%node']['theme callback'] = 'MODULENAME_default_node_theme';
$items['node/%node/edit']['theme callback'] = 'MODULENAME_edit_node_theme';
$items['node/%node/edit']['theme arguments'] = array(1);
}
@cecilemuller
cecilemuller / gist:1973248
Created March 4, 2012 14:28
taxonomy_select_nodes with multiple terms, in Drupal 7
<?php
/**
* In Drupal 6, `taxonomy_select_nodes` was able to filter by multiple terms,
* but Drupal 7 accepts only one TermID.
*/
function taxonomy_select_nodes_multiple($tids = array(), $operator = 'or'){
$nids = array();
if (variable_get('taxonomy_maintain_index_table', TRUE)){
@cecilemuller
cecilemuller / gist:1973253
Created March 4, 2012 14:30
Add a shortcut to "Create Node" at /admin in Drupal 6
<?php
/**
* Implementation of hook_menu().
*
* Add a shortcut to "create node" in the Admin page for users
* that have the permission to create at least one type, in Drupal 6.
*/
function MODULENAME_menu(){
return array(
@cecilemuller
cecilemuller / gist:2016921
Created March 11, 2012 15:59
Click the 3D Sphere to hide a <div>, using X3DOM
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Touchsensor in X3DOM</title>
<link href="x3dom.css" rel="stylesheet" />
<style>
#myDiv {
color: blue;
@cecilemuller
cecilemuller / gist:2135802
Created March 20, 2012 13:48
Calculate the Viewpoint orientation to look at a specific target position in VRML or X3D
/**
* `target` is where you want to look at.
*
* `position` is the SFVec3f location of your viewpoint.
*
* `orientation ` is the resulting SFRotation of your viewpoint.
*
* Optionally, modify `new SFVec3f(0, 0, -1)` to change the roll.
*
*/