Skip to content

Instantly share code, notes, and snippets.

View cosimo's full-sized avatar
🇳🇴

Cosimo Streppone cosimo

🇳🇴
View GitHub Profile
cosimo@ubuntu:~/src/web$ export PERL6LIB=/home/cosimo/src/perl6-sqlite/lib:/home/cosimo/src/web/lib
cosimo@ubuntu:~/src/web$ perl6 t/squerl/01-sqlite-write.t
invoke() not implemented in class 'Undef'
in sub SQLite3::sqlite_open (/home/cosimo/src/perl6-sqlite/lib/SQLite3.pm:50)
called from method Squerl::Database::open (/home/cosimo/src/web/lib/Squerl.pm:334)
called from method Squerl::Database::create_table (/home/cosimo/src/web/lib/Squerl.pm:360)
called from Main (t/squerl/01-sqlite-write.t:12)
@cosimo
cosimo / gist:803454
Created January 31, 2011 00:07
Opera contacts to Mutt aliases converter
#!/usr/bin/env perl
#
# Convert Opera contacts file (.adr) into
# mutt aliases file format.
#
# Usage:
# perl opera-adr-to-mutt-aliases.pl < ~/.opera/contacts.adr >> ~/.mutt/aliases
#
# Cosimo, 31/Jan/2011
#
/* Per Buer's code, "Re: Lots of configs"
* http://pastebin.com/a68y15hp
*/
#include <stdio.h>
#include <string.h>
#include <pcre.h>
int main() {
const char *error;
@cosimo
cosimo / gist:884307
Created March 24, 2011 00:05
Convert svn tags to git tags
#!/bin/bash
#
# Convert remote tags imported from SVN to real git tags
#
REMOTE_TAGS=$(git branch -r | grep 'tags/' | cut -f2 -d/)
GIT=$(which git)
for t in $REMOTE_TAGS
do
@cosimo
cosimo / purge-cache.sh
Created March 28, 2011 09:51
Script to purge varnish cache by URL, by regexp or all of it (for Debian)
#!/bin/sh
# purge-cache: Script to purge varnish cache. Defaults are defined in
# /etc/default/varnish.
#
# Cosimo <[email protected]>
# Based on reload-vcl, by Stig Sandbeck Mathisen <ssm at debian dot org>
# Settings
defaults=/etc/default/varnish
@cosimo
cosimo / time-response.pl
Created July 23, 2011 14:39
Simple tool to detect TCP retransmit timeouts through HTTP requests
#!/usr/bin/env perl
#
# Fires HTTP request batches at the specified hostname
# and analyzes the response times.
#
# If you have suspicious frequency of 3.00x, 9.00x, 21.00x
# seconds, then most probably you have a problem of packet loss
# in your network.
#
# [email protected], sometime in 2011
@cosimo
cosimo / gist:1171210
Created August 25, 2011 17:25
Strace of a IO::Socket.recv() from local memcached socket
connect(3, {sa_family=AF_INET, sin_port=htons(11211), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
sendto(3, "get trololol\r\n", 14, 0, NULL, 0) = 14
# ite(1, "# Sent 'get trololol\r# \n# '. Wai"..., 50# Sent 'get trololol
# '. Waiting a response...) = 50
write(1, "\n", 1
) = 1
recvfrom(3, "END\r\n", 2048, 0, NULL, NULL) = 5
recvfrom(3, <stuck-here>
@cosimo
cosimo / gist:1171216
Created August 25, 2011 17:26
Strace of a IO::Socket.recv() from local HTTP server
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
sendto(3, "GET /ping.html HTTP/1.1\r\n\r\n", 27, 0, NULL, 0) = 27
# ite(1, "# Sent 'GET /ping.html HTTP/1.1\r"..., 67# Sent 'GET /ping.html HTTP/1.1
#
# '. Waiting a response...) = 67
write(1, "\n", 1
) = 1
mmap(NULL, 1052672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc31ca1c000
recvfrom(3, "HTTP/1.1 400 Bad Request\r\nDate: "..., 2048, 0, NULL, NULL) = 515
recvfrom(3, "", 2048, 0, NULL, NULL) = 0
diff --git a/lib/Mojo/Cookie.pm b/lib/Mojo/Cookie.pm
index 6a67e42..ed42fe5 100644
--- a/lib/Mojo/Cookie.pm
+++ b/lib/Mojo/Cookie.pm
@@ -22,6 +22,7 @@ my $NAME_RE = qr/
/x;
my $SEPARATOR_RE = qr/^\s*\;\s*/;
my $VALUE_RE = qr/^([^\;\,]+)\s*/;
+my $VALUE_NOCOMMA_RE = qr/^([^\;]+)\s*/;
@cosimo
cosimo / check-debian-version.sh
Created November 23, 2011 16:59
Quickly tells the Debian version running on a given host. Requires ssh server enabled.
#!/bin/sh
#
# Tells the Debian version reading the OpenSSH banner
# Requires OpenSSH to be running and ssh port to be open.
#
# Usage: $0 <hostname>
#
# Cosimo, 23/11/2011
HOST=$1