Archive for September, 2009

Wisdom by Python (Easter Egg)

An easter egg by python displays a list of quotations, useful in programming and in many cases in life as well.

In your shell, type this:

1
python -c 'import this'

You’ll get this:

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea — let’s do more of those!

via commandlinefu

Have fun ;)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Monday, September 28th, 2009 Easter Eggs 1 Comment

Fix Facebook Chat in Firefox 3.5 (Shiretoko) in Ubuntu

Since I upgraded Firefox to 3.5 (Codename : Shiretoko), I noticed that Facebook chat does not work anymore, moreover, in order to get notifications for new events, I had to refresh the page manually.

After a search at Google, I found the problem, and the way to fix it: Looks like Ubuntu had decided to rename the user-agent into “Shiretoko” which is the codename of firefox 3.5, instead of “firefox”.

Because of the new user-agent name, Facebook does not recognize the browser as firefox, and thus disables some features that are browser dependent.

In order to fix the problem:

1. In the URI bar (that’s the place where you type the URLs of websites you want to visit), type “about:config” (without the double quotes).

2. Click the funny button “I’ll be carefull, I promise”.

3. Now look for “general.useragent.extra.firefox”, right click it, and choose “Modify”.

4. Instead of “Shiretoko”, type “Firefox”. (e.g. if you had “Shiretoko/3.5.4pre” it should become “Firefox/3.5.4pre”.

That’s it, now the world should be a better place ;)

via vimtips.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Sunday, September 27th, 2009 Firefox 7 Comments

Embed A Document Using Google Docs

You can embed a document viewer for any PDF or PPT using Google Docs.

You will get something similar to this:

The code I used for the above is:

1
<iframe src="http://docs.google.com/gview?url=https://agora.cs.illinois.edu/download/attachments/10456143/vim.pdf?version=1&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>

Or in general:

1
<iframe src="http://docs.google.com/gview?url=DOCUMENT_URL_HERE&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>

Where DOCUMENT_URL_HERE should be replaced by the document’s URL ;)

via Google Operating System.
Smile ;)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: ,

Sunday, September 27th, 2009 Google No Comments

Re-Use A Bash Command With Different Parameters

Suppose you have typed and executed this command in your Linux shell:

1
./script_a.sh 1.23 && ./script_b.sh 1.23 && ./script_c.sh 1.23.45

Now you want to run the same command, but with 2.34 instead of 1.23
A nice way to do it is this:

1
!!:gs/1.23/2.34

Meaning, run the last command (!! is also called ‘bang bang’, and it’s substituted by the last command you executed), and replace every instance of 1.23 by 2.34

via Unix Bash Scripting.
Have fun ;)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: ,

Sunday, September 27th, 2009 Bash No Comments

Make Shell Scripts Executable By Default

If you use vim to write shell scripts, you might want to save the “chmod +x” command after saving the script.

By adding the following line to your vimrc file (typically, it’s located at ~/.vimrc), scripts will automatically become executable.

au BufWritePost * if getline(1) =~ “^#!” | if getline(1) =~ “/bin/” | silent !chmod a+x <afile> | endif | endif

(meaning, if the file includes #! with “/bin/” in the path, apply “chmod a+x” on this file).

via shell-fu.

Have fun ;)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , , ,

Saturday, September 26th, 2009 Vim No Comments

Fetch Links From Twitter Into Your RSS Reader

Twitter streams are usually full of links, most of them are shortened by a URL shortener, and filtering them might be time consuming.

A cool service, Readtwit, solves this problem intelligently: Using Readtwit, you can easily create a RSS feed of all links appearing in your twitter stream. The service will fetch the links, and send the full story to your RSS reader. It allows you to filter the tweets (block people and block hashtags).

Neat and time-saving. Try it and have fun ;)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Saturday, September 26th, 2009 Twitter No Comments

Google Reader Useful “Send To” Services

Recently, Google have added a “send to” feature to Google Reader, which allows one to share an item in social networks (Facebook, Twitter, etc…).

The greatest thing in this feature is, that Google allows you to add custom sites to the “Send To” destinations. A few nice sites are listed below:

1. Download item as PDF (via)

Name: Save as PDF
URL: http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL=${url}
Icon URL: http://www.adobe.com/lib/com.adobe/template/icon/pdf.gif

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Saturday, September 26th, 2009 Google No Comments

Tools to Improve the Quality of Your Code

Just found a nice link at Wikipedia with a collection of tools to help analyzing the quality of your code.

One interesting one is PMD (for Java), which is opensource. It statically analyses your code and alerts for potential problems.

For C, there is splint (opensource as well), which statically analyses your code for potential coding mistakes and security vulnerabilities.

The full list at Wikipedia is here.

Another great tool, which is not directly related to the above, is Valgrind. While the above statically analyze your code (i.e., they find potential problems by “just looking at the code”), Valgrind is a tool for dynamic analysis, which means, it analyses the code by monitoring the way it runs. It can report possible memory leaks, possible deadlooks, and many other information. (The full tool suite description can be found here). The output of Valgrind is not very easy to read, but with a little practice one can feel more comfortable with it.

There is also a list of tools for dynamic analysis at Wikipedia. It’s located here and may be worths a glance.

Enjoy coding ;)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: ,

Saturday, September 26th, 2009 Programming No Comments

Computer Security Articles

I just found a great collection of computer security related articles. They’re informative yet simple and well explained.
One interesting article is the “Buffer Overrun Attacks” found here.
The complete collection can be found here.

via rootsecure.net

Enjoy :)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Sunday, September 6th, 2009 Security No Comments

Trimming Bash Variables – A Summary

This post should summarize the subject of stripping out bash variables, we already talked about on previous posts

Let’s say we have a bash variable (say x), which stores a string (say “ExExampleStringStr”)

Then we can do the following manipulations:

1.

1
y=${x%Str*}

This will trim out the shortest match of the pattern “Str*” from the end of the string.
Thus, y will have the value “ExExampleString”.
› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags:

Saturday, September 5th, 2009 Bash No Comments
my email
my photo
Hi,
My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
I'm a Verification Engineer in Mellanox Technologies Ltd.
I love Linux, the Command Line and the OpenSource Community.
I used to write Poems (Arabic) when I was able to find time for this.
September 2009
S M T W T F S
« Jul   Dec »
 12345
6789101112
13141516171819
20212223242526
27282930  
SEO Powered by Platinum SEO from Techblissonline

Twitter links powered by Tweet This v1.7.4, a WordPress plugin for Twitter.