Bravo to Barnes and Noble for standing up to Microsoft. I always get my books from them.

Happy birthday, Vim!

========================================

Preface: There is a computer programming language that is oriented towards new developers. That language is called Python. It is available for most every platform. (i.e. MSWindows, OS/X, BSD,. Linux and etc.  Though there are no fancy graphics in what was done in this project, you could surely add that feature. Just wanted to show a bare bones project that anyone could use to start with.

One of the reasons I like to do page scraping is to get the data I need without having to take time to use a web browser such as Firefox and or a newsreader to get the specific data I need. Letting the computer get the data for me and making a summary file of the data I need is therefore letting the computer be my secretary and or research assistant.

Have been doing some page scraping but i was not able to get the weather from their (Google) site. Then read they have it sort of hidden. Was able to get a page of the xml they use to show the data. Aha!   Then found a short piece of code of how to use the api.

The xml shorted version (usinghttp://www.google.com//ig/api?weather=huntsville) :

<xml_api_reply version=”1″>

<forecast_information>
<city data=”Huntsville, AL”/>
<postal_code data=”huntsville”/>
<latitude_e6 data=””/>
<longitude_e6 data=””/>
<forecast_date data=”2011-11-18″/>
<current_date_time data=”2011-11-18 21:50:00 +0000″/>
<unit_system data=”US”/>
</forecast_information>

<current_conditions>
<condition data=”Clear”/>
<temp_f data=”55″/>
<temp_c data=”13″/>
<humidity data=”Humidity: 29%”/>
<icon data=”/ig/images/weather/sunny.gif”/>
<wind_condition data=”Wind: SE at 8 mph”/>
</current_conditions>

</xml_api_reply>

So then it was a matter of just plugging in variables. Almost cut and paste. Anything in single quotes was extracted from the xml sort of.  I also make it so that you did not have to redo the code of a different location. This also could be done in a gui environment, but for simplicities sake that part was not included.

weather.py:

<br />
import sys<br />
import&nbsp; pywapi<br />
import string<br />
<br />
google_result = pywapi.get_weather_from_google(sys.argv[1])<br />
<br />
print "\nThe weather report for " + sys.argv[1] + "&nbsp; on " + google_result['forecast_information']['current_date_time'] + " in: " +&nbsp; google_result['forecast_information']['city'] + " \n"<br />
<br />
<br />
print "Sky condition: " + string.lower(google_result['current_conditions']['condition']) <br />
print "Temperature: " + google_result['current_conditions']['temp_f'] + "F"<br />
<br />
print google_result['current_conditions']['humidity'] <br />
<br />
print google_result['current_conditions']['wind_condition'] <br />

usage: python weather.py zipcode or python weather.py “city state”

$ python weather.py 10001

The weather report for 10001  on 2011-11-18 21:51:00 +0000 in: New York, NY

Sky condition: clear
Temperature: 44F
Humidity: 37%
Wind: N at 0 mph

$ _

Note: I had to install the pywapi
$ sudo apt-get pywapi

This was a lot easier than page scraping. Anyway enjoy.

=============================================

Note: This also works for the graphics mode.

Do this at your own risk as I will not be responsible for any issues:

One of the biggest complaints I get is the text screen is too small. I
generally agree. More recent computers actually have the ability to use a
higher resolution, but do not take advantage of it in the default mode.
This article is for more advanced users. Please get help before
starting this project if you are at least the little bit. unsure.

You will need to have the documentation for both your video card and for
your monitor. You will see numbers like 640×48 800×600 1024×768. Take
those numbers and use the lower of the two from the video card and the
monitor settings. If you can only use 640×400 then stop here. The
640×400 is the default. There is a 320×200, but I have not see that in
years,

In my case the highest resolution for the monitor was 800×600. Still a boost over the default 640×400 screen.

Lastly you need to find out what your linux system uses to boot, Lilo(we will not consider it), Grub (aka Grub1) or Grub 2.

For our purposes we will be using Grub 2 for the images. Pictures at this point, are the original screen shots.

——————————————————–

Grub 1:

This is the easiest setup. as you only have to edit one file and then reboot.

$ sudo vim /boot/grub/menu.lst

or if you do not have vim

$ sudo nano  /boot/grub/menu.lst’

# (0) Arch Linux
title  Arch Linux
root   (hd2,2)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/1069fde9-8696-49a8-bbec-b8f35458f4d9 ro
initrd /boot/kernel26.img

We need to choose the number for our monitor and graphics card. we need
to look at the table to get a number that linux understands. We are just
going to use the 256 line as colors are not critical for our test setup. In our case it is 800×600, so we would use 0x303.

640×480 800×600 1024×768 1280×1024
256 0x301 0x303 0x305 0x307
32k 0x310 0x313 0x316 0x319
64k 0x311 0x314 0x317 0x31A
16M 0x312 0x315 0x318 0x31B

You will need to translate the hexadecimal numbers to decimal. Using a search
engine can convert it for you. We need to append vga=771 to the kernel
line.

# (0) Arch Linux
title  Arch Linux
root   (hd2,2)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/1069fde9-8696-49a8-bbec-b8f35458f4d9 ro vga=771
initrd /boot/kernel26.img

Check you woirk. Some times it might be a good idea to copy the original
lines, so in case the numbers do not work you can always still get into
the system.

# (0) Arch Linux
title  Arch Linux
root   (hd2,2)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/1069fde9-8696-49a8-bbec-b8f35458f4d9 ro vga=774
initrd /boot/kernel26.img
# (1) Arch Linux
title  Arch Linux default resolution
root   (hd2,2)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/1069fde9-8696-49a8-bbec-b8f35458f4d9 ro
initrd /boot/kernel26.img

Check your work, save your work, and reboot. You should not ge able to do the new resolution.

———————————

Grub2

Grub2 is a little more complicated and you need to be extra careful.

First we need to edit the /etc/default/grub file. At least you no longer have to do the hex conversion.

$ sudo vim /etc/default/grub go down to this part of the file and add GRUB_GFXMODE=800×600 leaving the original line as is.

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo’
#GRUB_GFXMODE=640×480
GRUB_GFXMODE=800×600

Save that. Now we need to edit /etc/grub.d/00_header

$ sudo vim /etc/grub.d/00_header

Go down where it says:
set gfxmode=1280×800 and on the very next line put set gfxpayload=keep.
My file looked a bit different, but just ignore it and just add the one line.

set gfxmode=1280×800
set gfxpayload=keep
insmod gfxterm
insmod vbe

Mine:
if loadfont `make_system_path_relative_to_its_root “${GRUB_FONT_PATH}”` ; then
set gfxmode=${GRUB_GFXMODE}
set gfxpayload=keep
load_video
insmod gfxterm
fi

Save your work. Now the files are edited we need to tell the system of the changes.

$ sudo update-grub

IGenerating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.32-5-686
Found initrd image: /boot/initrd.img-2.6.32-5-686
done
$ _

If there are no error messages, you should be ready to reboot.
$ sudo reboot

—————————————————————————————

Like almost getting a new monitor for free. Even the spreadsheet had 10
additional lines to work with. If we were able to go to 1024×768, you
would really see the difference!!!  Most monitors but not all will easily do that
and better if your video card supports it.  Good luck!

======================================

This is probably a better look at the change in resolution. I did a text scrape of a spreadsheet I wrote.

Before:

After:

 

A bit bigger(or smaller as the case may be)…..

=================================================

If you want to use gmail via mutt on the command line this is a good ,muttrc file:

# A basic .muttrc for use with Gmail

# Change the following six lines to match your Gmail account details
set imap_user = “YOUR.EMAIL@gmail.com”
set imap_pass = “PASSWORD”
set smtp_url = “smtp://YOUR.EMAIL@smtp.gmail.com:587/”
set smtp_pass = “PASSWORD”
set from = “YOUR.EMAIL@gmail.com”
set realname = “YOUR NAME”

# Change the following line to a different editor you prefer.
set editor = “nano”

# Basic config, you can leave this as is
set folder = “imaps://imap.gmail.com:993”
set spoolfile = “+INBOX”
set imap_check_subscribed
set hostname = gmail.com
set mail_check = 120
set timeout = 300
set imap_keepalive = 300
set postponed = “+[GMail]/Drafts”
set record = “+[GMail]/Sent Mail”
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include
set sort = ‘threads’
set sort_aux = ‘reverse-last-date-received’
set auto_tag = yes
ignore “Authentication-Results:”
ignore “DomainKey-Signature:”
ignore “DKIM-Signature:”
hdr_order Date From To Cc
alternative_order text/plain text/html *
auto_view text/html
bind editor complete-query
bind editor ^T complete
bind editor noop

# Gmail-style keyboard shortcuts
macro index,pager y “unset trash\n ” “Gmail archive message”
macro index,pager d “set trash=\”imaps://imap.googlemail.com/[GMail]/Bin\”\n ” “Gmail delete message”
macro index,pager gi “=INBOX” “Go to inbox”
macro index,pager ga “=[Gmail]/All Mail” “Go to all mail”
macro index,pager gs “=[Gmail]/Starred” “Go to starred messages”
macro index,pager gd “=[Gmail]/Drafts” “Go to drafts”

=================================================
Ice cream:

Good day.

Advertisements