Tuesday, March 23, 2010
HTML Editors for Beginners
Vim is great as I can run it at the command line, in a GUI (gvim) and on any OS you can think of. Within vim you can activate html syntax highlighting by simply typing:
:set syntax=html
That will add html syntax highlighting for only that session of vim. You will need to add "syntax on" in your .vimrc file for highlighting to be permanent.
Now as much as I love vim, I'm not going to have my students use it. This is an HTML class for the absolute beginner and introducing vim to the class is a hurdle I don't want to jump over. So, I'm leaning towards having my students use bluefish. Bluefish has several cool features including running on all three major platforms.
Any other suggestions for an HTML editor for beginners? What features do you like? What are your thoughts regarding bluefish?
Tuesday, March 16, 2010
id3 - Managing mp3 Tags
One of my favorite podcast is for the TV show Lost, hosted by a father and son who discuss the show. The file name for the podcast is d66027dd-8873-2829-c731-97fcc5a62bb9.mp3. I know, but the name of the file really doesn't matter since the media player only really reads the tags associated with the file. To list the tags of the file:
id3 -l d66027dd-8873-2829-c731-97fcc5a62bb9.mp3
Which will give you the following output:
d66027dd-8873-2829-c731-97fcc5a62bb9.mp3:
Title : Lost Podcast (MP3): EP. 5.11 " Artist: Jeremiah Glatfelter
Album : Year: 2010, Genre: Unknown (255)
Comment:
My fuze displays this podcast as Jeremiah Glatfelter. Who the hell is Jeremiah? Maybe it's some inside joke or something, but the hosts of the show are Jay and Jack and that's what I would like displayed as the artist. So, to change the artist portion of the tag, I use the following:
id3 -a "Jay and Jack" d66027dd-8873-2829-c731-97fcc5a62bb9.mp3
Which outputs the following to show that the change has been made.
Title : Lost Podcast (MP3): EP. 5.11 " Artist: Jay and Jack
Album : Year: 2010, Genre: Unknown (255)
Comment:
Pretty straight forward. Here are the options to change the other aspects of the tags using the same syntax.
usage: id3 -[tTaAycg] `text' file1 [file2...]
id3 -d file1 [file2...]
id3 -l file1 [file2...]
id3 -L
id3 -v
-t Modifies a Title tag
-T Modifies a Track tag
-a Modifies an Artist tag
-A Modifies an Album tag
-y Modifies a Year tag
-c Modifies a Comment tag
-g Modifies a Genre tag
-l Lists an ID3 tag
-L Lists all genres
-R Uses an rfc822-style format for output
-d Deletes an ID3 tag
-h Displays this help info
-v Prints version info
Now you can tag to your hearts content.
enjoy.
Wednesday, March 10, 2010
My .bashrc File Part 5 - Pimping the Prompt
This is the final installment of my .bashrc series. PS1 is a variable that allows you to change your prompt environment. Here is my setting as found in my .bashrc file which I use to get the prompt above.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
The numbers in the brackets represents colors. The \u option is username and \h is hostname which defines the first part of my command prompt. The second part of my prompt is indentified with /w which displays my current path which is shown above in blue.
Your possibilities are limitless when it comes to customizing your prompt and I don't have time here to list and explain all the options available, especially when the detail is readily available with a simple google search. Nevertheless, here are some links you might find useful to help pimp your prompt.
10 examples with syntax explanation.
This IBM article is a great resource as well.
I hope this series has been useful. Please share your pimped command prompt in the comments.
Monday, March 8, 2010
My .bashrc File Part 4 - Alias'
If you are unfamiliar with the alias command then you are missing out on an effective and efficient tool. Alias is a way to create a shortcut command in bash. You can take very long commands with several options or triggers and create your own shorthand equivalent of that long command. For Example, for me to get the weather for my local area using the weather-util application I would normally need to type:
weather -f --id=KSLC -c "Salt Lake City" -s UT
Well, that's way to long. I normally only want to know the weather in my local area, so I've created an alias for this long command.
alias weather='/usr/bin/weather -f --id=KSLC -c "Salt Lake City" -s UT'
This command essentially substitutes the longer command to display the weather for Salt Lake City with just the command "weather". I have several alias' in my .bashrc file to make my life easier.
# some ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
#Information
alias weather='/usr/bin/weather -f --id=KSLC -c "Salt Lake City" -s UT'
alias gcalcli='gcalcli --cals all'
#For getting around
alias videos='cd /home/jared/Videos/ && ls'
alias pics='cd /home/jared/Pictures/ && ls'
alias music='cd /home/jared/Music/ && ls'
alias podcasts='cd /home/jared/Podcasts/ && ls'
alias dropbox='cd ~/Dropbox/ && ls'
alias documents='cd ~/Documents/ && ls'
alias notes='cd ~/Notes/ && ls'
alias manti='cd ~/Manti/jared/ && ls'
The first group of alias' are very common shortcuts for the "ls" command. The second group of alias' give me shortcuts for the weather and gcalcli applications which displays the weather and my google calendar information. Finally, the las group gives me shortcuts to commonly used directories. This saves me tons of time as I don't have to type out the complete path of a commonly used directory.
Please share some of your cool alias' that you have implemented.
Friday, March 5, 2010
You Know You're a Geek If.....
I haven't been able to sleep at night for the last 3 days in anticipation of the RAM upgrade I ordered from newegg for my HP 1000 mini. The mini originally came with 1 GB RAM and I'm maxing it's compacity with 2 GB. The climatic release of tension came when my RAM (finally!) arrived and I could pop in the SODIMM into it's slot and gasp in awe at the increased performance from this baby.
Whew! What a rush.
Thursday, March 4, 2010
My .bashrc File Part 3 - Making Life Easier
#------Extraction of compressed files--------------# from ARCH Wikiextract () {if [ -f $1 ] ; thencase $1 in*.tar.bz2) tar xvjf $1 ;;*.tar.gz) tar xvzf $1 ;;*.bz2) bunzip2 $1 ;;*.rar) rar x $1 ;;*.gz) gunzip $1 ;;*.tar) tar xvf $1 ;;*.tbz2) tar xvjf $1 ;;*.tgz) tar xvzf $1 ;;*.zip) unzip $1 ;;*.Z) uncompress $1 ;;*.7z) 7z x $1 ;;*) echo "don't know how to extract '$1'..." ;;esacelseecho "'$1' is not a valid file!"fi}
Wednesday, March 3, 2010
My .bashrc File Part 2 - Useful System Information
This first script displays my internal IP address and my WAN IP address by simply extracting that information from ifconfig whenever I type "myip" in the terminal. Here is the script.
function myip() # get IP adresses
{
MY_IP=$(/sbin/ifconfig eth0 awk "/inet/ { print $2 } " sed -e s/addr://) \ MY_ISP=$(/sbin/ifconfig
eth0 awk "/P-t-P/ { print $3 } " sed -e s/P-t-P://)
}
This displays:
External IP:
xxx.xxx.xxx.xxx
Internal IP:
192.168.0.97
This second function displays my machine statistics, file system space available, memory stats and IP information, when I type "ii" in the terminal. Here is the function:
function ii() # get current host related info
{
echo -e "\nHello ${RED}$USER"
echo -e "\nSystem information:$NC " ; uname -a
echo -e "\n${RED}Machine stats :$NC " ; uptime
echo -e "\n${RED}Storage stats :$NC " ; df -h grep -v varrun grep -v varlock grep -v udev grep -v\ devshm
echo -e "\n${RED}Memory stats :$NC " ; free -m
echo -e "\n${RED}Local IP Address :$NC" ; ifconfig grep
'inet addr:' grep -v '127.0.0.1' cut -d: -f2 awk '{ print $1}'
echo -e "\n${RED}ISP Address :$NC" ; wget www.whatismyip.com/automation/n09230945.asp -O - -q
echo ""
}
You'll notice that in this script, my outside WAN IP is pulled from a website instead of from the ifconfig command. Here is the output:
Hello jared
System information:
Linux manti 2.6.24-24-server #1 SMP Fri Sep 18 17:24:10 UTC
2009 i686 GNU/Linux
Machine stats :
10:02:17 up 81 days, 15:14, 10 users, load average: 0.15, 0.38, 0.37
Storage stats :
Filesystem
Size Used Avail Use% Mounted on
/dev/sda1 17G 3.0G 13G 19% /
/dev/sda2 276G 246G 16G 94% /home
/dev/sdb1 187G 146G 32G 82% /media/backup
Memory stats :
total used free shared buffers cached
Mem: 502 492 10 0 37 65
-/+ buffers/cache: 389 113
Swap: 1874 30 1844
Local IP Address :
192.168.0.97
ISP Address :
xxx.xxx.xxx.xxx
I apologize that not everything is lined up correctly, it's due to the layout in blogger. The output lines up fairly cleanly in the terminal.
Enjoy!
Monday, March 1, 2010
My .bashrc File Part 1 - Useful Information
I want to focus the first apart of this series on having bash display useful information in an easily accessible and concise way. For example, the first thing I do each morning is run my "update" script which displays the time, my schedule for the day and the weather, which looks something like this:
Hello jared, How are you today?
Current Date and Time:Fri Feb 26 09:00:40 MST 2010
Your Schedule:
Mon Feb 22 12:00am Zone 4
Fri Feb 26 12:00am Safety Kids Fair
6:30am Scriptures
11:00am Preschool time
Sat Feb 27 9:30am Food Co-op Pick up
Current Weather Conditons:Current conditions at UT (KSLC)
Last updated Feb 26, 2010 - 10:53 AM EST / 2010.02.26 1553 UTC
Wind: from the SSE (160 degrees) at 13 MPH (11 KT)
Sky conditions: mostly cloudy
Temperature: 35.1 F (1.7 C)
Relative Humidity: 69%
City Forecast for Salt Lake City, UT
Here is the script I use in my .bashrc file.
function update() # Current date, time, weather and calendar
(
echo -e "\nHello $USER, How are you today?"
echo -e "\nCurrent Date and Time: $NC " ; date
echo -e "\nYour Schedule: $NC " ; gcalcli agenda head
echo -e "\nCurrent Weather Conditons: $NC " ; weather head -n 7
echo ""
)
Let me run through this function. As you can see it's all just echo commands spewing out the information I desire. I begin by having bash say "Hello" to me. Just because it's a shell doesn't mean it can't be polite. Next it displays the current date and time which is followed by my schedule for the day. My schedule is produced by a cool little app called gcalcli which was a Google summer of code project that displays your google calendar on the command line. I blogged about this app previously here. I then finish things up with the weather using the weather-utils application. I have the weather command set up as an alias (which I'll cover in another segment) to display my local weather.
As mentioned previously, this is the first command I type into the terminal when I first wake up, which gives me a quick and concise outlook for the day.
Well, I hope this was interesting to some of you. My next installment will cover displaying useful system information. So until then... enjoy!