Skip to content

Instantly share code, notes, and snippets.

View dolmen's full-sized avatar
😁
Happy!

Olivier Mengué dolmen

😁
Happy!
View GitHub Profile
@dolmen
dolmen / CleanHtmlURIResolver.java
Created June 1, 2010 14:08
XSLT processor in Java, with an URI Resolver
import javax.xml.transform.URIResolver;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.TagNode;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.PrettyXmlSerializer;
@dolmen
dolmen / json2xml.js
Created August 25, 2010 16:14
JSON to XML serializer
// A serialization of a JavaScript object to XML
// TODO: test suite
function json2xml(o, tab) {
var xml=[], addChild = function(name, v, ind) {
var childs;
if (v instanceof Array) {
for (var i=0, n=v.length; i<n; i++)
addChild(name, v[i], ind);
} else if (typeof(v) == "object") {
xml.push(ind, "<", name);
@dolmen
dolmen / which.cmd
Created August 27, 2010 16:42
'which' command for Win32
@echo off
:: Copyright © 2010-2011 Olivier Mengu‚
::
:: 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,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
@dolmen
dolmen / cpants-rank.pl
Created August 30, 2010 22:29
Kwalitee rank for an Acme::CPANAuthors list (from CPANTS)
#!/usr/bin/perl
# Author: Olivier Mengué
# 2010-08-21
use utf8;
use strict;
use warnings;
use Acme::CPANAuthors;
use ORDB::CPANTS 0.05;
use List::Util qw(reduce);
@dolmen
dolmen / so-3747049.xslt
Created October 1, 2010 16:50
My answer to StackOverflow #3747049
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- My answer to StackOverflow #3747049 -->
<xsl:output method="text"/>
<xsl:key name="ns" match="//* | //*/@* | //*/processing-instruction()" use="namespace-uri(.)"/>
<xsl:key name="ns-prefixes" match="//* | //*/@*" use="concat(substring-before(name(.), ':'), ':', namespace-uri(.))"/>
<!-- Only the nodes -->
<xsl:variable name="all-nodes" select="//* | //*/@*"/>
@dolmen
dolmen / utf8-console.cmd
Created October 22, 2010 09:50
Console Win32 en UTF-8
@mode con cp select=65001
@dolmen
dolmen / Logger-import-test.pl
Created October 27, 2010 12:42
Test a trick: local alias for a global class
# Could be used for a future version of POE::Component::Logger to avoid polluting the global namespace.
use feature 'switch';
#use strict;
# Global Logger
sub Logger::log
{
print "global: $_[1]\n";
}
@dolmen
dolmen / release-test-pod.t
Created October 27, 2010 17:13
release-test-pod.t
#!perl
BEGIN {
unless ($ENV{RELEASE_TESTING}) {
require Test::More;
Test::More::plan(skip_all => 'these tests are for release candidate testing');
}
}
use Test::More;
@dolmen
dolmen / export-wifi-profiles.cmd
Created March 10, 2011 17:54
Export all Windows Wifi profiles (SSID, password) in XML
:: Run with full administrator rights
netsh wlan export profile folder=. key=clear
@dolmen
dolmen / mirrors.json.diff
Created March 13, 2011 16:22
Fix region names for mirrors in France
--- mirrors.json.orig Sat Mar 12 16:43:05 2011
+++ mirrors.json Sun Mar 13 16:13:27 2011
@@ -2223,7 +2223,7 @@
"name" : "crihan.fr",
"org" : "Centre de Ressources Informatiques de Haute-Normandie (CRIHAN)",
"city" : "Rouen",
- "region" : null,
+ "region" : "Normandie",
"country" : "France",
"continent" : "Europe",