Skip to content

Instantly share code, notes, and snippets.

View lucagrulla's full-sized avatar

Luca Grulla lucagrulla

View GitHub Profile
@lucagrulla
lucagrulla / gist:1212271
Created September 12, 2011 20:16
node-tail example
Tail = require('tail').Tail;
tail = new Tail("fileToTail");
tail.on("line", function(data) {
console.log(data);
});
@lucagrulla
lucagrulla / gist:1240766
Created September 25, 2011 16:07
Marks-solution
// for the origina blog post check
// http://www.markhneedham.com/blog/2011/09/25/jquery-collecting-the-results-from-a-collection-of-asynchronous-requests/
var people = ["Marc", "Liz", "Ken", "Duncan", "Uday", "Mark", "Charles"];
asyncLoop(people, [], function(name, grid, callBackFn) {
// parse data and create something cool
grid.push(somethingCool);
callBackFn();
}, function(grid) {
// do something with grid
@lucagrulla
lucagrulla / gist:1240807
Created September 25, 2011 16:33
blog post: Javascript flow control
function fecthData() {
var people = ["Marc", "Liz", "Ken", "Duncan", "Uday", "Mark", "Charles"];
var grid = [];
$.each(people, function(index, person) {
$.getJSON('/git/pairs/' + person, function(data) {
// parse data and create somethingCool
grid.push(data["name"])
if (grid.length === people.length) {
$(document).trigger("gridFilled", [grid]);
@lucagrulla
lucagrulla / gist:1240760
Created September 25, 2011 16:03
Mark-initial-problem
//for the original blog post check
//http://www.markhneedham.com/blog/2011/09/25/jquery-collecting-the-results-from-a-collection-of-asynchronous-requests/
var people = ["Marc", "Liz", "Ken", "Duncan", "Uday", "Mark", "Charles"];
var grid = [];
$.each(people, function(index, person) {
$.getJSON('/git/pairs/' + person, function(data) {
// parse data and create somethingCool
grid.push(somethingCool);
@lucagrulla
lucagrulla / gist:1605855
Created January 13, 2012 12:25
ClojureQL: select count with a where clause
(->(cql/table db :switches)
(cql/aggregate [[:count/id :as :cnt]])
(cql/select (cql/where (= :id 5))))
@lucagrulla
lucagrulla / getParamsFrom(url)
Created January 21, 2012 18:39
get params for URL
function getParamsFrom(url) {
var seq = url.split("?").pop().split("&")
var params = {};
$.each(seq, function(k, v) {
tmp = v.split("=");
params[tmp[0]] = tmp[1];
});
return params;
}
@lucagrulla
lucagrulla / gist:1716469
Created February 1, 2012 10:55
forcing clojureql to always print the sql in the standard output
(alter-var-root #'clojureql.core/*debug* (constantly true))
@lucagrulla
lucagrulla / breadcrumb
Created February 17, 2012 12:57
wordpress php breadcrumb
<?php function the_breadcrumb() {
echo "<nav>";
echo "<ul class=\"breadcrumb\">";
echo "<li>";
echo "<a href=\"\">Home</a>";
echo "</li>";
echo "<li>";
echo the_category("</li><li>");
echo "<li>";
echo the_title();
@lucagrulla
lucagrulla / gist:2035822
Created March 14, 2012 11:13
sanitize Windows file url for the web
image_path = "\images\foo\myimage.png"
image_path = image_path.dump.gsub(/\\\\/,"/").gsub("\"", "")
#total crazyness to cope with windows cut&paste url with backslashes instead of forward slashes:we convert to / just to avoid troubles...
#cover scenarios where Windows users find where a file is using windows explorer and copy the location from there(therefore with backslashes)
Verifying that +lucagrulla is my blockchain ID. https://onename.com/lucagrulla