Skip to content

Instantly share code, notes, and snippets.

View caillou's full-sized avatar

Pierre Spring caillou

View GitHub Profile
@caillou
caillou / gist:1390151
Created November 23, 2011 22:41
Google's clearQuery code
gh.addEventListener("mousedown", function(a) {
a.preventDefault();
S.value = "";
S.value = S.value; // hrhrhr...
if (T)
jh.innerText = T.innerText = ""; // hrhrhr...
yg++;
vg = ug = 0;
S.focus(); // interesting. it really has no effect.
zh();
@caillou
caillou / gist:1420463
Created December 1, 2011 22:48
Possible addition to moment.js
// We assume it's Friday, December 2nd, 2 PM
// This could be interesting for a listing of events in a calendar.
// Two Questions:
// 1. How would you call the function?
// 2. What would you return for the dates in 1 and 2 weeks?
moment().xxx() // "Today at 2 PM"
moment().add('hours', 1).xxx() // "Today at 3 PM"
@caillou
caillou / gist:1446583
Created December 8, 2011 09:44
Translation for relativeDate of moment.js
/*jslint white: false */
var langs;
langs = {
"de" : {
today: "heute um %time",
tomorrow: 'morgen um %time',
next: '%weekday um %time',
yesterday: 'gestern um %time',
@caillou
caillou / gist:1931490
Created February 28, 2012 09:19
Rewrite URLs in Wordpress
<?php
/*
Plugin Name: ReWrite
Plugin URI: http://nelm.io/
Description: A Plugin to ReWrite URLs.
Version: 0.1
Author: Pierre Spring
Author URI: http://nelm.io/pierre
License: GPL2
*/
@caillou
caillou / gist:2021918
Created March 12, 2012 13:25
Track mailto, file download and external links using Google Analytics
/*globals pageTracker: true */
(function () {
"use strict";
var delegate, clickCallback, handleLink, track;
// generic delegate function
delegate = function (element, tagName, eventName, callback) {
var eventListener;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css">
path {
fill: none;
stroke: black;
}
</style>
.tree > ul > li > ul > li > ul > li {
@levelPadding: 25px;
padding-left: @levelPadding;
& > ul > li {
margin-left: -@levelPadding;
padding-left: @levelPadding * 2;
& > ul > li {
margin-left: -@levelPadding * 2;
padding-left: @levelPadding * 3;
{
"color_scheme": "Packages/User/Monokai-Seld.tmTheme",
"font_size": 15.0,
"ignored_packages":
[
"SublimeCodeIntel"
],
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}
@caillou
caillou / communes.json
Created September 7, 2012 08:40
D3 Demo
[{"zip":"1002","0":"1002","name":"Lausanne","1":"Lausanne","y":"536715","2":"536715","x":"151315","3":"151315","latitude":"46.5101","4":"46.5101","longitude":"6.61407","5":"6.61407","merc_x":"736275","6":"736275","merc_y":"5831470","7":"5831470","pixel_x":"177","8":"177","pixel_y":"437","9":"437","canton":"VD","10":"VD"},{"zip":"1008","0":"1008","name":"Prilly","1":"Prilly","y":"534375","2":"534375","x":"153265","3":"153265","latitude":"46.5275","4":"46.5275","longitude":"6.58331","5":"6.58331","merc_x":"732851","6":"732851","merc_y":"5834260","7":"5834260","pixel_x":"170","8":"170","pixel_y":"431","9":"431","canton":"VD","10":"VD"},{"zip":"1009","0":"1009","name":"Pully","1":"Pully","y":"538470","2":"538470","x":"150535","3":"150535","latitude":"46.5033","4":"46.5033","longitude":"6.63704","5":"6.63704","merc_x":"738832","6":"738832","merc_y":"5830360","7":"5830360","pixel_x":"182","8":"182","pixel_y":"440","9":"440","canton":"VD","10":"VD"},{"zip":"1020","0":"1020","name":"Renens","1":"Renens","y":"533595",
<!doctype html>
<html>
<head>
<!-- Run in full-screen mode. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Make the status bar black with white text. -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">