<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
        <?xml-stylesheet type="text/css" href="http://artha.org/blog/styles/feed.css"?>
<title type="html">sham_blog</title>
<link rel="alternate" type="text/html" href="http://artha.org/blog"/>
<link rel="self" type="application/atom+xml" href="http://artha.org/blog/atom.xml"/>
<updated>2010-04-22T00:34:56+01:00</updated>
<author>
<name>shammash</name>
<uri>http://artha.org/blog</uri>
</author>
<id>http://artha.org/blog/</id>
<generator uri="http://nanoblogger.sourceforge.net" version="3.3">
NanoBlogger
</generator>

<entry>
<title type="html">urxvt selection2browser</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2010/04/21/index.html#e2010-04-21T12_18_03.txt"/>
<id>http://artha.org/blog/archives/2010/04/21/index.html#e2010-04-21T12_18_03.txt</id>
<published>2010-04-21T12:18:03+01:00</published>
<updated>2010-04-21T12:18:03+01:00</updated>
<category term="tech" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
Sometimes I need to open a few links from the terminal which are just words, so
it's almost impossible to have them recognized by urxvt url matcher. This is
why I've done this small script which allows you to open into your browser a
piece of text previously selected on the terminal.<br><br>

I'm far from being an urxvt expert so if you have better solutions please write
me!<br><br>

<pre>
#! perl

sub on_start {
   my ($self) = @_;

   $self->{browser} = $self->x_resource ("urlLauncher") || "sensible-browser";

   ()
}

sub on_user_command {
   my ($self, $cmd) = @_;

   $cmd eq "selection2browser"
      and $self->exec_async ($self->{browser}, $self->selection);

   ()
}

</pre>

I have this script saved as a file named <b>selection2browser</b> in my
<b>~/.urxvt/perl/</b> directory and in order to activate it via
<b>Ctrl-Alt-w</b> I put the following lines in <b>~/.Xresources</b>:<br><br>

<pre>
URxvt.perl-lib: /home/shammash/.urxvt/perl/
URxvt.perl-ext-common: default,[other stuff],selection2browser
URxvt.keysym.C-M-w: perl:selection2browser
</pre>]]>
</div>
</content>

</entry>
<entry>
<title type="html">tesi specialistica</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2010/03/06/index.html#e2010-03-06T11_40_10.txt"/>
<id>http://artha.org/blog/archives/2010/03/06/index.html#e2010-03-06T11_40_10.txt</id>
<published>2010-03-06T11:40:10+01:00</published>
<updated>2010-03-06T11:40:10+01:00</updated>
<category term="var" />
<category term="tech" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
Finalmente, dopo mesi di gestazione[1], sono arrivato a consegnare la tesi di
laurea specialistica.<br>
<br>
<a target=_blank href='/unibo/tesi_specialistica.pdf'>Design e implementazione
del nuovo framework Virtual Distributed Ethernet: analisi delle prestazioni e
validazione sulla precedente architettura.</a><br>
<br>
Buona lettura!<br>
<br>
[1] o,> e (o(<br>
<br>]]>
</div>
</content>

</entry>
<entry>
<title type="html">debrick LiveScribe Pulse</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2010/01/09/index.html#e2010-01-09T16_16_26.txt"/>
<id>http://artha.org/blog/archives/2010/01/09/index.html#e2010-01-09T16_16_26.txt</id>
<published>2010-01-09T16:16:26+01:00</published>
<updated>2010-01-09T16:16:26+01:00</updated>
<category term="tech" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
A few days ago my friend <a target=_blank
href='http://giardini.sm/rpd/'>Roberto</a> received his new <a target=_blank
href='http://www.livescribe.com/smartpen/index.html'>LiveScribe Pulse</a>.
After playing a bit with his new toy he decided to attach it to the computer,
but unfortunately the pen got bricked during a firmware upgrade.<br>
<br>
So with my friend <a target=_blank href='http://esaurito.net/blog'>Filippo</a>
we tried to perform various kinds of hard reset, following what's described in
<a target=_blank
href='http://www.livescribe.com/support/kb/?View=entry&EntryID=279'> 29101 -
Mac Master Reset and firmware update utility</a>, but with no success.<br>
<br>
We were about to give up when, just out of curiosity, I decided to attach the
pen to my Linux machine. Using "lsusb -vv" I've discovered that the pen was
stuck in its Device Firmware Upgrade mode waiting for something interesting to
happen.<br>
<br>
Fantastic! We found the pen firmware inside LiveScribe Flash Utility and we
uploaded it using "dfutool" from BlueZ... The pen came back to life, very
good!<br>
<br>
After this forced upgrade the pen was basically working, but it lacked some
functionalities like voice recording. But now official LiveScribe utilities
were able to see the pen, so we re-flashed using them and we obtained a 100%
working device.<br>
<br>
These are the steps we used to flash the LiveScribe Pulse from Linux:<br>
<br>
<pre>
$ wget http://www.livescribe.com/downloads/support/LivescribeSmartpenFlashUtility_2.1.1_Mac.zip
$ unzip LivescribeSmartpenFlashUtility_2.1.1_Mac.zip
$ cd 2.1.1\ Pen\ Flash\ Utility.app/Contents/Resources/Bundles/
$ unzip SystemSoftwareV2.1.1_C.bnd -d SystemSoftwareV2.1.1_C
$ cd SystemSoftwareV2.1.1_C/Files/
$ dfutool upgrade bali_ams3.dfu
Filename  bali_ams3.dfu
Filesize  3365572
Checksum  40559ec9 (valid)

Available devices with DFU support:

  1) Bus 004 Device 002: ID 1cfb:1020 Interface 2

</pre>
<br>]]>
</div>
</content>

</entry>
<entry>
<title type="html">two local interfaces without loopback</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2009/08/29/index.html#e2009-08-29T22_43_55.txt"/>
<id>http://artha.org/blog/archives/2009/08/29/index.html#e2009-08-29T22_43_55.txt</id>
<published>2009-08-29T22:43:55+01:00</published>
<updated>2009-08-29T22:43:55+01:00</updated>
<category term="tech" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
Today I was working with <a target=_blank href='http://esaurito.net/blog'>Filippo</a>
on some performance analysis. At some point we<br>
needed to send some traffic between two different interfaces on the same Linux<br>
box, but we did not want the traffic routed through the local loopback.<br>
<br>
The main problem here seems to be the lack of a direct and clean way to say in<br>
Linux: "yes, this address is on this machine, but do not use the local loopback<br>
for the traffic originating from the same host which needs to reach it".<br>
<br>
Different flavours of this problem have been approached in many ways, there is<br>
also a <a target=_blank href='http://www.ssi.bg/~ja/#loop'>Send-To-Self</a> patch
for the kernel.<br>
<br>
So this is my sol^W^Wan hack to achieve that using four IP addresses, NAT, and<br>
a few simple changes to the routing table.<br>
<br>

<pre>
ip l s tap1 up
ip l s tap2 up
ip a a 10.10.1.2/32 dev tap1
ip a a 10.10.2.2/32 dev tap2
ip r a 10.10.2.1/32 dev tap1
ip r a 10.10.1.1/32 dev tap2
iptables -t nat -A POSTROUTING -o tap1 -j SNAT --to-source 10.10.1.1
iptables -t nat -A POSTROUTING -o tap2 -j SNAT --to-source 10.10.2.1
iptables -t nat -A PREROUTING -i tap1 -j DNAT --to-destination 10.10.1.2
iptables -t nat -A PREROUTING -i tap2 -j DNAT --to-destination 10.10.2.2
arp -i tap2 -Ds 10.10.1.1 tap1
arp -i tap1 -Ds 10.10.2.1 tap2
</pre>
<br>]]>
</div>
</content>

</entry>
<entry>
<title type="html">delicious backup</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2008/10/18/index.html#e2008-10-18T18_46_36.txt"/>
<id>http://artha.org/blog/archives/2008/10/18/index.html#e2008-10-18T18_46_36.txt</id>
<published>2008-10-18T18:46:36+01:00</published>
<updated>2008-10-18T18:46:36+01:00</updated>
<category term="var" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
A slightly improved version of
<a target=_blank href='http://snippets.dzone.com/posts/show/290'>this ruby script</a>
you can use to backup your delicious bookmarks to an sqlite3 database.<br><br>

<pre>
#!/usr/bin/env ruby
require 'rexml/document'
require 'net/http'
require 'net/https'
require 'sqlite3'
require 'json'

dbfile_base = 'delicious_bkp_'
rcfile_base = '.delicious_bkp.rc'

agent = 'del.icio.us backup v0.2.1'

schema = &lt;&lt;EOF
create table bookmarks (
    hash char(32) primary key,
    url varchar(1024),
    title varchar(1024),
    note varchar(2048),
    time timestamp
);
create table tags (hash char(32), tag varchar(1024));
create index ix_tags_hash on tags (hash);
create index ix_tags_tag on tags (tag);
EOF
insert_url = 'insert into bookmarks (hash, url, title, note, time) ' +
             'values (?, ?, ?, ?, ?);'
insert_tag = 'insert into tags (hash, tag) values (?, ?);'


rcfile_path = File.join(ENV['HOME'], rcfile_base)
if (not FileTest.exist?(rcfile_path))
	puts "\nERROR: rc file not found!\n\n"
	puts "Create a file " + rcfile_path + " containing the following line:"
	puts "{ \"user\": \"username\", \"pass\": \"password\", \"dir\": \"/path/to/bkp\", \"max_bkp\": 0}\n\n"
	exit -1
end
rcfile = File.open(rcfile_path)
perms = sprintf("%o", rcfile.stat().mode)[-4..-1]
if (perms != "0600")
	puts "\nERROR: rc file permissions are not safe!\n\n"
	exit -1
end
begin
j = JSON.parse(rcfile.read())
rescue JSON::ParserError
	puts "\nERROR: bad syntax in rc file\n\n"
	exit -1
end
['user', 'pass', 'dir', 'max_bkp'].each { |key|
	if (not j.has_key?(key))
		puts "\nERROR: field " + key + " doesn't exist in rc file!\n\n"
		exit -1
	end
}
if (not FileTest.directory?(j['dir']))
	puts "\nERROR: Specified directory does not exist!\n\n"
	exit -1
end

dbfile_base = dbfile_base + j['user'] + "_"
dbfile_name = dbfile_base + Time.now.strftime("%Y-%m-%d.db")
dbfile_path = File.join(j['dir'], dbfile_name)
if (FileTest.exist?(dbfile_path))
	puts "Backup " + dbfile_name + " exists, exiting."
	exit 0
end

http = Net::HTTP.new('api.del.icio.us', 443)
http.use_ssl = true
xml = http.start { |http|
    req = Net::HTTP::Get.new('/v1/posts/all', {'User-Agent' => agent})
    req.basic_auth(j['user'], j['pass'])
    http.request(req).body
}

doc = REXML::Document.new(xml)

SQLite3::Database.open(dbfile_path).transaction { |db|
    db.execute_batch(schema)
    db.prepare(insert_url) { |url_stmt|
        db.prepare(insert_tag) { |tag_stmt|
            doc.elements.each('posts/post') { |el|
                url_stmt.execute(el.attributes['hash'],
                    el.attributes['href'], el.attributes['description'],
                    el.attributes['extended'], el.attributes['time'])
                el.attributes['tag'].split(' ').each { |tag|
                    tag_stmt.execute(el.attributes['hash'], tag)
                }
            }
        }
    }
}

if (j['max_bkp'] > 0)
	d = Dir.new(j['dir'])
	b = []
	re = Regexp.new(dbfile_base + "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\.db")
	d.each {|entry| if re.match(entry) then b.push(entry) end }
	if b.nitems > j['max_bkp']
        	b.sort()[0, (b.nitems - j['max_bkp'])].each {|olddb|
	                File.unlink(File.join(j['dir'], olddb))
        	}
	end
end


</pre>]]>
</div>
</content>

</entry>
<entry>
<title type="html"></title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2008/10/18/index.html#e2008-10-18T14_49_47.txt"/>
<id>http://artha.org/blog/archives/2008/10/18/index.html#e2008-10-18T14_49_47.txt</id>
<published>2008-10-18T14:49:47+01:00</published>
<updated>2008-10-18T14:49:47+01:00</updated>
<category term="var" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[]]>
</div>
</content>

</entry>
<entry>
<title type="html">stop software patents world day</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2008/09/24/index.html#e2008-09-24T15_09_33.txt"/>
<id>http://artha.org/blog/archives/2008/09/24/index.html#e2008-09-24T15_09_33.txt</id>
<published>2008-09-24T15:09:33+01:00</published>
<updated>2008-09-24T15:09:33+01:00</updated>
<category term="tech" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
<br>
<a href="http://stopsoftwarepatents.org/">
<img alt="http://stopsoftwarepatents.org" src="http://stopsoftwarepatents.wdfiles.com/local--files/banners/banner-x60.png" border="0">
</a>
<br>]]>
</div>
</content>

</entry>
<entry>
<title type="html">native vde support in qemu</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2008/07/02/index.html#e2008-07-02T00_13_21.txt"/>
<id>http://artha.org/blog/archives/2008/07/02/index.html#e2008-07-02T00_13_21.txt</id>
<published>2008-07-02T00:13:21+01:00</published>
<updated>2008-07-02T00:13:21+01:00</updated>
<category term="tech" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
The patch is
<a target=_blank href='http://lists.gnu.org/archive/html/qemu-devel/2008-07/msg00026.html'>here</a>.<br>
I hope it will get upstream.<br>]]>
</div>
</content>

</entry>
<entry>
<title type="html">tempo</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2008/06/27/index.html#e2008-06-27T10_53_41.txt"/>
<id>http://artha.org/blog/archives/2008/06/27/index.html#e2008-06-27T10_53_41.txt</id>
<published>2008-06-27T10:53:41+01:00</published>
<updated>2008-06-27T10:53:41+01:00</updated>
<category term="var" />
<category term="fun" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
Ricevo in terra irlandese e pubblico un segno evidente del tempo che passa:<br>
<br>
<img border=0 alt='occhio beppe'
src='http://artha.org/blog/entrimg/occhio_beppe.jpg'><br>
<br>
<i>Nota: il valore di verit&agrave; non cambia sia interpretando "tempo" come
clima (si suda) che come anni (si portano gli occhiali).</i>]]>
</div>
</content>

</entry>
<entry>
<title type="html">quicksort</title>
<author>
<name>shammash</name>
</author>
<link rel="alternate" type="text/html" href="http://artha.org/blog/archives/2008/05/06/index.html#e2008-05-06T15_20_04.txt"/>
<id>http://artha.org/blog/archives/2008/05/06/index.html#e2008-05-06T15_20_04.txt</id>
<published>2008-05-06T15:20:04+01:00</published>
<updated>2008-05-06T15:20:04+01:00</updated>
<category term="tech" />
<category term="fun" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[
Let's write a quicksort implementation in
<a target=_blank href='http://www.jsoftware.com/'>J programming language</a>..<br>
<br>
<pre>
quicksort=:(($:@(<#[),(=#[),$:@(>#[))({~?@#))^:(1<#)
</pre>
<br>
<i>Many thanks to Vlad! :)</i><br>]]>
</div>
</content>

</entry>

</feed>
