Skip to content

Instantly share code, notes, and snippets.

Avatar
😁
Happy!

Olivier Mengué dolmen

😁
Happy!
View GitHub Profile
@dolmen
dolmen / CleanHtmlURIResolver.java
Created Jun 1, 2010
XSLT processor in Java, with an URI Resolver
View CleanHtmlURIResolver.java
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 Aug 25, 2010
JSON to XML serializer
View json2xml.js
// 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 Aug 27, 2010
'which' command for Win32
View which.cmd
@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 Aug 30, 2010
Kwalitee rank for an Acme::CPANAuthors list (from CPANTS)
View cpants-rank.pl
#!/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 Oct 1, 2010
My answer to StackOverflow #3747049
View so-3747049.xslt
<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 Oct 22, 2010
Console Win32 en UTF-8
View utf8-console.cmd
@mode con cp select=65001
@dolmen
dolmen / Logger-import-test.pl
Created Oct 27, 2010
Test a trick: local alias for a global class
View Logger-import-test.pl
# 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";
}
View 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 Mar 10, 2011
Export all Windows Wifi profiles (SSID, password) in XML
View export-wifi-profiles.cmd
:: Run with full administrator rights
netsh wlan export profile folder=. key=clear
@dolmen
dolmen / mirrors.json.diff
Created Mar 13, 2011
Fix region names for mirrors in France
View mirrors.json.diff
--- 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",
You can’t perform that action at this time.