Skip to content

Instantly share code, notes, and snippets.

<article title="Le titre de mon article machin"
cite="http://example.com/url/to/article.html"
pubdate="2010-06-08T00:00:00Z">
<p>
le contenu de l'article et un peu de lorem ipsum et
<a href="#">un lien pour voir</a> pis kin, un <b>gras</b>!
</p>
</article>
/* Bien sur, cet exemple utilise jQuery... */
$(function() {
$('article').each(function() {
var $a = $(this),
$link = $('<a>').attr(
{
href: $a.attr('cite'),
text: $a.attr('title')
}, true
/*
Innershiv from J.D. Bartlett
*/
window.innerShiv = (function() {
var d, r;
return function(h, u) {
@quickredfox
quickredfox / Run VirtualboxVM without GUI
Created October 27, 2010 17:38
Run VirtualboxVM without GUI
# Get a list of available VMs:
VBoxManage list vms
# Start one of the VMs w/o starting a gui
VboxHeadless -s VMname &
# Run your web server inside a headless VM. Or an SSH server, etc.
// pulled from example.js
var directive = {
'li': {
'child <- children': {
'a': 'child.name',
'a@onclick':'alert(\'#{child.name}\');',
'div.children': function(ctxt){
return ctxt.child.item.children ? rfn(ctxt.child.item):'';
}
@quickredfox
quickredfox / node-tiny-repl.js
Created November 7, 2010 22:14
Dangerously interesting.
var stdin = process.openStdin();
stdin.setEncoding('utf8');
stdin.on('data', logeval );
function logeval(chunk){
if(chunk) console.log( eval( chunk ) );
}
defineImportCallback = (script, callback) ->
unless script.readyState?
script.onload = -> callback()
return
# IE case
script.onreadystatechange = ->
if script.readyState is "loaded" or script.readyState is "complete"
script.onreadystatechange = null
callback()
function element(value, context) {
var ret = $([]); // $(context) ?
if (value.jquery) {
ret = value;
} else if (value == 'parent') {
ret = $(context).parent();
} else if (value == 'clone') {
ret = $(context).clone().removeAttr('id');
} else if (value == 'window') {
@quickredfox
quickredfox / $.post.js
Created January 21, 2011 00:33
Un POST AJAX en jQuery
/* Je prétends que ton POST est pas Cross-Domain.. */
var tonCallback = function(textOrHTML){
// si textOrHTML est du JSON
var json = JSON.parse(textOrHTML);
// sinon
var resultDocument = $(textOrHTML);
};
// tu peut en plus de l'option "data" mettre des variables GET dans ton url...
var fs = require('fs');
/**
* Offers functionality similar to mkdir -p
*
* Asynchronous operation. No arguments other than a possible exception
* are given to the completion callback.
*/
function mkdir_p(path, mode, callback, position) {
mode = mode || 0777;