stefan.grothkopp.com

Relax - This won't hurt. 
Filed under

open source

 

google.pl - command line google search in a shell with perl

#!/usr/bin/perl
# google.pl - command line tool to search google
#
# Since I wrote goosh.org I get asked all the time if it could be used on the command line.
# Goosh.org is written in Javascript, so the answer is no. But google search in the shell
# is really simple, so I wrote this as an example. Nothing fancy, just a starting point.
#
# 2009 by Stefan Grothkopp, this code is public domain use it as you wish!

use LWP::Simple;
use Term::ANSIColor;

# change this to false for b/w output
$use_color = true;
#result size: large=8, small=4
$result_size = "large";

# unescape unicode characters in" content"
sub unescape {
my($str) = splice(@_);
$str =~ s/\\u(.{4})/chr(hex($1))/eg;
return $str;
}

# number of command line args
$numArgs = $#ARGV + 1;

if($numArgs ==0){
# print usage info if no argument is given
print "Usage:\n";
print "$0 \n";
}
else {
# use first argument as query string
$q = $ARGV[0];
# url encode query string
$q =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;

# get json encoded search result from google ajax api
my $content = get("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=0&rsz=$result_size&q=$q"); #Get web page in content
die "get failed" if (!defined $content);

# ugly result parsing (did not want to depend on a parser lib for this quick hack)
while($content =~ s/"unescapedUrl":"([^"]*)".*?"titleNoFormatting":"([^"]*)".*?"content":"([^"]*)"//){

# those three data items are extrated, there are more
$title = unescape($2);
$desc = unescape($3);
$url = unescape($1);

# print result
if($use_color){
print colored ['blue'], "$title\n";
print "$desc\n";
print colored ['green'], "$url\n\n";
print color 'reset';
}
else{
print "$title\n$desc\n$url\n\n";
}
}
}

Loading mentions Retweet
Filed under  //   ajax   code   google   linux   open source   perl   shell   unix  

Comments [5]

Apollo 11 mission's 40th Anniversary: One large step for open source code...

The code for the lunar lander and command module has been open sourced:
 http://googlecode.blogspot.com/2009/07/apollo-11-missions-40th-anniversary-one.html

Loading mentions Retweet
Filed under  //   code   open source   space  

Comments [0]

GPL vs. LGPL

Interesting thoughts on open source licenses:
"Yes, this is just me and my crazy theories. I haven’t done exhaustive
research to prove that liberal-license communities thrive more than
GPL communities. But the anecdotal examples are staggering. The very
foundation of Mac OS X, the operating system through which I’m typing,
is thanks to the liberally-licensed FreeBSD operating system. "
 
 http://www.red-sweater.com/blog/825/getting-pretty-lonely

Loading mentions Retweet
Filed under  //   GPL   Licenses   Open Source  

Comments [0]

so true

the Apache Foundation, of course, widely known as a cruel experiment to see what happens when bureaucrats do open source.

Loading mentions Retweet
Filed under  //   apache   open source  

Comments [0]

JavaScript: The Good Parts


 
via:
http://google-code-updates.blogspot.com/2009/03/doug-crockford-javascript-good-parts.html

Loading mentions Retweet
Filed under  //   code   JavaScript   open source  

Comments [0]

How FriendFeed uses MySQL to store schema-less data

Friendfied uses MySQL to store schema-less data (much like CouchDB:
http://bret.appspot.com/entry/how-friendfeed-uses-mysql

Loading mentions Retweet
Filed under  //   code   open source  

Comments [0]

Installing Vista Fonts in Ubuntu

How to install Vista fonts in ubuntu (with shell script).
Consolas is a nice monospaced font for programming and shell use:
http://ubuntuforums.org/showpost.php?p=3376019&postcount=1

Loading mentions Retweet
Filed under  //   linux   open source   ubuntu  

Comments [0]

My new linux box

Since apple stubbornly refuses to release an updated mac mini I decided to switch back and buy a pc.
I didn't regret my decision. The new ubuntu release (8.10 intrepid) works just fine. Everything ran right out of the box without debugging or tweaking (sound, graphics, tv).
Then I played around with the system monitor conky, avant window manager and the ubuntu dust theme.
I think my desktop is even pretier then the OS X one (well maybe I was a bit tired of the look after ~3 years).
Well you may judge for yourself.

Here are some links if you're looking for the conky config or the theme:

Loading mentions Retweet
Filed under  //   linux   open source   ubuntu  

Comments [0]

30 Useful Open Source Apps for Web Designers

Nice collection of open source tools for webdesign:

http://sixrevisions.com/tools/30-useful-open-source-apps-for-web-designers

Loading mentions Retweet
Filed under  //   open source   web design  

Comments [0]

Doom as an admnistation tool

The author seems to have a quite simple idea of what system administration is about (killing processes, mostly), but its an idea with potential.

"Certain processes are vital to the computer's operation and should not be killed. For example, after I took the screenshot of myself being attacked by csh, csh was shot by friendly fire from behind, possibly by tcsh or xv, and my session was abruptly terminated. "

http://www.cs.unm.edu/~dlchao/flake/doom/

Loading mentions Retweet
Filed under  //   fun   linux   open source  

Comments [0]