Bash Shell Regex Most Common Words from Web Page, Sorted to File

Used in combination, the command line Bash/Shell utilities wget, sed, awk, and sort are powerful regular expression tools for processing word frequency analysis. These commands can be deployed on static files, web pages, retail reviews and YouTube comments. Through sorting, one can quickly evaluate content emphasis and user sentiment on a wide range of subjects. For the impatient, check my commands, posted on Gist (GitHub):

In a practical scenario, instead of sifting through countless user reviews, a retail analyst can discern a product's weak and strong points, gleaned from hundreds or thousands of reviews, in about five minutes. As a case in point, I evaluated user reviews on this Wool Duffel Coat, from L.L. Bean. Now, often we can retrieve comments exclusively, as in the case of YouTube videos (using an API, see my Gist, above), but in the case of comments integrated within a page's main content (in this case, product description), we may resort to creating a local text file ("bean") with the comments, excluding description. From there, run the following Shell script, which outputs a text file ("bean2"), with top 300 words, sorted by occurrence:
cat bean \
| sed -e 's/<[^>]*>//g' bean | cat bean | tr -cs A-Za-z\'  '\n' \
| tr A-Z  a-z | sort | uniq -c | sort -k1,1nr -k2 | sed ${1:-300}q > bean2
The magic in the Shell is the ability to pipe commands. Here, sed stream editor removes  HTML's < > tags, and tr translation filter converts all letters—with and without spaces—to lowercase. Next, sort and uniq are deployed in combination; the number of words to list, and output file are defined.

And here is a section of the results, from reviewer comments on that wool duffel coat (stop words omitted). I've highlighted key, useful words:

     17 zipper  
     16 at
     15 for
     15 review
     14 as
     14 comment #used in description
     14 content #used in description
     14 found #used in description
     14 inappropriate #used in description
     14 report #used in description
     14 yesno #used in description
     13 post
     13 would
     12 purchased
     11 bean
     11 that
     10 month
     10 shops
     10 within
      9 describe
      9 male
      9 more
      9 myself
      9 with
      8 my
      8 not
      7 be
      7 on
      7 one
      7 very
      7 warm
      6 bought
      6 but
      6 had
      6 perfect
      6 too
      5 am
      5 bottom
      5 december
      5 duffel
      5 frequently
      5 heavy
      5 large
      5 like
      5 occasionally

The words in red give valuable feedback about this product; the zipper is reported to be problematic. Cntl F (find) on the reviews page confirms this. The coat is reported to be warm. The bottom of the coat is reported to have issues concerning the zipper and the cut of the fabric. The word heavy is used both in a positive and negative respects, with negative sentiment predominating by one two usage counts.

Along with product reviews analysis, command line regex techniques can be used in any textual situation. Thanks for reading.

Shell Scripting on Android Samsung Galaxy: Push/Install Busybox via ADB to Terminal Emulator (ATE)

If you like Linux, you like the shell (probably Bash) and developing scripting skills. If you have an Android, Jack Palevich's Android Terminal Emulator app provides some basic command line utilities, like ls, cat, mv, and the Bourne shell: sh. However, there is no editor, nor regex utilities—grep, awk, sed—no uname or wget. You want this stuff, right? After weighing the options: downloading an ad-centric Play Store app, or going with Kevin Boone's KBox2 (and recommended third-party auto-installer), I decided to go "app-free" and install the Busybox binary into my Samsung Proclaim, via USB, using the Android Debug Bridge (ADB) included in Google's Software Development Kit (SDK). And I'm doing all without rooting phone. Non-root.

And let me tell you people, having a full-feature scripting terminal on your phone rocks!

First, go the Play Store and download Android Terminal Emulator. Check out its features. The app will reside in /system/data/data/jackpal.androidterm. Get used to this location; you're gonna be seeing a lot of it.

Next, download Android SDK Tools and install per your Android version (mine is 2.3.6, so I chose the closest option, 2.3.3. Download the correct Busybox binary for your phone (mine is busybox-arm7l). Extract and copy that executable to platform-tools folder in SDK.

Log in as root and create /etc/udev/rules.d/51-android.rules (click link for instructions, see vendor #, set chmod), which will enable device detection (see vendor #). Log out of root.

Set path:
export PATH=$PATH:~/android-sdk-linux/platform-tools

Set your phone's USB settings to "Debugging", under Applications/Development. Reboot phone. Connect phone to computer via USB. cd / to the platform-tools directory (yours may vary, my SDK is in ~/, as above), and run: 

adb devices

You should see a number corresponding to your phone. If not, make sure USB debugging is enabled on phone, your path is correct, and you have cd / to the platform-tools directory. If that doesn't work, unplug or reboot your phone; my phone only gets detected after I exit out of the USB debugging screen on phone, into my Home screen. Keep playing with it—you'll get it. 

After your phone is detected, run: adb shell. You'll note the directory change to $. Then run: cd /system. You are now in your phone! Try: ls. Make a directory folder to push (adb's "copy") the Busybox binary (my directory named SH):

mkdir data/data/jackpal.androidterm/SH

Now exit, and cd / back to the platform-tools directory, to "push" Busybox binary to phone: 

adb push busybox-armv7l data/data/jackpal.androidterm/SH

The command above worked for me, but I've read of others using push busybox data/local first. Anyhow, adb shell and cd /system (again), and go to directory you created in jackpal to see if the binary was pushed. chmod 755! You'll be doing this chmod for ALL files you create in jackpal subdirectories, which is the ONLY place you will be able to write/save least as non-root. 

After confirming the Busybox file push, while still in /system, install to same folder: ./busybox-armv7l --install . (keeping space and period), or make another directory (that's what I did) and install to that: ./busybox-armv7l --install -s /busy1

Now, confirm that Busybox installed: start Terminal Emulator (ATE), run: export PATH=/data/data/jackpal.androidterm/SH/busy1:$PATH (wherever your install went to), cd / to your file folder in jackpal (again, mine is SH), create vi, put #!/data/data/jackpal.androidterm/SH/busy1/sh as shebang (note this is not #!/bin/bash), write a script, :wq, chmod 755, ./, and enjoy the results (hopefully). In screen capture below, Busybox syntax highlighting shows /busy1 directory in blue—nice!

Check "Special keys" in ATE menu to escape in vi, etc. Mine is volume up/e. Learning the Special keys is essential to navigating your ATE/Busybox rig.  

If all has gone according to plan, set your Busybox and sh paths in ATE's Preferences menu. In Command line option, enter: /system/data/data/jackpal.androidterm/SH/busy1/sh (to YOUR path to sh; note "system" preceding "data" this time). Then, in Initial command option, enter: 

export PATH=/data/data/jackpal.androidterm/SH/busy1:$PATH

Exit and restart ATE, and note PATH automatically populated in terminal! (See image.) From here cd / to your working folder, and have fun developing shell scripting! 

Troubleshooting: If Busybox binary installed, but ATE won't start, and you get a quick flashing message "In mgmain JNI OnLoad", set your path in ATE: 

 export PATH=/data/data/jackpal.androidterm/SH/busy1:$PATH 

Also, a heads-up that { } braces are not available in Busybox, so Bash brace expansion is not possible; use seq or increment operator i++.  

While I like the low profile of a smaller phone, working through this Busybox/ATE install, and seeing the potential for highly mobile shell scripting, I'm thinking: NEW PHONE! Should I go for a 5" screen? I'm open to advice; and let me know if the tutorial helped you: drop a comment below. Thanks for reading.  

Understanding Windows 8: Metro Tile Start Screen; 8.1 Upgrade

You Windows users are going to have to acquiesce to the geniuses at Microsoft at some point. Here's how to adopt Windows 8 and 8.1 upgrade with an open, Zen-like mind, while appreciating the fact that Windows 8 has some problems that undermine user productivity.

Subscribe to my channel:

FFmpeg to Convert .3ga Samsung Audio to .mp3 and Record Desktop/Screencast!

Debian's lack of pre-configured multi-media functionality inspires one to rely on the command line terminal, which turns out to be a good thing as far as learning Linux administration.

Even though I'm currently running Debian testing "Jessie," Ubuntu has many advantages over Debian; namely, third-party codecs. Debian is a PITA in this regard. For example, Debian's Audacity does not include FFmpeg, and does not provide a built-in library for FFmpeg, so the user has to compile FFmpeg, or use a library. So, I installed deb-multimedia in my sources.list and updated; however, even that did not provide FFmpeg to Audacity (at least not that I could find). Finally, exasperated, I downloaded the executable FFmpeg static build, copied it to my Music folder, and began converting my .3ga Samsung audio files to .mp3 in the terminal. Good times! Files were rendered flawlessly, and much quicker than opening and Exporting in Audacity.

Here is the FFmpeg usage Wiki. And here is a constant rate .mp3 conversion command:  
ffmpeg -i song.3ga -codec:a libmp3lame -b:a 128k song.mp3
-b:a refers to constant rate .mp3; -q:a refers to VBR (see Wiki for sample rates). aac is also available.

FFmpeg can also be used for video encoding; this is a good screencast command (without audio):
ffmpeg -f x11grab -s 1024x768 -r 25 -i :0.0 output.mp4
FFmpeg is an awesome command line multi-media conversion tool!

Since I use fmpeg en route to making videos in Kdenlive, I should mention that setting the Threshold on the Gate audio effect is great for eliminating background noise in your audio narrations/voice-overs!

Subscribe to my YouTube channel. 

Android Slowing Down, Freezing? Keep it Running Fast! Best Phone Data Plan Unlimited Straight Talk

*Check out my Mood first effort with Python programming.

I'm reviewing Android cell phone plans and apps from Play Store on my YouTube channel, p1nesap. This video teaches how to keep your 'Droid running FAST:

While some might shun everything Walmart, their Straight Talk Android and iPhone no-contract phone and data plan is undeniably the best value going. I know: I've been a ST user for five years. Your phone gets served by Verizon and AT&T towers at a fraction of the price. Check it out people: 

Subscribe to my channel:

VirtualBox | Ethernet Configuration | USB

Although many seem to upgrade Linux versions easily via command line terminal, many others warn that the seeming ease of such a process belies the inevitable glitches one will encounter after upgrading. Reluctant to backup numerous files and configurations, I tried upgrading through two Ubuntu versions, only to find so many glitches that I finally decided to back up some files and fonts with emailed compressed file folders, and do a fresh install. I had been using Ubuntu for a year, so I decided to go back to Debian—to the progressive testing (Jessie) version.

First, to prevent a broken install, use the command line wget -c <url> utility to download the .iso file. The -c option ("continue") prevents the download, and consequently the installation, from breaking. Burn DVD image disk using Xfburn or similar, and reboot to CD drive. Follow prompt.

Gnome 3 desktop is way too bloated for my 2007 HP desktop spinning a Toshiba netbook hard drive, so LXDE is the only way: apt-get install task-lxde-desktop. I'm having an issue of only being able to reboot via command line in LXDE, but I'll deal with it for now.

One thing nice about Ubuntu is that third-party audio-video codecs like Adobe Flash and LAME are included. I miss this in Debian, although their open-source adherence is noble. Anyhow, the Shockwave Flash included with Chromium and Iceweasel simply does not work reliably with YouTube. So, you need Adobe Flash: add contrib non-free after all "main" lines in /etc/apt/sources.list, then apt-get update, then apt-get install flashplugin-nonfree and update-flashplugin-nonfree --install. Now, you will have reliable video.

Now on to Virtualbox. First, install via command line: build-essential module assistant, then m-a prepare. Also, installing linux headers apt-get install linux-headers-$(uname -r) might be a good idea (see below). Install VirtualBox via command line terminal, then download (with wget -c) your .iso of choice; I stayed with Debian, stable (Wheezy) this time. You're going to install your "Guest" OS in VirtualBox through the CD icon; browse to your downloaded .iso file.

Wheezy 7.3 includes Guest Additions functionality (mouse control, windows resizing), but I didn't see evidence of the file, so after installing flashplugin (see above) and still not being able to load YouTube videos, I clicked Device and downloaded and installed the updated Guest Additions from the prompt. Most users seem to suggest downloading and mounting Guest Additions via command line, but this wasn't working for me. Maybe others could weigh in...I also ran the header commands above, in the virtual machine. Not sure if that's necessary.

Without knowing to first install build-essential and linux-headers (above), VirtualBox did not load after I rebooted my computer. Even after installing headers (after VB installation), I was only able to get things working by running these commands in host machine:
sudo apt-get install linux-headers-$(uname -r) #automatically detects kernel version
sudo apt-get remove virtualbox-dkms 
sudo apt-get install virtualbox-dkms 
dkms = dynamic kernel module support. Using sudo (not su) with this command seems important, as the user account needs to have privileges to use VirtualBox (at least I think that's the reason).

I set LOAD_VBOXDRV_MODULE set to 0 so Virtualbox doesn't start at boot. So, the vboxdrv module has to be loaded manually every time before starting Virtualbox: modprobe vboxdrv

Whether the Guest Additions, with 3D acceleration, or flashplugin was responsible for videos playing is unknown to me, but it did work...somewhat. Even with LXDE desktop and all programs except VB closed, video is very glitchy in a virtual machine. Perhaps this is not the case with newer systems. Anyhow, I'm running Debian Wheezy in VirtualBox and it's pretty cool.

Finally, after troubleshooting why my DSL Ethernet Connection had decreased to .50 mb/sec (1/2 mb) after the fresh install, System Tools < Network Tools < Network Device revealed that Loopback Interface, not Ethernet, was configured. I added the Ethernet (eth0) option, saved the configuration, then selected the new Ethernet option (previously set to "Wired Connection") from the network icon in the status tray of my desktop. Voila! Speedtest showed download speed of 6 mb/sec. Network Devices is otherwise useful for finding the IPv4 and IPv6 addresses of your provider, Ping and Whois utilities, and more.

Moving along, even though my Samsung phone is detected as USB, the SD card with my phone files is not detected. Perhaps I need to reformat the SD card, but in the meantime, sudo fdisk /dev/sdf does the trick.

Subscribe to my YouTube channel. 

Gimp, Fonts

You're on Linux and want to a Photoshop-like program? Gimp provides what you need: apt-get install gimp on any Debian-based distro.

Find your photos and open in Gimp. Decide on background, middle ground and foreground, and create respective Layers. I prefer to work sequentially with each layer, making sure it's exactly how I want, before moving on to the next Layer. Want your title text up front, superseding Layers below it? Put it last, using Text tool. Want text blended with foreground? Put it in middle ground.

Use the Smudge tool, experimenting with Opacity, to make your Layers and text blend in nicely. Use the Eraser tool the same way, to allow lower Layer to appear through. Also use contrast, saturation, etc. as needed. Blend color areas with Smudge, or match color areas with the paint "dropper" tool or Color Picker (cntl/Paintbrush), then paint areas, adjusting Paintbrush size and Opacity level accordingly. Whether using Smudge, Paintbrush or Eraser, experiment with Opacity level, as a lowered Opacity levels lend to more natural transitions.

To create a Photoshop-like project, compiled from "pieces" of several images,  select image areas with rectangular or free select, copy, New Layer, Paste to desired area, drag/move ("M"), click Layer Add To, and you're golden.

Sometimes you will experience an inability to paint over areas; no tool will work. You need to de-select the selected area: press Cntrl/Shift/a, and you should be able work on area. Menu Select None does the same. If those options don't work, make a New Layer for your new section.

Adding custom fonts to a header can give your site that extra edge; is the place to go. To install fonts in Gimp, save and extract the download to a folder, then cp (.ttf or .otf file location) /usr/share/gimp/2.0 (or your version)/fonts Then, run fc-cache -f -v and open Gimp. Your new fonts are ready!

Saving your Gimp file will only save a .xcf Gimp project file. If you want an image of your project, use File Export. For graphics, the .png format renders a small file size (fast loading) while showing impressive resolution at the default setting. .png is essential for images that you Composite Transition in kdenlinve.

Make transparent backgrounds using Alpha Channel, Fuzzy Select (Magic Wand) tool, Color Picker, and Bucket Fill erase mode. Edit < Clear is useful. Here's one method, and here's the Gimp tut

Subscribe to my YouTube channel.  

Upgrading from 12.04 to 12.10 to 13.10 "Saucy" Ubuntu in One Session

Edit: the following post might be useful, but I experienced other problems after upgrading, so I ultimately went with a fresh install (see post above). 

Ubuntu 12.04 was getting long in the tooth, so as I found myself two releases (over one year) behind the current distro, I decided to bite the bullet and do two consecutive upgrades from Software Updater. You need to upgrade each version sequentially. The total process, from 12.04 to 13.10, took about two hours, including troubleshooting. I'm going to cut to the chase about solutions to problems you might encounter along the way. 

For a change, I upgraded from 12.04 to 12.10 via Software Updater, and from 12.10 to 13.10 via command line do-release-upgrade. Although both methods will prompt you to remove obsolete program versions, you still need to run autoremove and autoclean to get rid of obsolete files that will create problems. For example, after upgrading to 12.10, I was running into a problem of desktop icons not generating after logging in (I accessed temporarily with sudo lightdm) and I think the auto commands solved the problem. 

As usual, Linux audio configuration is a PITA. When you get no sound, sudo apt-get remove --purge pulseaudio and make sure your alsa-utils are up to date. After upgrading, edit sudo gedit /etc/group file, putting your username after the : in audio:x: username. Save file, open alsamixer, hit F6 and select your soundcard. Make sure your Master level is high and Mute is off. Log-out, reboot and you should have sound!  

Subscribe to my YouTube channel.  

Pops and Clicks Fun with Kdenlive and .3ga Samsung Audio Files, Solved! Keyframe Animation FUN!

Update: since publishing this post, I've graduated to the command line utility, FFmpeg, for audio and video conversion. Check it out people. 

Kdenlive is occasionally weird with audio, and I've found that I have to convert .mp3 and even .ogg files to a lower bit rate in order to get glitch-free sound. You know, that "choppy" thing, artifacts, etc. By contrast, this is not a problem in Windows Movie Maker. Fortunately, using Sound Converter or Audacity does the trick; even 96kbps .ogg files are acceptable as background music or sound effects, for my purposes anyway.

So after getting Kdenlive to play nicely with .mp3 and .ogg files, I still had to figure out a solution to getting my .3ga sound files, recorded with Voice Recorder on my Samsung Galaxy Proclaim Android, to work in Kdenlive. This proprietary file glitched, popped, clipped and chopped to the point of being unusable. But being able to narrate over a video (prerecorded vid, an image, etc.) by recording on my Android is really convenient, so I needed to get this working.

A .3ga file—which to my ears sounds like a 96kbps mp3—loads and plays in Kdenlive, but pops and clicks. Changing the suffix to .mp3 helped get the file identifiable in Sound Converter, to convert to a smaller .mp3 or .ogg file, but the rendered file got a white noise distortion which rendered it unusable.

Next, I renamed suffix .mp3 and tried converting file in command line terminal, using LAME. More clicks and pops grief.

So I tried Audacity...

Problem solved! Exporting the .3ga file as .mp3 at 128kbps creates a glitch and pop-free file, when loaded in Kdenlive, even while playing a video track with embedded audio.  

So there you have it, people. When you have an audio file problem, go right to Audacity. I'm not sure what they're doing "under the hood" that LAME in the terminal can't do; maybe a reader can shed some light. If you're new to Audacity and LAME, you need to install the LAME codec; follow these instructions. 

Also check my post on using FFmpeg command line utility for converting audio and video.

On my Android, I record in 720 x 480 resolution. This makes for some pretty good video, and rendered in MPEG-4 in Kdenlive, gives a good compromise between quality and upload time to YouTube. I experimented recording and rendering in HD on another device, and the marginal improvement in video quality did not warrant the hours of upload time for a 3-minute video.

Be sure your Default Profile in Kdenlive is set to maximize your input quality. You get there by: Settings < Project Defaults < Default Profile. Mine is set to DV/DVD NTSC, which matches the 720 x 480 raw video resolution. The plethora of Profile options can seem daunting; Google your device name + Kdenlive to find the optimal setting.

Here are a couple keyframe videos I recorded in Kdenlive; manipulating anatomy and facial movements is fun:

Logarithms and Asymptotes

A logarithm is another way to represent exponents, in that the base^x (x being the "answer" or "y value") = the exponent; thus base^(exponent) = y. The common log—LOG key on a TI 83/84 calculator—is base 10, so that LOG(2) = .3010 and LOG(10) = 1.  Logs of different bases are calculated on a TI by using Change of Base, where LOG(8)/LOG(2)  [denominator being base, numerator being "y" value] = 3.33.

The natural log—LN on a TI—as explained by Kalid Azad, is about finding the period or time of continuous growth; continuous growth being represented by the constant "e", or 2.718: e^growth = time. LN is the inverse of e^time (2nd key e^x), which we use to find the growth: e^time = growth.

Understanding how rational (fractional) functions work in terms of vertical and horizontal asymptotes, end behavior, and infinite limits is important stuff. 

Asymptotes are undefined horizontal or vertical values of a function near which the function tends toward infinity. Vertical asymptotes are the zeros of the denominator, making the function undefined, so long as the numerator is heading toward a non-zero constant. The following rational function has a vertical asymptote, horizontal asymptote, and infinite limit:

lim x 1 (x-3)(x+1) / (x-1)^2

We plug the zero of the denominator, 1, into the numerator, and get -4, a non-zero constant (in this case negative). So, the vertical asymptote is x = 1, and as x approaches 1, the function is heading to negative infinity, - ∞.
Some rules about horizontal asymptotes in rational functions: 
  • When degrees of numerator and denominator are the same, leading coefficient of numerator is horizontal asymptote. Leading coefficients are useful when analyzing end behavior because as x approaches infinity, the smaller powers of x become insignificant. 
  • When degree of denominator > numerator, y = 0 (being a reciprocal function).
  • When degree of numerator > denominator, no horizontal asymptote, but there may be an oblique (slant) asymptote, found by dividing the leading coefficient of the numerator by the leading coefficient of the denominator.

In the example above, the degrees are the same, so we look at the leading coefficient of the numerator: the horizontal asymptote is y = 1. 

The zeros of a rational function are the x intercepts when y = 0; we find the x intercepts, or zeros, of the function by setting the x values in the numerator to 0 and then solving for each expression. In our example, y = 0 when x = -1, 3. Neither of these values makes the denominator zero, so the function is defined at -1 and 3, and they are x intercepts, not asymptotes, of the function. 

Continuity of a function is another concept; odd roots are continuous but even ones are not, because even roots of negative numbers are undefined: the y values of such numbers are imaginary, so they are not continuous throughout the domain.  

Are you involved with "Common Core" math education? Check out this interview with a CONCERNED parent:

Terminal Commands

  • rcconf for start-up configuration
  • apt-get update && apt-get dist-upgrade
  • apt-get autoremove && apt-get autoclean
  • directory/folder/file management: 
    • mkdir (make directory)
    • cd (change directory)
    • rm -r (remove directory/folder and contents files, recursively)
    • cp file /destination 
      • cp -r *.ttf /path/to/directory (copies all .ttf extension files from current directory)
    • mv (move = rename)
    • cat (display text file)
    • ls (list directory/folder contents
  • chmod 755 for folders; 644 for files: 
    • read = 4, write = 2, execute = 1
  • man (manual, followed by command, ie man uname)
  • uname -a (lists Linux kernel version and processor)
  • free -m
  • df -h (disk usage, human readable) 
  • cat /proc/meminfo
  • cat /proc/cpuinfo
  • /etc/vim/vimrc (Vim config file)
  •  history | awk '{print $2;}' | sort | uniq -c | sort -rn | head -10
    • awk is a language for text and data manipulation
Google App Engine GAE Setup Configuration: 

Set path: 

Change directory:
cd ~/APP/google_appengine/

Development server: python-math (localhost:8000; cntl c stops)

Update: update python-math

Download files: download_app -A python-math -V 1 ~/py-down

Solving Quadratic Equations, Factoring, Completing the Square, Vertex Formula

Even though using the Quadratic Formula: (-b ±  √b²-4ac)/2a is often handy when solving trinomial equations of the form ax^2+bx+c, knowing (remembering!) how to solve a trinomial equation by factoring and completing the square is crucial for working with algebra and trigonometry. 

First, if the discriminant, b² - 4ac is a perfect square, then the problem is factorable. We can also see if the sum of the products A and C equal the B variable; if so, we can factor. If not, solve by using the Quadratic Formula or by completing the square. I like to get rid of the leading coefficient immediately; this technique is the same as proving the Quadratic Formula

4x² - 2x - 5 = 0
x² - 2/4x +  = 5/4  (divide out that leading coefficient)
x² - 1/2x   =  5/4
x² - 1/2x + (1/4)²  =  5/4 + (1/4)² (add the square of half the b variable to both sides)
x² - 1/2x + 1/16 = 5/4 + 1/16
(x - 1/4)² = 21/16 (check this out: you want to set up a ±   situation...)
x - 1/4  = ±  (√21/16)
x  = +  (√21)/4 + 1/4 or x = -  (√21)/4 + 1/4

Next, knowing how to derive the Vertex Formula from the Standard is pretty important. In the formula y = a(x-h)² + k, (h,k) is the vertex. We arrive at the Vertex Formula from the Standard thus: 
3x² + 30x + 68
3(x² + 10x + 25)    +68 (complete the square; we're not solving the equation, just re-ordering)
3(x+5)²  -7  (subtract 3*25 from 68 = -7)

If we are given (h,k) and another point on the graph, we arrive at the Vertex Formula by solving for "a" by replacing h,k for given values, and letting y = the other y point, and x the other x point. Solve for "a." 

Unit circle graphic: 

Wolfram|Alpha, gnuplot

While relying on calculators and graphing programs is no substitute for understanding underlying principles in mathematics, apps and programs can facilitate the learning process. The minimal, Google-esque Wolfram|Alpha (W|A)  is the de facto online quantitative tool. And, in Linux, gnuplot is a convenient, command-line/terminal graphing utility.

Archaic, pixelated, oversized $100+ graphing calculators, such as the Texas Instrument TI-83 Plus and TI-84, are required by college (even high school) math teachers; many assignments require a "graphing utility." And, as smartphones are not yet allowed on exams, a math student has no choice but to submit to this racket, or, like I did, scout and score a TI-83+ on ebay for $35. However, even $35 seems unnecesary, when compared to $2.99 W|A or Algeo apps for Android, that together can do so much more than a calculator that hasn't been updated in 10 years.

W|A, is a quantitative, not subjective, tool: ("best chicken recipe") doesn't work; rather, enter quantitative statements, like ordered pairs, quadratic equations, or "chicken" for a graphic taxonomy.

For engineers and mathematicians, Wolfram offers the Mathematica program (whose Linux counterpart is Sage). However, any math problem the college student might face can be processed by Wolfram|Alpha. For Android, the $2.99 W|A app is worth every penny and about $50 more.

As a preview tester for Wolfram|Alpha, I am not at liberty to discuss new program features. However, the W|A team is constantly rolling out updates, and is open to suggestions from the community at large. Of particular interest are the math updates from the W|A team; it's obvious that this continues to be the project's focus. Texas Instruments, look out.

In my opinion, we will see W|A as the de facto classroom mathematics tool within the next three years. At present, teachers do not allow Android or iPhone usage during tests. However, just as a graphing calculator can compromise a student's ability to do the math by hand, the usage of smartphones is just the next, natural extension of that compromise. You can't stop technology, remember? Well, apparently, teachers have forgotten this premise in regards to smartphone usage in math courses. To their defense, teachers need to observe the process of how a student arrives at a solution. Computer Algebra System (CAS) calculators are banned for the very reason that they, like Wolfram|Alpha, can solve the problem, and show the steps leading to the solution.

While the dilemma is real, stopping progress is futile. One school of mathematics still believes that relying on a graphing calculator for calculus defeats the whole purpose for learning the subject, or at least undermines the student's understanding of the material. I agree, and any learning tool should only support a primary understanding of the concepts, including the ability to arrive at solutions by hand, on paper.

Moving on to Linux, gnplot is a command line/terminal graphing program. You have to set your output type to produce a file; png is the most popular. Here is a polynomial function:   

gnuplot> set terminal png
gnuplot> set output "gnuplot.png" 
gnuplot> plot (((x-1)**2)*(x+3))/((x+1)*(x-(5/2)))
Note the nested brackets (reminiscent of the Scheme programming language), and the calling of exponents with **

While Linux has many more mathematics programs that I hope to explore in the coming years, gnuplot is a great place to start, for command-line graphing.

Do you have a favorite Linux math utility? Please share in Comments. 


gnuplot> set terminal png
gnuplot> set output "gnuplot.png" 
gnuplot> plot (x-1)*(x**2+3)-sqrt(2) lc rgb "violet" lw 2

Network, Secure Shell (SSH) and Secure Copy (SCP)

In this second installment of our IT Bonanza, we will configure a network and router using Dynamic Host Configuration Protocol (DHCP), and view and share files in our network via a secure shell (SSH) connection, and Secure Copy (SCP). 

This tutorial is for networks that are served via an Internet Service Provider (ISP), and have dynamic, not static, IP.

Router and Network Configuration 

First, power up and connect your router to the machines in your network. The Wide Area Network (WAN) Ethernet cable connects to your DSL line or cable box, and the machines in your network connect to Local Area Network (LAN) ports on the back of router. Following these instructions alone may be adequate for setting up your network; check that each machine can connect to the Internet. Now, let's explore our router's configuration, to see what's going on behind the scenes. 

For the Dynex DX-400 series routers, type in your browser address bar. This will bring up a log-in window; type admin for both username and password for access. 

First, create a username and strong password under System Tools! Next, scanning the Router Status, note the LAN address,, and WAN address, which correspond to your local machine and ISP, respectively. Recall that in the first part of this tutorial, our LAN address is used for the DNS host to "point to" our machine, subsequently serving our web page via Apache server. If you wish to continue serving your DNS domain name and web page from your local Apache server, in a networked environment, click on Dynamic DNS from the menu, and enter username, password and domain name from your account, check Enable DDNS (Dynamic Domain Name Server) and login-in. You should get a Succeeded! confirmation status.

Because we use an ISP (AOL, cable, DSL, etc.), our network IP is dynamic, not static. You can pay a premium be assigned a static IP, as do many businesses, schools, and government entities. A static IP environment effectually hosts and serves their own systems. This concept is relevant because as we explore Secure Shell (SSH) and Secure Copy (SCP), we must adjust slightly for working in a dynamic IP environment. 

Connecting to Machines and Sharing Files in a Network  

These instructions continue to apply to a Linux environment (Debian). # apt-get update && apt-get install ssh on all your machines in the network. You will notice that open-ssh-server is the secure shell server that is installed, along with RSA and PSA algorithmic cryptology "keys", and OpenBSD's secure shell. Now we are ready to connect to computers in the network.

To connect to another computer, type the other computer's user and hostname.local as follows: $ ssh user@hostname.local (replacing user and hostname with the proper names). When prompted for the RSA key fingerprint, type "yes"; enter user password for machine you are connecting to. Next, approve that this hostname.local is being added to the LAN of known hosts. You will now be logged in to the other machine; type ls to see directories...look around! exit logs you out of this account, back to your machine.

Because we are in a dynamic IP environment, using DDNS, ssh username@hostname alone will alert "could not resolve hostname". Thus, the .local suffix is necessary; works as well. In this closed "shell" environment, port 22 is the default shared port; confirm this in /etc/ssh/sshd_config.

SCP (Secure Copy) is similar to SSH in that we must produce the user password of the machine to which we are sharing files. To export a file from your machine to another on the network, type scp yourfile otheruser@hostname.local:directory, replacing yourfile, otheruser, hostname and directory appropriately. Now, check that directory via SSH (or manually) and you should see your exported file!

DNS and Apache2 Server Integration

This post shows how to serve a web page using Apache2 server, via a third party Domain Name Server (DNS), which in turn will configure and serve your custom Internet Protocol (IP) address!
Store your HTML or PHP files in /var/www folder. If using Python, /var/www/cgi-bin (create cgi-bin directory folder within /var/www. The Apache configuration file for Debian is at /etc/apache2/sites-available/default; on Windows it's conf\httpd.conf. Here, note VirtualHost at Port 80, and DocumentRoot at /var/www. Here are common solutions to server 500 errrors:   
If installing Apache on Windows, that already has IIS server, change VirtualHost Port to 8080 and access your web page from localhost:8080 (or localhost:8080/cgi-bin for Python). Google App Engine's local server serves files from 8080 as well.  
Make sure Python path at the top of your code is correct: #!/usr/bin/python for Linux; if Python installed to C:/ in Windows, find path, for example: #!C:/python27.  
Set all file and folder permissions to chmod 755 and 644, respectively. Important!
Check form paths and file paths to linked pages, CSS, etc; broken links crash applications.
Include error and traceback reporting in script:
PHP: error_reporting(E_ALL); Python: import cgitb and cgitb.enable()
 Run Firebug or other web dev tool console
Here is the Apache configuration file edited to serve Python files from /var/www/cgi-bin: 
   #ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    <Directory "/var/www/cgi-bin">
         AddHandler cgi-script .py
        AllowOverride All
        Options +Indexes FollowSymLinks +ExecCGI
        Order allow,deny
        Allow from all
Next, to create a domain name through which you will serve your Apache files, scoot over to and select a "Add a Host," followed by the suffix of your choice from the scroll down menu. Your IP address will be detected automatically. It is from this address that will "ping" your domain name that you create here: 

Now, restart Apache2 on the command line (CLI): /etc/init.d/apache2 restart, then type the web address of your new no-ip host in your browser (in my case it's
This page is being served "live", via Apache2 server. Note the server version, OS and Port 80 info. Now, by clicking on the html file...
...our web page appears. Typically, this page would be named index.html, and the site would open to it; but I wanted to demonstrate the server, OS and Port info on first web page. This is just an introduction to the possibilities of serving your own pages to the WWW. This process would work the same if you were running a php file and integrating MySQL database, for example. If you do serve PHP pages, be sure to install libapache2-mod-php5.

Pythagorean Theorem Proof

Understanding underlying concepts makes learning enjoyable. Greek mathematician Pythagoras observed that the square of a right triangle's hypotenuse (longest side) equals the sum of the squares of the two legs:

a 2 + b 2 = c 2

Following this theorem, the diagram shows the square of the hypotenuse, c2, forms the basis for a larger square, formed by the two legs of each right triangle. Take a moment to see these relationships.

To prove the theorem algebraically, consider the area of the large entity, in this case, the outside square: (a + b)2, as being equal to the sum of the areas of its constituent parts: the hypotenuse squared c2, plus the area of the four triangles, 4(1 2)a b. From this premise,

(a + b)2 = c2 + 4(1 2)a b

Factoring this equation brings us to the original, Pythogorean Theorem, and thus completes our proof:

a2 + 2ab + b2 = c2 + 2ab

a2 + b2 = c2

Math notation made with MathML (see page source). Diagram made with GIMP, using Stroke selection on square with a second, rotated square inserted (calculated with Pythagorean Theorem!). Another method to generate outlined shapes is to Paint Bucket fill, Shrink, then Clear.