stefan.grothkopp.com

Relax - This won't hurt. 
Filed under

code

 

Mail-Adress validation with perl

"Implementing [email] validation with regular expressions somewhat
pushes the limits of what it is sensible to do with regular
expressions, although Perl copes well."

If you hear that from a perl-guru it's like your dentist saying "this
might hurt a little bit". In both cases: run!

See for yourself:
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

Loading mentions Retweet
Filed under  //   code   coding  

Comments [0]

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]

Semantic fail

 The semantic web isn't really there yet. This is what happened after
some company tried to extract medical information from wikipedia.

  http://languagelog.ldc.upenn.edu/nll/?p=1715

Loading mentions Retweet
Filed under  //   code   web  

Comments [0]

Bridging desktop and browser with Swell’s native Drag and Drop implementation

This looks promising:
 http://blog.justswell.org/swell-javascript-native-dragdrop-implementation/

Loading mentions Retweet
Filed under  //   Code   JavaScript  

Comments [0]

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]

infully.com

my new pet project:
http://infully.com/

 it's supposed to be a social "news" site for webdesigners and programmers.
You'll find links to articles regarding javascript, design, css/html
and other stuff.
Hopefully it will gain some traction.

Loading mentions Retweet
Filed under  //   code   design   projects  

Comments [0]

JavaScript language advanced tips and tricks

nice JS tips here: code.google.com


Loading mentions Retweet
Filed under  //   code   JavaScript  

Comments [0]

An unthinking programmer's guide to the new C++

I must say that was about as lucid as the text of a software licence agreement and half as amusing. Is there anything else to which you would like to draw my attention?

Yes, C++0x is going to be a lot of fun :)

Loading mentions Retweet
Filed under  //   code  

Comments [0]

URL Unshortening Web Service With JSON/P Support

http://therealurl.appspot.com/

Loading mentions Retweet
Filed under  //   code   javascript  

Comments [0]

Slashdot | DirecTV's Secret War On Hackers

"To add a little pizzazz to the operation, DirecTV personally "signed"
the anti-hacker attack. The first 8 computer bytes of all hacked cards
were rewritten to read "GAME OVER". "
 
http://slashdot.org/articles/01/01/25/1343218.shtml

Loading mentions Retweet
Filed under  //   code  

Comments [0]