Skip to content

Instantly share code, notes, and snippets.

View mklabs's full-sized avatar

Mickael Daniel mklabs

View GitHub Profile
@mklabs
mklabs / whitespace-cleanr.js
Created July 23, 2011 12:57
svg to raphael helper, get an array of path object {path, attr} from an svg file
// <script type="text/someunknowntype" id="logo-svg"><svg>...</svg></script>
var svg = $('#logo-svg')[0].innerHTML
// >< whitespace cleanr ><
.replace(/>[\s]+</g, '><')
.replace(/[\s]+/g, ' ')
// get an array of path hash object, with path/attr property
.match(/<(path[^\/]+)\/>/g)
.map(function(el) {
var m = el.match(/<path d="([^"]+).+style="([^"]+).+/),
attr = {},
@mklabs
mklabs / front-tools.md
Created July 23, 2011 10:32
my little list of frontend tools and resources #frontend #tools
@mklabs
mklabs / template.js
Created July 16, 2011 20:00
little template engine helper
function tmpl(s,d){return s.replace(/:([a-z]+)/g, function(w,m){return d[m];});}
// auto executing function
function tmpl(s,d){return s.replace(/:([a-z]+)/g, function(w,m){return w.replace(/.+/, d[m]);});}
/*
tmpl(':foo <p>:bar</p>', {foo: 'bar', bar: true})
> bar <p>true</p>
@mklabs
mklabs / findgit-example.js
Created May 10, 2011 15:04
findit + node-git (git-fs) = findgit
// callback style
findgit(Path.join(dir, 'templates'), function(err, r) {
console.log('test findgit', r.files.length);
});
// event emitter style
findgit(Path.join(dir, 'templates'))
.on('error', function(e){ console.log('Doooooh, there was an error', e); })
.on('file', function(file){ console.log('A file: ', file); })
.on('directory', function(dir){ console.log('A dir: ', dir); })
@mklabs
mklabs / childprocess-git-test.js
Created April 13, 2011 20:35
use spawn childprocess to perform a git commit
var spawn = require('child_process').spawn,
un = spawn('git', ['config', 'user.name', 'Batman']),
ue = spawn('git', ['config', 'user.email', '[email protected]']),
g = spawn('git', ['commit', '-am', "Jooooooker"]);
un.stdout.on('data', function (data) {
console.log('un stdout: ' + data);
});
ue.stdout.on('data', function (data) {
@mklabs
mklabs / dom-walker-texas-ranger.js
Created April 9, 2011 13:01
A chuck norris version of Douglas Crockford's walkTheDOM helper.
/**
* http://javascript.crockford.com/code.html
* http://yuiblog.com/assets/crockford/theory.zip
*/
function walker(texas, ranger) {
ranger(texas);
texas = texas.firstChild;
while (texas) {
walker(texas, ranger);
@mklabs
mklabs / original.js
Created March 8, 2011 13:26
new version with (nearly) detailled information of albumtable script
/*
* Script for albumtable.html template
*/
$(document).ready(function() {
$("#voteInfo").hide();
$('#albumList').dataTable();
//album covers
$.each($('.cover'), function(){
var album = $(this).parent().parent().attr("id");
//album id
@mklabs
mklabs / pretty-bridge.js
Created March 3, 2011 23:27
My pretty bridge - inspired by, based on http://alexsexton.com/?p=51 - Using Inheritance Patterns to Organize Large jQuery Applications
// inspired by, based on http://alexsexton.com/?p=51
(function($, global) {
// Make sure Object.create is available in the browser (for our prototypal inheritance)
(function() {
if(typeof Object.create === 'function') {
return;
}
@mklabs
mklabs / github-flavored-markdown.md
Created March 1, 2011 09:47
GitHub Flavored Markdown #test #github #markdown

GitHub Flavored Markdown

View the source of this content.

Let's get the whole "linebreak" thing out of the way. The next paragraph contains two phrases separated by a single newline character:

Roses are red Violets are blue

@mklabs
mklabs / little-test.md
Created February 28, 2011 17:28
Just a test #test

New markdown formated file

Yup.