Skip to content

Instantly share code, notes, and snippets.

View lucapette's full-sized avatar

Luca Pette lucapette

View GitHub Profile
@lucapette
lucapette / application.html.erb
Created September 19, 2011 20:54
jquery ui tables in rails
<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
<%= yield(:head) %>
<%=javascript_tag "$(document).ready(init)" %>
</head>
<body>
@lucapette
lucapette / toys.rb
Created February 2, 2011 10:08
methods to create toys arrays and hashes
class Array
def self.toy(n=10, &block)
block_given? ? Array.new(n,&block) : Array.new(n) {|i| i+1}
end
end
class Hash
def self.toy(n=10)
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
end
@lucapette
lucapette / alfa.pl
Created September 25, 2010 22:44
a stupid perl script from my childhood
#!/usr/bin/perl -w
use strict;
my %letters=(
"A" => "ALFA",
"B" => "BRAVO",
"C" => "CHARLIE",
"D" => "DELTA",
"E" => "ECHO",
@lucapette
lucapette / quine_define.c
Created September 25, 2010 22:21
quine in c
#define t(x) main(){printf(#x"\nt("#x")\n");}
t(#define t(x) main(){printf(#x"\nt("#x")\n");})
@lucapette
lucapette / quine.c
Created September 25, 2010 22:13
quine in C
char *s="char *s=%c%s%c%c%c%cmain()%c{%c printf(c,10,34,c,34,59,10);%c printf(s,34,s,34,59,10,10,10,10,10,10,10);%c}%c";
main()
{
printf(s,34,s,34,59,10,10,10,10,10,10,10);
}