Nerdabout: the art and craft of technology

Text Only

How To Install the W3 CSS Validator

November 23, 2009

Did you know that you can install the same CSS validation tool on your local machine? Follow the simple instructions below, to set yourself up to run the W3 CSS validator from the command line!

CSS Validation on the Command Line

Web developers are all familiar with the W3's CSS validation service.

CSS validation is an essential part of developing a Web interface. The same goes for XHTML validation and running JavaScript through JSLint.

Continue reading >

How To Use Lynx to Quickly List All the URLs On A Web Page

November 17, 2009

When used with the --dump option, Lynx parses an HTML document and builds a list of hyperlinks in that document.

If you have tried either of our previous Lynx recipes, then you may have noticed that, in addition to parsing out the textual content from Web pages. Lynx prints all of the URLs referenced in a document, as a numbered list at the bottom of the output.

how to use Lynx to list all the URLs in
an HTML page

Continue reading >

Lynx As A Simple (but Fast!) HTML Parser

November 10, 2009

There are numerous useful things that can be done with Lynx. For instance, you can quickly scrape a weather report for any US zip code.

Another little-known use for Lynx, is to preview HTML documents.

howto preview HTML from Maruku, using
Lynx

Continue reading >

Using Lynx to Scrape a Weather Report

November 03, 2009

Lynx As A Simple HTML Parser

One great and often-overlooked feature of Lynx is its --dump option.

lynx --dump <url> dumps the text content of the Web page at URL, followed by a numbered list of URLs that were referenced in that page.

how to use Lynx to scrape a weather forecast

Continue reading >

Python's SimpleHTTPServer: the World's Smallest Web Server?

October 27, 2009

When last we posted about tiny Web servers built with Ruby, Face-book friend Michael Cottingham immediately protested that Gary Robinson has blogged about a Python Web server that is in fact even smaller.

And the Python version seems to be more featureful than the Ruby version as well. For instance it is a bit more secure (and much more intuitive), in that "server root" defaults to the directory where SimpleHTTPServer was invoked. By contrast, the Ruby version blindly serves up everything in the root of the drive where it was invoked.

The internet is not a big truck

Continue reading >

Solution to the Perl Puzzler: by Aram

October 20, 2009

w00t!!1! Major congratulations to aram, who deciphered our very first code puzzler!

cksum file1 file_n | perl -ane 'warn if $F[0] != ($x ||= $F[0])'

Aram explained the convoluted code above as follows:

> Just a guess, it looks like it does a comparison of 2 files. 
> The chksum file file2 calculates and outputs the checksum which is 
> piped into a perl program.
> perl -a auto splits the output from checksum and puts it into array $F, 
> so F$[0] is the first element.
> the perl -n loops through all the piped input.
> $F[0] is the checksum of one file.
> $F[0] != ($x ||= $F[0]
> is true if $f[0] is not equal to $x or $F[0]. 
> it seems $x is set to $F[0] if not equal

Awesome, Aaram. Comparing the checksum of two files is exactly what this little one-liner is meant to do.

Hey Aram -- DM us on Twitter and let us know how we can get in touch with you! We'd like to send you a Nerdabout laptop sticker.

Pimp mah Laptop

Continue reading >

Set Up Passwordless SSH Login on Windows with Cygwin and SSH-Keygen

October 13, 2009

Here is how to set up passwordless login for SSH access to a remote server (including SVN over SSH) on Windows.

im in ur fiirwalz watchin ur pakkitz (by Andy Cunningham)

Getting this right has sadly eluded us for some time, even though the internets contain some really good articles on how passwordless login works as well as step-by-step instructions on how to set up passwordless login.

Still, putting it all together, on Windows, we found a bit tricky. But we've finally banged our heads up against a solution.

Continue reading >

The Magic of GNU Readline: Emacs' Commands Without Emacs

October 06, 2009

Take advantage of the convenience of Emacs keyboard commands, even if you aren't using Emacs. It turns out that quite a few pieces of software support the basic Emacs text-editing command set. All this is made possible of the GNU Readline library.

gnu emacs

There's a complete list of keyboard navigation commands in the Readline documentation. Or if you prefer, there is the bash/Readline cheatsheet :-;)

If you aren't already, you'll want to familiarize yourself with the the basic Emacs text-editing command set before trying these out.

Environments where you can use the Emacs keyboard shortcuts, that aren't Emacs

Mac OS X

Firefox, Safari and many other Mac OS X applications.

The IRB

The Ruby's use Emacs commands in the IRB interactive shell.

bash

The bash shell for Linux, BSD Unix and Mac OS X.

Cygwin

Cygwin, the Unix terminal emulator for Windows, runs bash and so supports Emacs keyboard navigation shortcuts

Cygwin (the Linux emulator for Windows): Emacs' Commands Without Emacs, part 4

September 29, 2009

When I wrote about bash support for the basic Emacs text-editing command set, I should have mentioned Cygwin, the bash emulator for Windows. Cygwin ships with a Linux terminal emulator, that runs bash and so supports Emacs keyboard navigation shortcuts.

Kill Bill
photo: wili_hybrid

If you haven't, try it. Especially if you are a Windows user and haven't tried they GNU/Linux tools yet.

Cygwin can change your life by enabling you to do things that you generally just can't do on Windows, at least not out-of-the box.

It's so awesome to have a free tool that will let you, for instance, search for files on your hard drive by name and by content, at the same time. And it's free. I'm consistently surprised by the preponderance of ten-to-fifty-dollar shareware programs, whose functionality can be duplicated with a 5 or 10 line shell script, and perhaps a little Perl.

How To Run the World's Smallest Web Server: one line of Ruby!

September 22, 2009

In 2008, Michael Neumann published a Ruby one-liner that leverages the power of Ruby's standard RSocket::TCPServer library, to start up a fully functional HTTP server; in just a single line of Ruby.

ruby -rsocket -e's=TCPServer.new(5**5);loop{_=s.accept;_<<"HTTP/1.0 \
200 OK\r\n\r\n#{File.read(_.gets.split[1])rescue nil}";_.close}'

teh internets-truck version03

cartoon: goopymart

Although there's no fancy stuff like 404 pages or redirects, you'll find that all the basic HTTP transactions work (eg you can follow links to other documents).

Once started, the server's root directory is the root of your local filesystem.

Continue reading >

bash: use Emacs' Commands Without Emacs, part 3

September 15, 2009

GNU Linux's bash shell supports the Emacs command set out of the box. Like IRB as well as many Mac OS X applications, you can navigate your way around the Bourne-Again SHell.

This is because Bash takes advantage of a library called GNU Readline

Here is a Readline Cheatsheet. Bash Emacs Editing Mode (readline) Cheat Sheet

As you can see, there are tons of features potentially available. That's because bash is a really large, featureful tool. You can work in bash for 10 or 20 years, and still find interesting things to learn, and find out about things you didn't know you could do.

Of course, many people are more interested in just getting some work done. In that case just stick to the the basic Emacs text-editing command set and you'll likely find that just mitigating your need to take your fingers off the home keys, can be a big boost to your productivity.

Use Emacs' Commands in the IRB

September 08, 2009

Ruby's interactive debugger, the IRB is a friendly and helpful shell environment for experimenting with and learning about Ruby.

Why's (Poignant) Guide to Ruby Cartoon: _why

The IRB has many nice features, not least of which is support for Emacs-style editing and keyboard navigation.

Not only is the basic Emacs text-editing command set supported, but the IRB also supports

selecting text with
C-SPC
or transposing characters with
C-t
as well as many other Emacsian keyboard shortcuts.

9 Essential Emacs Commands for Beginnners

August 17, 2009

By Noah Sussman

For many hackers, Emacs is one of those mysterious, crufty applications that pops up from time to time but has no real use; a leftover from the bad old days when computers didn't have graphical interfaces and most programs were written with a magnetic needle. And that's understandable because most chance encounters with Emacs occur in an ugly little terminal window with no mouse support.

But in fact Emacs is no relic. It's still widely used and has a living, vibrant community of developers and plugin writers. Modern Emacsen (that's the plural of Emacs) have mouse support, and a plethora of other features besides.

Emacs has a rich (some would say notoriously rich) keyboard command set. That shouldn't be surprising, since it was developed 30 years ago, before computers had mice.

CMU EMACS photo: fhisa

Continue reading >

10 useful but often-overlooked shell commands for Mac, Windows or Linux

June 10, 2009

Lately I have had the opportunity to configure a lot of workstations, and that has led me to read the documentation of several different collections of shell tools. Many of these distributions have been in development for decades, and there’s some funny stuff tucked away in there. Here are ten command-line oddities.

By the way, these commands should work, and you should be able to install them, equally easily for Linux, Macports and in Cygwin on Windows (except for Anagram, which afaik is only available as a binary for Windows.) Maruku is a Ruby gem and, assuming you have RubyGems already, installs with sudo gem install maruku (drop the sudo on Windows.)

fortune

Serves up a random string using a fortune-cookie database prepared with strfile. Although the common use is to serve up limericks when a process is started up, fortune can handle input files of large size, so its easy to use it for random access to very large collections of text. And entries can be of any length, so its possible to enable quite a wide variety of random information. man fortune reveals a command set including options like

        -o    Choose only from potentially offensive aphorisms.  

Fortune also contains awesome Ascii art, like this dragon:



                         ___====-_  _-====___
                   _--~~~#####//      \\#####~~~--_
                _-~##########// (    ) \\##########~-_
               -############//  :\^^/:  \\############-
             _~############//   (@::@)   \\############~_
            ~#############((     \\//     ))#############~
           -###############\\    (^^)    //###############-
          -#################\\  / "" \  //#################-
         -###################\\/      \//###################-
        _#/:##########/\######(   /\   )######/\##########:\#_
        :/ :#/\#/\#/\/  \#/\##\  :  :  /##/\#/  \/\#/\#/\#: \:
        "  :/  V  V  "   V  \#\: :  : :/#/  V   "  V  V  \:  "
           "   "  "      "   \ : :  : : /   "      "  "   "

However fortune has a very practical use, which is to break up an otherwise monotonous shell session buffer, with unique, recognizable tokens. For instance, I often set up my build or test automation clients to print a fortune with each run. I may confuse two time stamps occasionally, but I can always tell one limerick from another ;-)

strfile

Prepares fortune files, or more generally creates a text database from a text file. That is, any file foo that contains blocks of text separated by a line containing just a % character, is a fortune cookie file. Just run strfile foo and then start serving up customized fortune cookies.

wtf

Acronym explanation service. For instance, try wtf is pebkac Like fortune its simple to make your own databases. And like most shell commands its pretty easy (though probably not secure) to patch wtf into an IRC robot like Autumn. for a quick-and-dirty knowledge-base agent.

remind

Remind is a powerful calendar that can be either run from the shell or plugged in to a graphical (HTML) front end. Remind defines a domain-specific language which enables quick, accurate scheduling of complex, repeating events.. Thanks Ralph for telling us about this one.

anagram

Uses a dictionary of English words to identify anagrams in phrases. For longer phrases it can take hours to generate all the permutations. While the rest of these tools are *nix native, Anagram is available both as source and as a Windows binary.

maruku

Markdown translation on the command line. Great to preview blog posts locally, without the need to visit the Markdown Dingus at DaringFireball.com. Although editing in the browser has its conveniences, compiling markdown on the command line is much faster. And Maruku prints helpful error messages as well. Pipe it through Lynx to preview Markdown as rendered HTML, without launching Firefox:

        maruku shell-commands.markdown 
        lynx --dump shell-commands.html
nmap

reveals the open ports on a host, which information often reveals what services are running on that host. Great for figuring out the IPs of Web servers. Replaces tools like ping and tracert with a rich toolset for network discovery. Developed in the security field, this is also a tool for maintenance and diagnostics.

wget

I am surprised how many web developers do not yet know about the power and elegance of the automated browsers wget and curl. By invoking Wget with the arguments -pkr, it is trivial to archive an entire Web site, complete with binary resources and JavaScript/CSS includes. Even for sites that use cookie-based authentication.

scp

ftp and ssh rolled into one, scp is a fast way to put files on remote servers with a single command:

        scp myfile.html admin@example.com:~/domains/example.com/temp
tac

I recently learned about this command while reading Higher Order Perl. tac reads files backwards, from the bottom up. That’s very convenient, since the latest entries in a log file, are always located at the very bottom. This capability is also in tail but the syntax must be memorized. Meanwhile, tac is mnemonic (it’s the cat command backwards) and its output can immediately be viewed page-by-page with less

By Noah
The Nerdabout bloggers are (from left to right) Elizabeth Suman, John Son, Heather Quinlan, Joanna Burgess, Noah Sussman and Dave Caputo.
nerdabout group photo

@Nerdabout on Twitter

Please wait while our tweets load…

Or visit the Nerdabout's Twitter.

Advertisement

Nerdabout's TumbleBlog

Currently listening to…

David Caputo is rockin out to…

Noah Sussman listens to…

Nerdabout on Flickr

Joanna Burgess on Flickr


Noah Sussman on Flickr


Dave Caputo on Flickr


Heather Quinlan on Flickr


Elizabeth Suman on Flickr


John Son on Flickr

SITE SEARCH
SUBSCRIBE TO OUR NEWSLETTERS
CREDITS Photos: iStockphoto | Getty Images | AP | Wikipedia | DCL |
DISCOVERY SITES Discovery Channel / TLC / Animal Planet / Discovery Health / Science Channel / Planet Green / Discovery Kids / Military Channel /
Investigation Discovery / HD Theater / Turbo / FitTV / HowStuffWorks / TreeHugger / Petfinder / PetVideo / Discovery Education
SHOP Toys / Games / Telescopes / DVD Sets / Planet Earth DVD Sets / Gift Ideas
CUSTOMER SERVICE Viewer Relations / Free Newsletters / RSS /
CORPORATE Discovery Communications, Inc / Advertising / Careers @ Discovery / Privacy Policy / Visitor Agreement
ATTENTION! We recently updated our privacy policy. The changes are effective as of Tuesday, October 30, 2007. To see the new policy, click here. Questions? See the policy for the contact information.