Sunday, May 24, 2009

Quick Update, Little to Tell

Well, it's my bi-weekly update again, and I haven't really done much that's worth mentioning (besides finishing my exam and then relaxing), so I will quickly outline what I'm looking forward to, and what I plan on doing (blog-wise) in the near future.

Basically, I graduate (officially) from high school in a weeks time. After I graduate I will be purchasing a Samsung NC10 netbook to replace my battered and temperamental speaker-less laptop for a little under 400€ off amazon.de (haven't seen a better deal anywhere else yet). Once I get it and play around with it for a bit, I'll install Ubuntu or ArchLinux on it as well (if Ubuntu, then the Netbook Remix edition). If battery life (which is supposedly anywhere between 6 and 9 hours depending on usage and review) in Linux is similar to the windows one (Samsung seems to be offering a custom power savings utility that is very modular, so Linux may be a little bit subpar compared to the XP battery life), I will most likely be shrinking XP to the most minimal size, mainly for itunes (since I have an iPod touch, and while I am sure I could get it working in Linux, I see no point in doing so since I don't update my music or my ipod every day). Basically, I'm taking the lazy way out, which is to say...I'll just boot XP and use iTunes if I need to update my ipod. I'll also be writing up a review of the netbook as it runs under XP and Linux (whichever distribution I choose) and posting them on here. It may or may not be up before I go on summer break. If it's after, then it won't be up before September, since I'll be living with dial-up for quite a few weeks.

Also, I may be purchasing a couple of things with the netbook if I order it, depending on if I can afford it or not. The two other things would be a 2GB stick of RAM (only one slot in the NC10), and a slim drive, since I will probably buy CDs over the summer, and it'd be silly if I can't put it on my iPod. Altogether (this is an offer on amazon.de) it'd go for about 430€, which is not bad, considering.

I'll post back once I order and receive the stuff, which may be in two or three weeks. If anyone wants to post here with an opinion as to whether or not the 2GB of RAM will make much of a difference on this netbook for mainly command-line tools in Linux and itunes (being the most resource heavy program I'd run) in XP, it would be appreciated.

Besides the netbook I'll also be working on whatever coding ideas I can come up with over the summer, and so I'll be posting those on here as I go. Not only that, but I have to write my FCM articles in advance, since I won't be able to send them in for two or three issues, meaning I'll be busy. Also, I'm going to be going to see Angels and Demons today, and I may post a quick update with my opinion on the movie (if it's worth mentioning) later today.

Sunday, May 10, 2009

Yet another Update

Well, it's my bi-weekly update! Not much to write about, since I'm in the process of doing exams, but they will be over in 2 weeks. I was able to get my article done for FCM, and I decided to cover Bash Functions and History, because I felt it's something useful and has quite a few time-saving uses, so if you're interested, don't miss the next issue of FCM #25 (should come out on May 29th). I haven't done much coding in the past 2 weeks, and the only thing exciting thing that happened technology-wise is that my laptop's speakers have also died. I don't see myself buying another HP anytime soon. I may post another entry later this week if I think of a good topic to write about.

Sunday, April 26, 2009

School is nearly over!

Well, I'm now on study leave for a week before my exams start. By the end of May I'll have graduated high school. So if the next update is a little delayed (day or two maybe) you guys know why.

These days I've been bothered by my temperamental laptop again. The charger is starting to die (it's the THIRD charger for this HP DV6545eg laptop in the last year), and I'm tired of replacing it, so I've decided to replace the laptop after I graduate. I've decided this mainly because the battery life of the HP laptop is terrible (about and hour and a half, maybe a bit longer), and the hard drive seems to be starting to die (I give it another month or two before it bites the dust). Seeing as the total cost of replacements would be around about 200€ I decided I may as well buy a new laptop for twice as much and get better battery life and mobility (my laptop is 15.4"). I've decided I want to get the Samsung NC10 netbook, which has a rumoured battery life of up to 7 hours (even if it only gets to 4 or 5 hours I'd be ecstatic), and is 10.2", which means it'll be nice and portable for me. Not sure if I'll go with Ubuntu 9.04 netbook edition, ArchLinux, or a normal install of Ubuntu. If anyone has any comments on compatibility (according to Ubuntu wiki only suspend/resume and sound recording doesn't work), please post a comment.

On a bit of an ironic note...the Samsung NC10 has an integrated graphics card with more shared memory than my laptop. Current laptop: Nvidia 7150m chipset with 128MB shared memory, NC10: Intel GMA 950 with max. 384 MB SharedMemory. Sure, the NC10 only has 1GB of RAM, but I can easily increase that, though my current PC and laptop set ups only require about 300MB of RAM for everything I do. Actually...looking at these specifications...the NC10 has bluetooth and all that, seems it is a better deal than my laptop (for half the price too). How times change.

I'm also hoping to get another Acer x223w monitor (22") for my PC, which will require yet another re-organizing of my desk.

The latest program I'm working on is a command-line tool for googling using python. So far the only thing it does is take supplied search terms and open the google results in firefox, since the SOAP API from google was dropped, and I've not got the time yet to try to implement the AJAX API in some way or form. I'm doing this mainly for practice so that I can get some hands-on experience with formatting large chunks of input in python, and so I can work with urls a bit.

Also, I noticed something interesting this morning. I have a follower! First one too, it was a bit of a surprise. I thought to myself "has that function always been there?". It's nice to know someone reads these articles (besides people I know personally).

One final note: I'm open to any suggestions if anyone would like a how-to written on a specific linux problem, or anything like that. Just drop a comment with your request and I will do my best to write a how-to on it.

Sunday, April 12, 2009

Some Python scripts

Well, as I mentioned in the last post I made, I plan on updating this blog every other Sunday (besides when I'm on vacation). This is the first of that series of updates (on time too!). I've been using Python a lot for small scripts lately, because a) it's good practice, and b) it's efficient. Below are a few scripts I wrote and an explanation of what they do:

Sorry, but the whitespaces seem to be ignored, so I'll post a link to a pastebin for each one as well. (For those who don't know, whitespace is significant in Python since each indentation level denotes a "block" of code, similar to the function of braces "{}" in Java or most other programming languages).

FileCondenser
http://lswest.pastebin.com/f21a592a4
#!/usr/bin/env python
#Script to condense the multiple files of a project into one for easy printing/copying
#Author: lswest
import os
import optparse

def main():
usage="usage: %prog [options] args"
p = optparse.OptionParser()
p.add_option('--origin', '-o', help="The location of the files to be read in.", default="")
p.add_option('--output', '-t', help="The location of the file to which the condensed output will be written.", default="");
p.add_option('--extension', '-e', help="The extension of the files to condense.", default="");
options, arguments = p.parse_args()
if options.origin == "" or options.output == "" or options.extension == "":
p.print_help()
else:
print "Input file: %(o)s*%(e)s \nOutput file: %(t)s" % {'o' : options.origin, 't' : options.output, 'e' : options.extension}
ff=open(os.path.join(options.output), "wt")
for root, dirs, files in os.walk(os.path.join(options.origin), "true", "none", "true"):
for infile in [f for f in files if f.endswith(options.extension)]:
fh=open(os.path.abspath(os.path.join(root,infile)))
for line in fh:
ff.write(line,)
fh.close()
ff.close()

if __name__ == '__main__':
main()
This is a small script that can be run using the arguments ("FileCondenser --help" to see the help information), and is used to take all the files within a directory tree ending in the specified extension, and then copy each line of those files into the output file. I used it for my Computer Science coursework, since I had to print a hard-copy of my code (weird, I know).

LineCounter
http://lswest.pastebin.com/f6c52aaa0
#!/usr/bin/env python
#Program to tally the lines in a file
#Author: lswest
import os
import os
import optparse

def main():
usage="usage: %prog [options] args"
p = optparse.OptionParser()
p.add_option('--file', '-f', help="The path to the file to count.", default="")
options, arguments = p.parse_args()
if options.file == "":
p.print_help()
else:
print "Input file: %s" % options.file
count=0
ff=open(os.path.join(options.file))
for x in ff:
count+=1
values={'name': os.path.join(options.file), 'count' : count}
print "The file %(name)s contains %(count)s lines." % values

if __name__ == '__main__':
main()
This script basically just tallies the number of lines within the specified files, and was done for practice (no real practical reason), but I still thought I'd include it.

updateCheck
http://lswest.pastebin.com/f4d33eb3d
#!/usr/bin/env python
#A program to check if there are any updates available for Arch
#Author: lswest
from subprocess import Popen,PIPE
import os

def main():
p=Popen("pacman -Qu|grep Targets|cut --delimiter=\" \" -f 2|sed -e 's/(//' -e 's/)://'",shell=True,stdout=PIPE)
x=p.stdout.read()
if x != "":
tally=int(x)
if tally == "1":
print "1 package to update"
else:
print "%s packages to update" % str(tally)
else:
print "No packages to update"

if __name__ == '__main__':
main()
I use this script in my Conky on both my PC and laptop, in combination with a cronjob of "pacman -Sy" to update the database, to display the number of available updates for my system.

To Buy.py
http://lswest.pastebin.com/f4b4c9849
#!/usr/bin/env python
## A script to print out my "to buy" list
#Author: lswest
import os

home=os.path.expanduser("~")

for root, dirs, files in os.walk(os.path.join(home,"To Buy")):
for infile in [f for f in files]:
if(infile.endswith("~")!=True):
fh=open(os.path.abspath(os.path.join(root,infile)))
for line in fh:
print "- "+line,
fh.close()
This is a small script that takes all the text files in my To Buy folder, and prints it out, which I use in Conky. I create the text files with just echo "something to buy" > To\ Buy/something.

TO DO.py
http://lswest.pastebin.com/f18550d93
#!/usr/bin/env python
#A script to print out my To Do list
#Author: lswest
import os

home=os.path.expanduser("~")

for root, dirs, files in os.walk(os.path.join(home,"Reminders")):
for infile in [f for f in files]:
if(infile.endswith("~")!=True):
fh=open(os.path.abspath(os.path.join(root,infile)))
for line in fh:
print "- "+line,
fh.close()
Basically the same as above, besides the fact that it's a to-do list.

Well, that's all the scripts I've written so far that are half-way useful. I'm thinking about making a github repository for scripts of mine, so if you think it's a good idea, drop a comment and I'll post an update on the blog with the link if I do it.

*edit* I went ahead and made the github repository: http://github.com/lswest/scripts/tree/master

Saturday, April 4, 2009

An update (very delayed, sorry!)

Sorry about the slow updates on my blog here, I've been kinda swamped with school work, writing articles for Full Circle, and such that I haven't been able to think of things to write when I did have time (or I just simply didn't have time). I am now, however, setting aside every other Sunday of the month (second and last sunday of each month) to updating this blog (short of when I have exams, or when I'm off on Summer vacation, but I'll leave a notice as to how long I'll be gone). Over Summer vacation I'll probably be writing a lot, and so I'll just be unable to post them until I return.

A few things I'm working on these days:
- A website about Linux along with a wordpress blog, and once it's finished I may find hosting for it and use that instead, but I will see how it turns out first.
- Learning Python thoroughly
- Studying for exams
- Planning my gap year out
- Writing for Full Circle

Changes to my computers:
- Both PC and Laptop are now running ArchLinux 64bit with Awesome 3.1
- PC will soon be running with 4GB of RAM

Things I plan on doing:
- LPIC-1 during my gap year
- Getting a second 22" monitor for my PC
- Getting a graphics tablet for my PC

Favourite programs these days:
- MOC (command-line music player)
- My ipod Touch (for checking emails and such without having to pull out my old clunky laptop)
- Conky (I added a to-do list and a shopping list to it using python and an assortment of text files)

That's all I can think of posting for this time. Anyone is free to post suggestions for articles, how-tos, and so forth and I will cover as many as I can. Also, I would like to get a rough estimate of how many people read this blog, so if you feel like just leaving a comment, please do so!
Lswest

Wednesday, February 4, 2009

Finally!

I have finally decided my laptop is configured to my liking.

Specs:
HP DV6545EG
2GB of DDR2 RAM
1.8GHz AMD Turion 64x2
160GB hdd (10GB - ArchLinux (ext4), 10GB - ext4 /home for Arch, 10GB - Ubuntu, 17GB - /home for Ubuntu, the rest to Vista)
Nvidia 7150m chipset

Basically, I installed Arch because I was tired of semi-laggy performance for graphics and lots of extra services running in Ubuntu. I decided to go with openbox, and from there I found a nice system tray replacement, panel, dock and found a nice dzen script for battery display (I modified it a tiny bit to suit my needs).

I plan on getting rid of Ubuntu entirely, and removing the old /home, but I'm waiting until I'm sure I have all the config files, fonts, cups settings, etc. that I need copied over before doing so. After all...disk usage isn't bad for a pretty much complete system. Also, if I decide I don't need it anymore, I will also dispose of Vista, but I see no reason to yet, as the space isn't required. Sure, I never use it, but why throw away what you paid money for if it works, right?
[lswest@lswest-laptop:~]% df -h [19:48:10 on 09-02-04]
Filesystem Size Used Avail Use% Mounted on
/dev/sda8 9.7G 3.6G 5.7G 39% /
/dev/sda9 9.2G 1.3G 7.4G 15% /home

The apps I decided on using are trayer for a system tray (top right), cairo-dock for a dock, tint2-svn for the panel, and a dzen2 script off the archlinux for the battery display. All the running system is configured through config files (save for cairo-dock), and battery life (managed by laptop-mode-tools with custom config files) gives me about 2 hours and 15 minutes of battery life, which is roughly 10 minutes more than Ubuntu gave me with slightly tweaked system settings. The wallpaper is a custom one that I call "Electric". I may or may not release this one, I haven't released any for a while. Also, I use xcompmgr for the transparencies.

Ultimately, I'm satisfied with this setup, it boots quickly, is responsive, and looks nice as well. Not only that, it also still hooks up to the beamers (projectors) at school, and (almost) all my keyboard shortcuts are fully functional. Only thing I have to figure out are my media keys, they seem to not be working properly in openbox yet.

Tuesday, February 3, 2009

That itch to disassemble is back!

Well, on Sunday I was sitting at home and this urge came over me to take something apart (it's been a while since that happened, used to be too busy to do so), and all I really had on-hand that I hadn't yet taken apart and re-assembled was my old, broken iPod Mini (broken in the sense that the battery holds roughly 5 seconds of charge). First I had to heat the glue at the top and bottom with a hair dryer, then I pried them off (using a thin screwdriver and my fingernail to bend the side away), unhook the bottom metal plate (held in place using tension in the tags), disconnected the click-wheel, unscrewed it from the top metal plate, and pushed it out. I even took pictures!
Quick note: the parts were lying on a Lufthansa clipboard, thus the funny colors.

Another slightly off-topic note. The article for Full Circle Magazine I wrote (Command & Conquer, filling in for Robert Clipsham) was released in issue 21 yesterday: http://fullcirclemagazine.org/2009/02/02/full-circle-21-out-now-finally/