This Blog is Dead, follow me at my new blog

You can now follow my adventures at my new blog, http://julianapena.com/
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, July 23, 2007

Text Editors: Notepad++ and GVim go Portable

A few days ago, Notepad++, the famous Windows text editor, was released as a PortableApp, Notepad++ Portable. I have used Notepad++ for quite some time now, and I am very glad that now I can easily take it anywhere I want on my USB flash drive.

For those of you with a more classic, Unix-y taste, there is also GVim Portable, which takes up a LOT more space than Notepad++, but includes all the amazing features of Vi withing an easy-to-use graphical interface.

Click Here to go to the Notepad++ Portable home page.
Click Here to go to the GVim Potable home page.

Friday, July 13, 2007

Learn Python in 10 minutes


Link: Learn Python in 10 minutes

If you're an experienced programmer but never got around to learning Python, now's your chance! This quick guide explains the complete syntax of this powerful and modern programming language.

Be aware that this guide is NOT for beginners who have never programmed before. For those of you, I highly recommend How to think like a Computer Scientist: Learning with Python, an amazing e-book for the beginning programmer.

Happy coding!

Wednesday, July 4, 2007

Programming: Find prime numbers

Today I bought a new book about programming and algorithms. One of the first examples in the book, which I found very simplistic yet interesting, is the algorithm for finding prime numbers. It goes like this:

  1. Let N be the number you want to find if it is prime or not
  2. Let X be 2
  3. If N equals X, N is a prime. End.
  4. Divide N by X
  5. If the result is an integer, N is not prime. End.
  6. Add 1 to X.
  7. Go to step 3.
In Python, this can be implemented with the following function:
def isitprime(n):
x=2

while True:
if n==x:
return True
elif n%x == 0:
return False
x+=1

Sunday, July 1, 2007

How to: Make a Google Notebook button for the Google Toolbar

In my previous post, I discussed making a button for the Google toolbar which links to Google Reader. In this post, I will make a similar button, but for Google Notebook.

This button is much simpler than the last one because Google Notebook doesn’t have any feeds to link to. It’s basically just a link with an image. Google Notebook DOES have a search capability, but I can’t seem to be able to implement it with this button since it’s an Ajax-y search.

Anyway, here is the finished button:

<?xml version="1.0" encoding="utf-8">
<custombuttons xmlns="http://toolbar.google.com/custombuttons/">

<button>

<site>http://google.com/notebook</site>

<title>Google Notebook</title>

<description>Google Notebook</description>

<icon mode="base64" type="image/x-icon">
AAABAAEAEBAQAAAAAABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAMAABILAAASCwAAAAAA
AAAAAADm5ubm5ubm5uY0KQA0KgA0KgA2KwA2KwA2KwA2KwA1KwA0KQA0KQA0KQDm5ubm5ubm5uYy
KQD///////////////////////////////////////9osno/kE0yKQDm5ubm5uYyKQD////Jl1LI
llHHlVDFk07DkUzBj0q+jEe8ikWtezZosnpAkE00KgDm5ua2uK19fnd7fHXPnVjOnFfMmlXLmVTI
llHFk07DkUy/jUiwfjlosnpAkE00KgDm5ub8/PvR0su2uK3Vo17Uol3SoFvQnlnNm1bKmFPHlVDD
kUy0gj1osno+jko3LADm5ubm5uZAMwb////bqWTaqGPYpmHVo17ToVzPnVjLmVTHlVC2hD87j0vR
0stCNQfm5ubm5uZCNQb////hr2rfrWjerGfbqWTYpmHUol3QnlnLmVS5h0KM5OokzelCNQfm5ua2
uK19fnd7fHXntXDmtG/jsWzgrmncqmXYpmHUol3PnVi8ikWM5OokzelGPRXm5ub8/PvR0su2uK3t
u3bruXTpt3Lls27hr2rdq2bYpmHToVy/jUiM5OokzelGPRXm5ubm5uZQQxr////zwXzxv3ruvHfq
uHPls27grmnbqWTWpF/Bj0qL4+okzOhPQhnm5ubm5uZWSiD////3xYD1w37/////////////////
///YpmHDkUwz0OnR0stXSyHm5ua2uK2LjYSCg3v8yoX5×4L+/fz////////////////aqGPFk06k
nuhIPZhcUSnm5ubm5+Pd3ti2uK3/zov8yoX3xYDywHvtu3bntXDhr2rbqWTGlE+lnuhIPZhiWDHm
5ubm5uZlWzT/////z439y4b4xoHzwXzuvHfntXDisGvbqWTHlVClnuhIPZhiWDHm5ubm5ubm5ubt
u3bsunXpt3Lls27hr2rcqmXWpF/Rn1rLmVTFk06noOhIPZloXjXm5ubm5ubm5ubm5uZwZUFwZUFw
ZUFwZUFwZUFwZUFwZUFwZUFwZUFwZUFwZUHm5ubm5ubgA///gAH//4AB//8AAf//AAH//4AB//+A
Af//AAH//wAB//+AAf//gAH//wAB//8AAf//gAH//8AB///gA///
</icon>

</button>

</custombuttons>


Again, just copy that to the text editor and save it in the corresponding folder (C:\Documents and Settings\(your username)\Local Settings\Application Data\Google\Custom Buttons for Windows and /home/(your username)/.google/custombuttons for Linux).

It looks like this:


How to: Make a Google Reader button for the Google Toolbar

I’ve recently fallen in love with Google’s numerous applications — from Google Calendar, to Gmail, to Google Desktop, and now the Google Toolbar. I previously considered it unnecessary clutter to my Firefox configuration, but now that I use so many Google services, it’s become pretty handy. Google maintains a quite large repository of buttons for the toolbar. So I quickly added the buttons for the services I used. But I did not like the Google Reader button at all. First of all, it’s green of all colours when there are no new items in your Google Reader account. Second, there is no drop-down menu like there is for Gmail and Gcal buttons.

So I decided to make my own button.

All the documentation necessary to make buttons is available on Google’s website. Making a button was extremely easy this way.

I extracted the favicon from the Google Reader site to use as the button, and created a second button by editing it with The Gimp, for when I had new unread items. Also, unlike the button available in the gallery, this one has a drop-down menu to see your new items in your feeds. The only downside is that it has to be user-modified to work with your Google Reader items. Also, since Google Reader doesn’t have a search functionality, this button doesn’t search for anything.

Here is the finished code for the button:

<?xml version="1.0" encoding="utf-8">
<custombuttons xmlns="http://toolbar.google.com/custombuttons/">

<button>

<site>http://www.google.com/reader/view</site>
<title>Google Reader</title>
<description>Google Reader RSS Aggregator</description>

<icon>
AAABAAIAEBAAAAAAAABoBQAAJgAAABAQAAAAAAAAaAQAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAA
AEABAAAAAAAAAAAAAAAAAAAAAAAA////AMyinwC7lpMA57i1AP/08wD/9/cA997dAPzRzQD5ycUA
98K9ALyJhAD+7OsA9OnoAPC0rwDorKcAqnh0AMysqQD4urUArYJ+APzZ1gDpxsQA+LOtAKZwawD4
q6QApWhjAPSlngDNmZQA/ubjAPGakwC5eXMAuXRuAP///wD///8A////AP///wD///8A////AP//
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////
AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A
////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD/
//8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////
AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A
////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD/
//8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////
AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A
////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD/
//8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////
AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A
////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD/
//8A////AP///wD///8A////ABgYGB0eHh0eHh0dDxgYGBgYGAoZEQMZHBwcHAEWGBgYGBgKCAAA
HAkLFwkGFhgYGBgYCggACxwJABwGCxgQEBgYGAoNHBwZCwAZCwYWCQMQGBoKGREIBgAREQAJGAYL
EBoNChkGAAARGQsADhgGABABBgoNGRkXEQsACRkYAAYQAQcKCQgHCwAACA0ZGAAGGgEJCg4LAAsG
EREREBgACBABEQgSEg8KDxYdDxgABggBAQ0LAAANDQsADQoABggIAQEJEREREQsACAMdBgYGFBAB
BwcGCwALEQMODxAQEBAYAQMLAAAGBwgJAwoYGBgYGBgBAgICAgICAgIYGBgYGBjgD4u8wAdQ4MAH
LADAAQAAwAAA3YAAAAAAAAAAAAAAAAAAAAAAAASwAAAQVAAAEFQAAAACAAEABwAfAACAP4rQKAAA
ABAAAAAgAAAAAQAgAAAAAABABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALl5c/+5dG7/
uXRu/7l5c/+5eXP/uXRu/7l5c/+5eXP/qnh0/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAK2Cfv/0
pZ7/98K9//C0r//0pZ7/8ZqT//Gak//xmpP/8ZqT/8yin/+mcGv/AAAAAAAAAAAAAAAAAAAAAAAA
AAC8iYT//NHN////////////8ZqT//fCvf/+7Ov/+Kuk//nJxf/33t3/pnBr/wAAAAAAAAAAAAAA
AAAAAAAAAAAAvImE//nJxf//9PP//uzr//Gak//5ycX///////Gak//82db/9Ono/6Zwa//MrKn/
zKyp/wAAAAAAAAAAAAAAALyJhP/4s63/8ZqT//Gak//0pZ7//uzr///08//0pZ7//uzr//fe3f+m
cGv/98K9/+nGxP/MrKn/AAAAAM2ZlP+8iYT/9KWe//i6tf/5ycX//ubj///////4urX/+Lq1////
///3wr3/pWhj//fe3f/06ej/zKyp/82ZlP/wtK//vImE//Slnv/+5uP////////08//4urX/9KWe
///08///9PP/6Kyn/6VoY//+5uP///Tz/8ysqf/Mop///NnW/7yJhP/4s63/9KWe//Slnv/4s63/
+Lq1///08///////98K9//Slnv+laGP///Tz//Tp6P/MrKn/zKKf//zRzf+8iYT/98K9//nJxf/8
2db//uzr////////9PP/+cnF//izrf/4q6T/pWhj///////82db/zKKf/8yin//3wr3/vImE/+is
p//+7Ov///Tz//7s6//82db/98K9//i6tf/4urX/zKKf/6Zwa///9/f//NHN/8yin//Mop//+Lq1
//nJxf+tgn7/rYJ+/62Cfv+tgn7/qnh0/6p4dP+qeHT/qnh0/6p4dP///////NnW//nJxf/Mop//
zKKf//izrf/+7Ov////////39//4urX/+LOt//7s6///9PP/+Lq1/7yJhP//9/f/997d//zRzf/5
ycX/zKKf/8yin//3wr3/+Lq1//i6tf/3wr3/+Lq1//7s6///////+cnF//C0r/+tgn7//NnW//zZ
1v/82db/6cbE/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DhkcGxAOGRoQBhsWFBMKChEQEBEQGRwTDgUVFRUSDAoUFBYZHBgRDg0DDAwMDB0K
DxobGhYUExEPBh0dHR0dHQoHBwcHBwcHBx0dHR0dHeAPAADABwAAwAcAAMABAADAAAAAgAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAB8AAIA/AAA=
</feed-icon>

</button>

</custombuttons>


That’s it. Copy that to a text editor (eg. Notepad). All you need to do now is put your Google Reader reading list feed where the red text is. To find your feed, go to the Google Reader site and click on the RSS button next to the address bar:


Now copy what’s in the address bar to where the red text is, and save the file as google-reader-button.xml in the custom buttons folder. In Windows XP, this is located under C:\Documents and Settings\(your username)\Local Settings\Application Data\Google\Custom Buttons. In Linux, this is in /home/(your username)/.google/custombuttons.

So, there it is. The finished button looks like this: