Navigation Menu

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 / nodejs_rss_vsize.c
Created March 17, 2011 13:50
A new implementation of Node's Platform::GetMemory (in src/platform_linux.cc)
/* A new implementation of Node's Platform::GetMemory (in src/platform_linux.cc) */
/* Copyright (c) 2011 Olivier Mengué */
#include <stdlib.h>
#include <stdio.h>
#include <sys/param.h> // MAXPATHLEN
#include <fcntl.h> // O_RDONLY
#include <sys/time.h> // gettimeofday
@dolmen
dolmen / VisitPATH.cmd
Created March 18, 2011 19:58
A procedure that call a callback for each directory of %PATH%
@echo off
:: Copyright © 2011 Olivier Mengué
:: License GNU GPL 3.0
setlocal
call :VisitPATH :Echo
goto :EOF
:Echo
@dolmen
dolmen / curlIE-bootstrap-micro.js
Created March 26, 2011 12:55
Tiny bootstrap scripts for curlIE
// Does not handle non-ASCII
(W=new ActiveXObject("WinHttp.WinHttpRequest.5.1")).Open("GET","http://curlie.googlecode.com/svn/trunk/curlIE.wsf");W.Send();WScript.Echo(W.ResponseText)
@dolmen
dolmen / isLeapYear-testsuite.js
Created March 29, 2011 09:30
isLeapYear implementation, with a test suite
// See http://stackoverflow.com/questions/61088/hidden-features-of-javascript/64950#64950
function isLeapYear(year) {
return !(year % 4 != 0 || (year % 100 == 0 && year % 400 != 0));
}
function isLeapYear_refButSlow(year) {
return new Date(year, 1, 29, 0, 0).getMonth() != 2;
}
@dolmen
dolmen / StackOverflow-4829003.js
Created March 29, 2011 11:24
StackOverflow #4829003: date diff testsuite
// See http://stackoverflow.com/questions/4829003/using-date-in-js-to-calculate-the-difference-between-two-dates-what-am-i-doin
// jQuery mock object for calculateTime
// $('#time').html(result) => result is stored in $.result
var $ = (function() {
var $, $$ = {
html: function(result) {
$.result = result
}
}
@dolmen
dolmen / my-perl-env.pl
Created April 11, 2011 21:49
Configure my local Perl environment and tools (Unix)
#!/usr/bin/env perl
use strict;
use warnings;
my $local_lib = $ENV{'HOME'}.'/.perl';
-d $local_lib || -l $local_lib or mkdir $local_lib or die $!;
open my $f, '>', "$local_lib/profile" or die $!;
@dolmen
dolmen / putty.ti
Created April 11, 2011 22:04
PuTTY terminfo
#!/usr/bin/tic
#
# Reconstructed via infocmp from file: /usr/share/terminfo/p/putty
# from Redhat 4 update 3 for PuTTY 0.58
#
# Added: tsl, flash, fsl, ka1, ka3, kb2, kc1, kc3, kend, kent, khome, ich,
# btns, indn, rin, curses, setf, setb, dispc, rmpch, smpch, kcan,
# kspd, lm
# Changed: colors (256 colors), setab (256 colors), setaf (256 colors)
# Optimized: csr, cub, cud, cuf, cuu, dch, dl, ich, il
@dolmen
dolmen / cpan-prep-patch.pl
Created April 11, 2011 22:39
Prepare an environment for fixing a a bug on a CPAN Perl module
use utf8;
use strict;
use warnings;
use autodie;
use Cwd qw/cwd/;
use Archive::Tar;
use File::Spec;
use CPAN;
@dolmen
dolmen / pdocfr.cmd
Created April 11, 2011 22:45
Perldoc in french with the correct console encoding on Win32
@perl -MPod::Perldoc "-ebinmode STDOUT,':encoding(cp850)';exit Pod::Perldoc->run" -- -Lfr -T %* | more
@dolmen
dolmen / perl-env.cmd
Created April 11, 2011 22:48
Switches environment between ActivePerl and StrawberryPerl
@echo off
setlocal
if "%1"=="" goto :ShowEnv
:SetEnv
if /I "%1"=="SB" set NewPerlDir=C:\strawberry\perl
if /I "%1"=="AS" set NewPerlDir=C:\Perl