Archive for July, 2007
Contributing to GNOME: evince multihead presentations
Posted by JohannesTheDeveloper in Happy Hacking on July 30th, 2007
Yes, I have contributed to GNOME.
It is about presentations with multiple monitors (multihead, dualscreen). One monitor holds the presentation, the other shows a control window with overview on the left (current, next slides) and a large view for the current slide, or the notes on the right.
So far only a reorganizing patch is committed. I have hope though that it will be included in a future release.
You can get the patch from the bug and compile it into a evince release (not too hard and worth it in my opinion).
Also we have bad quality videos:
- Previous version
- Good working version, shows a usable notes file: evince multihead presentations (ogg, 3,022 KB)
So far for the technical part.
To say the least, it is sooooo awesome to work in open source. Nice people everywhere, you can get help easily (you have and should have to work and learn things on your own though). Getting to know the inner works of these projects is a very good experience. I expect Google Summer of Code to be quite similar to the nice help and mentoring I enjoyed by nsh, KaL, jrb and others.
Also I can’t describe to you the feeling that maybe, in 2 years, your software will be delivered to a million users. So awesome.
Some Mac users will of course say this is all stolen from KeyNote. One could say: Um, having a different content on 2 screens is not particularly new (Xinerama). Having one as control for the other is not that far away. Also, the window content is really different.
But I would say … who cares about Mac users anyway :-P
Btw: If you wonder why I do not have a clock in the window … GNOME already has one. The window is maximized, not fullscreen to allow starting of applications you may want to show during presentations. The patch also works for more than 2 monitors.
C: Bdecode
Posted by JohannesTheDeveloper in Happy Hacking on July 25th, 2007
In the last hour or so I wrote this bdecode C-program (see the
specification of bencoding) since this python program doesn’t work and I hate wikis with logins (otherwise I’d posted it there).
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
void tabber(int t){
while(t-->0) printf("\t");
}
int bdecode(char * data, int tab){
/*printf("data: %c%c%c%c%c\n", data[0],data[1],data[2],data[3],data[4]);*/
if (isdigit(data[0])){
int i=0;
int j=0;
while (isdigit(data[i])) {
i++;
}
data[i] = 0;
int len = atoi(data);
i++;
tabber(tab); printf("Bytestring (%d long): ", len);
for (;j<len;j++) {
printf("%c", data[j+i]);
}
printf("\n");
i+=len;
return i;
}else if(data[0] == 'i'){
int i=0;
int n=0;
int sign = 1;
i++;
if(data[1]=='-'){
sign = -1;
i++;
}
while (isdigit(data[i])){
n=n*10+data[i]-'0';
i++;
}
n*=sign;
tabber(tab); printf("Integer: %d\n", n);
i++;
return i;
}else if(data[0] == 'l'){
int i=0;
i++;
tabber(tab); printf("List: \n");
while(data[i] != 'e'){
i += bdecode(&data[i], tab+1);
/*printf("continuing at: %c%c%c%c%c\n", data[i+0],data[i+1],data[i+2],data[i+3],data[i+4]);*/
}
i++;
return i;
}else if(data[0] == 'd'){
int i = 0;
tabber(tab); printf("Dict: \n");
i++;
while(data[i] != 'e'){
i += bdecode(&data[i], tab+1);
/*printf("continuing at: %c%c%c%c%c\n", data[i+0],data[i+1],data[i+2],data[i+3],data[i+4]);*/
tabber(tab+1); printf(" => \n");
i += bdecode(&data[i], tab+2);
/*printf("continuing at: %c%c%c%c%c\n", data[i+0],data[i+1],data[i+2],data[i+3],data[i+4]);*/
printf("\n");
}
i++;
return i;
}
printf("Shouldn't be here\n");
return -1000;
}
int main(int argc, char ** argv){
if(argc>1)
bdecode(argv[1], 1);
else
printf("No arg, sucker!");
return 0;
}
Compile & execute (use the examples from the spec):
$ gcc bdecode2.c -o bdecode2.exe -Wall
$ ./bdecode2.exe d9:publisher3:bob18:publisher.location4:home17:publisher-webpage15:www.example.come
Dict:
Bytestring (9 long): publisher
=>
Bytestring (3 long): bob
Bytestring (18 long): publisher.location
=>
Bytestring (4 long): home
Bytestring (17 long): publisher-webpage
=>
Bytestring (15 long): www.example.com
Seriously, wikis with logins! Where even the discussion pages are locked.
Good old C… and don’t tell me about “Oh, you could save 2 lines there!” I got a compiler for that …
Of course it contains bugs! Good quality ones!
You can run your .torrent files against it:
$ ./bdecode2.exe "$(cat Apocalypto.torrent)" | less
Dict:
Bytestring (8 long): announce
=>
Bytestring (44 long): <a href="http://vip.tracker.thepiratebay.org/announce">http://vip.tracker.thepiratebay.org/announce</a>
Bytestring (13 long): announce-list
=>
List:
List:
Bytestring (44 long): <a href="http://vip.tracker.thepiratebay.org/announce">http://vip.tracker.thepiratebay.org/announce</a>
List:
Bytestring (44 long): <a href="http://tracker.torrentbox.com:2710/announce">http://tracker.torrentbox.com:2710/announce</a>.
List:
Bytestring (41 long): <a href="http://axxo.sladinki007.net:6500/announce">http://axxo.sladinki007.net:6500/announce</a>
List:
Bytestring (39 long): <a href="http://tracker.torrent.to:2710/announce">http://tracker.torrent.to:2710/announce</a>
Bytestring (13 long): creation date
=>
Integer: 1178231686
Bytestring (4 long): info
=>
Dict:
Bytestring (5 long): files
=>
List:
Dict:
Bytestring (6 long): length
=>
Integer: 943704064
Bytestring (4 long): path
=>
List:
Bytestring (45 long): Apocalypto[2006]DvDrip[Eng.Hard.Sub]-aXXo.avi
Dict:
Bytestring (6 long): length
=>
Integer: 623
Bytestring (4 long): path
=>
List:
Bytestring (52 long): IMPORTANT.Read carefully before enjoy this movie.txt
...
Reading metainfo about illegal movies is arguably allowed, I don’t download this. (Nor do I take anything away from anyone using violence, as piracy is defined.)
Accessing Oracle with OpenOffice Base
Posted by JohannesTheDeveloper in fun with Linux on July 18th, 2007
Get ojdbc14.jar from:
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc101040.html
Then read here:
http://wiki.services.openoffice.org/wiki/FAQ_(Base)#Why_can.27t_OpenOffice.org_load.2Ffind_my_JDBC_driver.3F
Why can’t OpenOffice.org load/find my JDBC driver?
OpenOffice.org needs to know the path to the class files or the jar files of the JDBC driver. To achieve this, go to the Tools/Options dialog, there choose the page “Java”. On this page, press the “Classpath” button, and add your archive or folder to OOo’s classpath.
Start oobase and create the connection.
Fighting spam mails
Posted by JohannesTheDeveloper in fun with Linux on July 18th, 2007
I use POP, and have already 7000 messages on the server (cause I always tell my clients to leave them, so I can read mails from different places).
Until now, under the above were also lots of spam mails, which I wanted to get rid of (when I fetch them on a new client, I takes ages).
Thunderbird supports something cool: If you have your spammail in one folder (Junk), you can create a message filter:
“If mail is not flagged: Delete from POP server, mark as flagged. Run in Junk folder.”
This is great, but you still have to find out which mails are spams. The following can help: We try to get our address book filled based on number of mails we got from each address. Thus we will (almost) have our friends and people we expect mail from, in the address book, and they won’t be marked as spam.
$ cd "~/.thunderbird/s2ardbyl.default/Mail/Local Folders"
$ cat Inbox |
grep "^From: " |
grep -Eo "[^< ]*@[^ >]*" |
sort |
uniq -c |
sort -n |
grep -v " 1 " |
sed 's/^ *\([0-9]*\) /\1\t/g' > ~/emails.tab
Okay, now we got in ~/emails.tab the number of mails, and the address, tab separated. You can import that using the address book of thunderbird (choose for example Work Phone and Primary email address; then sort by the first). Look over it, and delete stuff you don’t know. Either change the setting in Junk controls or move the people to your “Personal Addressbook”.
Now you can make a saved search looking for emails from your address book. You can mark them all as “Not Spam”.
Results of running Junk control over the mail folder should improve by that.
Bittorrent: Watching the net
Posted by JohannesTheDeveloper in Happy Hacking on July 25th, 2007
You might wonder, why I made the previous story.
I was trying to find out how to make a tool that watches the local network for torrents. Ideally, it outputs the files shared and being downloaded so one can either join … or fire that guy.
As it turns out reading the spec (bittorrent.org, theory.org) and doing some sniffing, that you can not find out the original torrents.
That is because the info_hash, that is transmitted to tracker announcements (getting other peers, etc) regularly is a one-way hash (sha1).
Thus you can only see how much traffic, how many and which users and how many different files are participating, but not which files are shared, unless you have the .torrent files yourself (like, your the owner of thepiratebay.org).
comment
No Comments