stefan.grothkopp.com

Relax - This won't hurt. 
Filed under

linux

 

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]

ubuntu

"Ubuntu is an African word meaning 'I can't configure Debian'"
 
http://tech.slashdot.org/comments.pl?sid=1248415&cid=28126731
 
thanks for the link stefan!

Loading mentions Retweet
Filed under  //   linux   ubuntu  

Comments [0]

satisfaction with operating systems


 
I found it on appleinsider.com so it's possibly biased:
http://www.appleinsider.com/articles/09/03/26/microsoft_to_attack_mac_pricing_in_new_series_of_tv_ads.html

Loading mentions Retweet
Filed under  //   linux   operating systems   os x  

Comments [0]

difference between apt-get and aptitude

i finally discovered the difference:

 
sg@lt7:~$ apt-get moo
        (__)
        (oo)
  /------\/
 / |    ||
*  /\---/\
   ~~   ~~
...."Have you mooed today?"...
sg@lt7:~$ aptitude moo
There are no Easter Eggs in this program.
sg@lt7:~$

Loading mentions Retweet
Filed under  //   linux  

Comments [1]

Parallelizing Jobs with xargs

xargs is one of my favorite linux commands. Here is a "new" use for it:

 http://www.spinellis.gr/blog/20090304/

Loading mentions Retweet
Filed under  //   linux  

Comments [0]

Convert a website to a pdf.

This is how you can convert a whole internet site (= multiple pages
with links) to an nice pdf document on linux.
 
http://kmkeen.com/mirror/index.html

Loading mentions Retweet
Filed under  //   code   linux  

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]

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]

Terminator on ubuntu linux

I wanted to install the newest version of the terminal client terminator in ubuntu hardy.
You can find terminator here:
http://www.tenshu.net/terminator/
However after I added the apt-source and ran "apt-get update" I got stuck a the following error:
"W: GPG error: http://ppa.launchpad.net hardy Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 978228591BD3A65C"
After some searching I found this solution:

gpg --keyserver wwwkeys.eu.pgp.net --recv-keys 978228591BD3A65C
gpg --armor --export 1BD3A65C | apt-key add -

then run apt-get update && apt-get install terminator

Loading mentions Retweet
Filed under  //   linux   open source   ubuntu  

Comments [0]