This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
if (navigator.appName == 'Netscape') | |
var language = navigator.language; | |
else if (navigator.appName == 'Microsoft Internet Explorer') | |
var language = navigator.browserLanguage; | |
if (language.indexOf('en') > -1) document.location.href = '/en/index.jsp'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See: http://blog.liip.ch/archive/2008/09/18/fotd-reflectionclass-newinstanceargs-args-is-slow.html | |
/* Results on my box: | |
$ php -v | |
PHP 5.2.6-pl7-gentoo (cli) (built: Sep 22 2008 08:13:50) | |
Copyright (c) 1997-2008 The PHP Group | |
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies | |
$ php test.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// open: http://www.iphone-conference.ch/speakers | |
// copy and paste this into your address bar (with Firefox or Opera, for example): | |
javascript:Array.prototype.slice.call(document.getElementsByTagName("img")).map(function(k){k.removeAttribute("width");});void(null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<meta charset="utf-8"> | |
<title>No script failure</title> | |
<style> | |
noscript{display:inline;} | |
</style> | |
<noscript>will be visible with Opera.</noscript> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ajax(obj) { | |
// data | |
obj.type = obj.type ? obj.type.toUpperCase() : "GET"; | |
obj.data = obj.data || ""; | |
obj.dataType = obj.dataType || "application/x-www-form-urlencoded"; | |
obj.aborted = false; | |
// callbacks | |
obj.success = obj.success || function() {}; | |
obj.error = obj.error || function() {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using XPath with namespace | |
// @see https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript#Evaluating_against_an_XML_document_within_an_Extension | |
var ns = "urn:Spam", xml = document.implementation.createDocument(ns, "eggs", null); | |
xml.documentElement.appendChild(xml.createElementNS(ns, "sausage")); | |
xml.documentElement.appendChild(xml.createElementNS(ns, "spam")); | |
xml.documentElement.appendChild(xml.createElementNS(ns, "sausage")); | |
// there is only one namespace used here. | |
var resolver = function(namespace) { return ns; }; | |
var result = xml.evaluate("count(//spam:sausage)", xml, resolver, XPathResult.ANY_TYPE, null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<title>Event delegation</title> | |
<ul> | |
<li><a href="#a">a</a></li> | |
<li><a href="#b"><span>b</span></a></li> | |
<li><a href="#c"><span><span>c</span></span></a></li> | |
<li><a href="#d"><span><span><span>d</span></span></span></a></li> | |
</ul> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Element.prototype.getElementsByClassName (using XPath or getElementsByTagName) | |
// Monkeypatching is evil | |
if(typeof Element.getElementsByClassName === "undefined") { | |
if("evaluate" in document) { | |
Element.prototype.getElementsByClassName = function(className) { | |
var result = document.evaluate(".//*[contains(concat(' ', @class, ' '), '"+className+"')]", this, null, XPathResult.ANY_TYPE, null), | |
node, | |
elements = []; | |
while(node = result.iterateNext()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env seed | |
var __author__ = "Yoan Blanc <[email protected]>"; | |
// This program is free software: you can redistribute it and/or modify | |
// it under the terms of the GNU General Public License as published by | |
// the Free Software Foundation, either version 3 of the License, or | |
// (at your option) any later version. | |
// | |
// This program is distributed in the hope that it will be useful, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple async call using libsoup on twitter.com | |
// author: Yoan Blanc | |
// compiled using: gcc twitter.c `pkg-config --cflags libsoup-2.4` `pkg-config --libs libsoup-2.4` | |
#include <stdio.h> | |
#include <glib-object.h> | |
#include <libsoup/soup.h> | |
static GMainLoop *main_loop = NULL; | |
OlderNewer