Filtered by Linux

Page 10

Reset

Redirect stderr into becoming dots in Bash

September 2, 2006
3 comments Linux

Here's a whacky idea; in a shell script I want to convert every line of stderr into a . on the same line. I'm still a shell scripting newbie but I know that bash can be quite powerful if you know what you're doing to it.

To begin with I've written a little wrapper on cvs commit called ~/bin/cvs_commit which does the following:


#!/bin/sh
cvs commit -m "$1" | grep -v '\.bak*' | grep -v '\.pyc'

Because cvs prints all folders it recursively traverses I if it's a big tree all of that ugly stuff is print to screen via stderr. To get rid of that, I've changed my command to:


#!/bin/sh
cvs commit -m "$1" 2>> /dev/null \
| grep -v '\.bak*' | grep -v '\.pyc'

Let's improve even more...

Truncated! Read the rest by clicking the link below.

slim in ruby

July 26, 2006
0 comments Linux

Just figured out how to call my slim web service via XML-RPC using Ruby. It's as easy as in Python.

Here's the code:


require "xmlrpc/client"
# Make an object to represent the XML-RPC server.
server = XMLRPC::Client.new( "www.peterbe.com", "/")
# Call the remote server and get our result
result = server.call("slim", "h1 { font-family: Arial;}","css")
puts result
result = server.call("slim", 
  "function add(var1, var2) { return var1 + var2; }","js")
puts result

And when you run this on the command line this is what you get:


$ ruby dummy.rb
h1{font-family:Arial}
function add(_0,_1){return _0 + _1;}

Geeking with tags file for Jed

May 29, 2006
0 comments Python, Linux

A little while ago I wrote about how I got Jed + TAGS to work thanks the ntags library. I've been using it now for a while and I love it! I doubt there are any IDEs that beats a swift combination of Ctrl+2 followed by Alt+. and you get the definition of a function or variable without losing any focus.

If you're not into programming stop reading now because it's going to get even more technical.

Truncated! Read the rest by clicking the link below.

SVN + ./todo + crontab

May 20, 2006
1 comment Linux

I've now started playing with ./todo which is a really promising method (for me) for maintaining a simple todolist. When at work I more or less live on the command line and can do things there much faster than I can with an online todolist or a proper GUI. Now I simply write:


$ todo add Call Jan about svn repo

and it adds "Call Jan about svn repo" to my todo list. To view the todo list I simply write:


$ todo list

Every item in the list has a number which you can use to mark things done or change priority.

Anywho, now I've put my little todo.txt in my personal SVN repository on one of our servers. But, how do I make sure that my changes to the todo list are always backed up with SVN (subversion)? I could hack the ./todo script to do a svn commit on every change and svn update every time I do a ./todo list but that would be far too slow.

Truncated! Read the rest by clicking the link below.

type - Writing shell scripts

April 28, 2006
1 comment Linux

I've started skimming through the lovely Writing shell scripts tutorial and even though I'm just in the beginning of it I've already learnt one very useful thing: the type program. With it you can find out "what type of command it is". This is useful because sometimes you want to know where some command is coming from. I'll let this example explain its usage:


peterbe@trillian:~ $ type jed
jed is /usr/bin/jed
peterbe@trillian:~ $ type cvs_commit 
cvs_commit is /home/peterbe/bin/cvs_commit
peterbe@trillian:~ $ type alias
alias is a shell builtin
peterbe@trillian:~ $ type sjed
sjed is aliased to `sudo jed'

I'll read more of this after the weekend.

Teach me about OCR

March 25, 2006
0 comments Linux

I might soon need a good OCR program to read scanned in pages but these pages aren't perfectly scanned pages from a novel. The kind of pages I'm scanning are stuff like printed out invoices and other stuff like that with tables, headers, logos, footers, etc.

The only program I've looked ocrad and I've had pretty decent results with it. I did scan an invoice and thanks to a quick python script I was able to find out the correct rotation with a 57% confidence (the second best was 37%). That's a start. ocrad seems very flexible and quite active judging from the mailing list

I guess I need to do more research into tuning ocrad with the right charsets, image formats and some of the immediate options of ocrad before I give up. When I scanned my invoice, the words it found did look like words but not much qualitative could be used out of. The company that sent the invoice was for example not anywhere in the recognized words :(

What do people use out there? I bet Amazon didn't just use ocrad when they did their Search Inside the Book

Why Linux is better

March 1, 2006
0 comments Linux

Manu Cornet of the Ubuntu team has created a simple yet effective site called Why Linux is better which I thought was pretty good.

Microsoft spend million$ on their "Get the facts" campaign where they get "independent" companies (affiliated with Microsoft if you read the fine print) to say that Windows is better than Linux. Sure enough, there are some points where Windows is better but far more where Linux is better than Windows. Anyway, this is what Manu is up against and still his delivery is much better than the Get the facts campaign. All he has to do is to be honest.

Keep up the good work Manu!

Jed Tags with ntags (for dummies)

February 11, 2006
2 comments Linux

Working with Jed just got better. I've finally figured out how to use TAGS with Dino Leonardo's ntags extension

When programming in Jed I can now hold the cursor over a function in the code and by just hitting Alt+. it quickly jumps to the definition of that function. This is great if you for example need to quickly find out how a function works and what the parameter options are without having to a) dig out where it is defined (which file) and b) dig out where in the file it's defined.

Truncated! Read the rest by clicking the link below.

Geeking with Eterm and Tkinter

February 9, 2006
0 comments Linux

Something that I do at least a couple of times every day when working here in Linux is to take a blank screen and set up a few command line terminals for developing with Zope. One terminal in which I'll run the editor (Jed of course), one in which I'll run Zope in debug mode and one in which I'll run my product refreshing script. I want the terminal windows of certain sizes and positions and I want to be in a particular directory in each terminal so that I have easy access to stuff like ./bin/runzope and jed Products/SomeProduct/....

Still with me? Cool, that means that you probably do something similar or that you're just extremely bored and have too much time.

Truncated! Read the rest by clicking the link below.

Who do you ping?

January 19, 2006
9 comments Linux

If you don't know what ping is, it's a program that tests the network connection between your computer and another host. When you run it you can see how fast the connection is but people use it mainly to test if it's even possible to make the network connection.

Often when I've had to struggle to get connected to the network (fiddling with the Ethernet cable or getting on a wifi broadcast) I often use ping to see if the internet connection works. Which host do I ping? I use www.com.

For a long time I was using www.google.com for no obvious reason. My colleague Zahid uses yahoo.com I noticed yesterday when I was leaning over his shoulder after connecting to a wireless router. So, who do you ping? (and why?)