Encrypting a Drive with Truecrypt

I have spent many hours of troubleshooting, researching, and scouring the net for a good encryption software program to encrypt a few sensitive files. After all kinds of high-end apps and expensive apps and open-source apps, I came across the gem. The best of them all: Truecrypt.

Backstory of Truecrypt

The backstory of Truecrypt is, like their service, slightly encrypted! There’s not that much information on the people behind Truecrypt, but it is open-source. This means that the code behind the program can be examines by all. While that’s nice and nifty and great for free softare and open-source (stuff I absolutely love because of it being quality, the community, and the beliefs behind it); having truecrypt’s code being opensource is additionally important for security. Because it’s open-source anyone can examine the code of the application to ensure that there’s no back-doors built into the security algorithms. Because nothing is hidden in its design, people can see and verify that it is safe.

File or Partition?

I had difficulty deciding on if I should use a file-container or partition. I quickly decided on partition after getting more information. Truecrypt file-containers/volumes are like normal files that can be put in folders, moved, copied, and deleted. That’s interesting, but not as simple as a partition. Most importantly, a partition has better performance than a container and reading and writing to a container file (just as with the partition, involves encrypting and decrypting on the fly) becomes very sluggish if the drive/system is heavily fragmented. So for faster read/write (which includes encryption) and performance and the fact that I wanted the truecrypt area to be accessible, I went with truecrypt partition. The idea of truecrypting an entire system is pretty interesting, and I may look into that, but for now the partition is a great method for having outrageously DOD, NSA-security on a select space of files.

The encryption/decryption methods and numbers of truecrypt are pretty advanced, like John Nash, Phd number theory mathematics advanced. So that’s reassuring and, additionally, interesting for a (very) side project of learning. It was pretty fascinating

Volume Setup

There’s three things you can encrypt. In order of least to most comprehensive, they are:

1. Truecrypt Volume

2. Partition Encryption

3. System encryption.

1 creates a truecrypt file on an existing partition. In linux, this single encrypted file shows up as an unopenable program file.

2 encrypts an entire partition.

3 encrypts an entire operating system.

Hidden Volume Setup

This was so ingenious of an idea I had to try it out. The hidden volume setup creates an outer volume in which you put decoy data and within that encrypted outer volume, a hidden volume which contains your actual data. Both the outer and inner volume’s are unencryptable but this adds a second layer (to an already unimpenetrable security line) of protection.

I tested making a 600gb truecrypt volume file (called a container) and on my netbook it would take 18 hours. This time would likely be one quarter of the time on a faster machine, but needless to say, the formatting, and encryption process is very very very comprehensive and secure!

Encryption Method

I considered using AES (advanced encryption standard), although there were many many many options for encryption. Truecrypt uses AES with “14 rounds and a 256-bit key”. I’m not John Nash, so not sure what those details mean, but I trust (and know and understand) that the data is very very very secure. But I went with Serpent which sounds equally secure.

Hash Algorithm

In addition to encryption method, you can also pick the hash algorithm for your encryption. I chose RIPEMD-160, which was developed by EU’s project RIPE (RACE Integrity Primitives Evaluation) and then adopted by the International Organization for Standardization (most commonly recognized as ISO), in the early 1990s.

The Hidden Volume.

This is AMAZING. This is one of the coolest things I’ve ever seen. With the same encrypted container/partition/system you have one truecrypt encrypted “file”. Now with that EXACT same file if you enter the outer volume password you get the outer volume (with decoy files) and then with the EXACT same file if you enter the hidden volume password, you get the hidden volume. Essentially one file has two doors. This would be like a house having a door. You use a key (password) to enter it. If you wanted to show someone that you would use a key (password) and it would open up and there would be your kitchen and table and chairs and desk and whatever. But with hidden file systems it’s like you go to the same door but use a different key (password_secret) and that exact same door opens up to an entirely different house. Instead of those normal things you’d see some sleek office area. This is so cool. This is more advanced than I thought. I thought it was a folder within a folder (outer). Not so, it’s one single file that unlocks two different ways. Wow this is awesome! That is easily one of the most impressive features I’ve ever seen in a program. Far exceeded my expectations.

Other Guides

Youtube tutorial on hidden volumes (horrible sound quality) – http://www.youtube.com/watch?v=3wUbnsEV0s0&feature=related

TrueCrypt and DVDs

This is a splendidly nifty idea. Create a truecrypt file-container and burn it onto a DVD. Now some backed-up files on disposable media (DVDs are cheap!) is now encrypted!

Very delighted with this find. It works because of its cross three-OS platform compatibility (something very important for me because I work in at least three OSes at times. Additionally, it works flawlessly and is uses by some big organizations (schools, huge companies) and has good repute.

Is it an Asteroid, Meteoroid, Planet, or Comet?

Asteroid

  • Diameter Size: 1-600 miles
  • Size Comparison: Meteoroid < Asteroid < Planet
  • Orbits Sun? Yes.
  • Other Distinctive Attributes: No atmosphere. Usually considered to be between Mars and Jupiter orbits. If enters earth atmosphere and is about the size of a car, makes bright glow.

Meteoroid

  • Diameter Size: Greater than a spec of dust, but smaller than an asteroid (a few centimeters to <1-mile)
  • Size Comparison: Meteoroid < Asteroid < Planet
  • Orbits Sun? No.
  • Other Distinctive Attributes: No atmosphere.

The Best Open-Source (aka Free) Apps for Practically Every Category of Program

Here’s the list the Best Open-Source Applications for Practically Every Category of Program!

I could have made this post very long (detailing all other options and why and how each application is superb) or very short.  I made elaborate later, but for now I went with the briefer version!

  • Graphics Manipulation – GIMP
  • Webcam Capture – Cheese
  • Screen Capture – KSnapshot
  • HexColorPicker – KColorChooser
  • Text-editor – GEdit
  • Word-processing, Spreadsheet, Database, Presentation – Libre Office (Truly marvelous, Full-fledged, extensible, advanced program.  Even the formula Math sup-application is very complete.  Professional word-processing in the Writer sub-application as well.)
  • Browser – Chrome and/or Firefox
  • Ubuntu-Specific Productivity for CLI – Guake
  • Ubuntu-Specific Productivity for GUI – Gnome-Do
  • Encryption – TrueCrypt
  • Email – Mozilla Thunderbird
  • Graphing Calculator – Extcalc
  • Media-player – Banshee (Incredibly swift and simple podcast-rss adding that Works.  Very fast, Excellent layout.  Superb).
  • Audio-Editing – Audacity (Superb with many advanced editing features and filters).
  • PDF-Viewer – This one is tricky.  Because the built-in viewer doesn’t allow high-lighting and okular can only save in the useless .okular file format, the best PDF viewer (that allows for .pdf-saveable highlights and annotations) is Foxit Reader and/or PDFX-Change Viewer via Wine.
Note, many of these incredible open-source applications (truly incredible, some of them could easily be very expensive as they are full-fledged high-functioning applications) are cross-platform, available in other operating systems (not that that matters much! xD) as well.

Bulk File-Renaming

pyRenamer pyRenamer pyRenamer pyRenamer. Easily my favorite utility of all time. “All time” spans windows xp, windows 7, various versions of ubuntu, and mac os 7 to 10.6. Out of all gui-based utilities in all those OSes over the past twenty years, pyRenamer is easily my favorite utility app. I’ve used it to rename literally tens of thousands of files and directories. It works flawlessly. It never crashes. And it was coded in my favorite programming langauge, python. Here’s a list of the file renamer gui-apps I’ve tried that have been utter and absolute failure and zero comparison to the supreme efficiency and awesomeness of pyrenamer.

  • Better File Renamer (rubbish)
  • NameChanger (okay, but rubbish)
  • Fast File Renamer (okay, but rubbish)
  • Bulk Rename Utility (didn’t even bother trying, but rubbish)
  • Batch File Renamer (rubbish)
  • Magic File Renamer (rubbish)

There indubitably exist people who work with more files than me, but I have not yet met them, so out of all the people I’ve met, I work the most files, tens of thousands of files that all must have strict, well-planned, well-organized naming schemes. pyRenamer is hands-down, no comparsion, the absolute superior best utility app for renaming files in bulk. Naturally, it’s free, open-source, and for linux.

Customize your CSS Blockquote Code Appearance (in WordPress or any Blog)

Why Do This?

This post involves editing your blog theme’s “.css” or Cascading Style Sheet, most likely the main Style Sheet.  Cascading Style Sheets are a marvelous new1 (be sure to see the foot-note for interesting history of CSS) style sheet language. Every colour, font, margin, border, layout, menu, and placement of everything on your blog is designated by what bloggers call its “theme”, but the theme you see is really composed of mainly .css pages so by learning to edit your blog’s theme’s .css page you can customize your entire blog in every way imaginable and even create your own themes! Learning how to tweak your blog’s theme’s css is momentously useful and awesome!

After this post you will know how to customize much of that! So really this is about making your blog more you and enacting upon your privilege to customize every appearance nuance that you want! By the way, CSS and HTML both can “style” or “format” web content but, CSS uses coordinates for layout and much many more advanced features leading to limitless or infinite layout and format options!

Accessing Your Style Sheet

  1. In wordpress you’ll want to look in the left-hand menu and click Appearance—>Editor. This will pull up a page that on the left-hand coloumn has a bunch of links of .php and .css pages.
  2. Don’t worry about the .php (and even most of the .css) pages for now. All of those links by the way compose the entire formatting of your blog’s theme! You want to find your main CSS sheet. Usually this is called “style.css”. It also may be “main.css” or something of a similar prominent-sounding name.
  3. AFter you have pulled up your main stylesheet, henceforth referred to as “style.css” for purposes of clarity, use your browser’s Search/Find feature to search for “blockquote”. If you cannot find it, do not fret, just append the following code to the style.css page (and if you can find it, replace the blockquote{ other code here} code with this):

blockquote {background-color:#FACC00; font-style:italic;border-left:4px solid #111; border-right:4px solid #111;margin:15px 30px 0 10px;padding-left:5;}

Now if you don’t customize that…

Customizing Your Blockquote Code

But this is about customizing your blockquote appearance, so I’ll deconstruct and describe every inch of that code so you can customize things how you wish!

  • background-color:#FACC00 – This is the background color of every blockquote. Normally this is white (#FFFFFF) by default. That rich orange hue corresponds to the hex-number FACC00. Hex-numbers are always six alphanumeric digits composed of A-F and/or 0-9. Those six alphanumeric numbers correspond to a color! You can gather an always-six-alphanumeric-digit hex-number for the colour of your choice from a nifty color-picker that provides you with the hex-number. Eliminating the background-color: attribute makes the blockquote background white.
  • font-style:italic; – Eliminating this code simple makes the font non-italicized.
  • border-left (and border-right) – This is slightly more advanced but very fitting for the customization of our blockquote. The two black bars are created by the border-left and border-right code. The colour of them (in this case black) and the width (in this case 4 pixels) are, of course, customizable. You can optionally choose to leave one out (to have only one column for your blockquote) or to exclude them both (no border-columns). Additionally, if you so desire, you can include a full rectangular border with the addition of border-top and border-bottom attributes! The cutomization features of CSS are marvelous and you can really get your pages and blog or site to look exactly how you envision!
  • padding-left – This attribute is practically identical to the “indentation” component of a word-processor. Except that a word-processor uses measly old inches or centimetres (usually) instead of the superior pixel. Furthermore, unlike a word-processor, the padding-left css “indent” is universally interpreted by every major browser! In other words, padding left indents the blockquote (border(s) included) a certain amount. In the above example, the amount is five pixels. If you really want to differentiate your quote from normal text, you might want to increase this number to make the blockquote really stand out via indentation.
  • important stuff – Every css property (padding-left, font-style, and background-color are three examples of properties) has the format property:value;. Note the colon that separates the property from its appearance-changing values and the semicolon which always separates a property-value set. The semi-colon (practically universal in code and various programming languages) allows you to have many different property-value pairs on the same line without the browser getting confused because they’re separated with semi-colons.

I’ve included some very usefull CSS quick-references here, from w3schools, and here from javascriptkit. The former, w3schools, includes links to almost every property of every attribute, providing a freakishly complete reference for almost every customizable feature of the awesome style and formatting code of css! Additionally, this is a great alphabetical reference of every css property (and corresponding values).

So to conclude our little tutorial. Just edit the blockquote{} code how you want, save the style.css, and reload a blog or site page that contains a to see the sparkling new changes!

1.  Fairly new.  Cascading Style Sheets actually have quite a lengthy history dating back as far as the 1970s with SGML.  The first version of the modern version of Cascading Style Sheets (CSS v1.0), however, emerged in December of 1996.

What’s the Difference Between Initialization and Formatting a Disk?

I love computers. I love digital data. I’m in the process of getting almost everything (via digital photos and finding or creating electronic versions) I own on my hard drives. I also love learning about hard drives and the accessing of the data from various sectors, read-write and access times. I have much to learn about more detailed components of the hardware, but one thing that has always perplexed me is the often misused “initialize” and “format” of a disk.

As it turns out, even hardware manuals for computers misuse the words initialize and format. So this sets it straight, ,once and for all.

Initialize

It turns out this discrepancy was once again related to the clouded, obfuscated self-created jargon used by Apple computer. Unfortunately, I grew up in youth using macs. This severely distorted how I viewed the objective (PC/windows and linux) world of computing because Apple tries to create a whole heap of its own language (intialize means to assign a starting value to a variable in programming, but that’s about it) and it locks down it’s operating system. In other words, if you only use Apple, you will be slightly askew and off from how the rest of the world does things with computers. This is very bad. You will see a on occasion a variety of anti-apple posts on Linuxgeekoid and from their toiletseat-shaped first generation fruity-coloured absurd iBooks, to the nuisance of learning useless “Apple-only” jargon that’s only applicable to that OS and hardware (that is sheer 100% marketing play to envelop consumers toxically in the “Cult of Apple”, which, toxically is all that it is, a pathetic cult). Real computing actually allows the user to tinker with BIOS, to have a standard (not apple-tweaked) file hierarchy that’s more or less universal, and other essentials. Someone who has only used apple computers, very likely will not know some essentials of computer, therefore! I’ve been ravenous to catch up (while abandoning Apple) and learn all that I can about this field that I have always loved (computing).

That rant aside….

Initialize means to supposedly erase the reference to the directory. In other words, upon initalization (again this is just a word and jargon that Apple made up in its attempt to keep its consumers enveloped using its own products; this is a hacker-based blog-site so Corporate attempts (as they always fail) to keep consumers trapped through psychological means into continuing to use rubbish over-priced products are openly ridiculed!) the reference to the hardware lcoation of data is erased. Thus, if a drive is initalized, but never written upon, all that data will exist, but it will not have a reference. Normally, an intialized (going by that definition) drive will be written upon and it will slowly write over the now-unreferenced data.

An analogy would be a slab of road that is barred off so cars don’t go on it (or a slab of grass that isn’t mowed or whatever) and then when it’s “intialized” the barred off area is removed so cars can go on that area (or that area of grass can be mowed), but it may not necessarily get “written over”.

Format

Format is the true definition of to “erase and prepare a disk for use”. Again, Apple’s unnecessarily ambiguous definition sounds identical to “format” in some ways.

“When you format a disk, the operating system erases all bookkeeping information on the disk, tests the disk to make sure all sectors are reliable, marks bad sectors (that is, those that are scratched), and creates internal address tables that it later uses to locate information.” (1)

So in other words (we’ll now be fully neglecting the “initialize” crumbly and useless jargon of Apple’s and focusing on what appears to be the only way to prepare a disk) formatting involves:

  1. Eliminating all book-keeping data on the disk
  2. Doing reliability-checks on all of the disks sectors (and indicating which sectors are bad, or scratched)
  3. Finally, creating and setting up fresh new internal address tables for the future location of new information.

Conclusively, “formatting” a disk erases all references (the “index” sort of) of old data tables, checks the reliability of all sectors (the space for new data and where the old data was), and finally sets up new data tables for locating and indexing new data. Kind of a clear the whiteboard, check to make sure is clean and not cracked, and then prepare the markers and outline things for writing new data to the whiteboard.

What was said about deleting the references to the data (initialize seems to be more or less identical to format but is an unnecessary and ambiguous “Apple-created” marketing jargon) but not the data itself is applicable to a “format” of a disk. Because the address tables are all that are erased in a typical format, a computer hard drive specialist can recover the data.

By the way, for a brilliantly lucid (and introductory) discussion with diagrams of sectors of a hard disk, this site does a great job.

Low-Level and High-Level Formatting

By the way, the entire discussion up and until now (and for most of the entirety of the article, and for that matter, most of the time whenever someone mentions “formatting a hard disk”) has been referencing “high-level” formatting, but there actually exists low-level and high-level formatting.

“The purpose of low-level formatting is therefore to prepare the disk surface to receive data (and therefore does not depend on the operating system) and to mark “defective sectors” using tests performed by the manufacturer.” 2

(3)

So Low-Level formatting kind of can be equated to maybe serious foundation and structural integrity tests that an engineer or architect may do on a building (testing to make sure it doesn’t collapse). Low-level formatting prepares the hardware to be written to and is indifferent to operating system and even data tables; it actually creates the sectors and tracks on a drive. It’s almost like low-level formatting is installing the doors and windows and rooms of a house (house = hard drive in this analogy). High-level formatting (using the structural integrity test analogy continuation) is thus similar to maybe a very thorough house-cleaning or moving everything out of a building to prepare it for moving in new things. Thus, low-level formatting, once complete on a drive, is rarely needed ever again. This is why almost all references to “formatting a drive” imply a high-level format.

Metaphors and analogies aside, high-level formating is operating system-specific and always has a file format.

File Formats

File formats deserve an entire book of explanation, but this is a surmised version.  File formats are specific to the file/operating system.  So there’s

  • Microsoft: DOS, FAT32, NTFS
  • Open Source Initiative (or OSI): ext2, ext3, ext4
  • And others Apple has its own file format.

Whatever the file format type, the high-level formatting enables and makes functional data writing to the disk in clusters (sector-based groupings). The file system is used to map logical address of files (address tables) to the actual physical spaces. This is what was referenced in the beginning of the data tables being erased by not the physical data itself. File systems link the logical address “index” to the physical location of the data on the sectors. Secondly, file systems in addition to that “index/directory connecting to the physical sector bit”, access data for read/write and thus enable the opening, changing, deleting, and executing of files and/or programs. In a nutshell the file system allows you to access, read/write data and to ensure it’s mapped with an index of wherever it’s location is on the hard drive itself.

This explains what happens when a file is deleted. Usually the physical data containing the file is not permanently erased (written over with 0s), but rather it flags the OS so that it can be reused. This is identical to the barrier setup on the road or the grass, when a file is deleted, that barrier is removed and the sector on the drive (or road or grass) can be written on (or driven over or mowed). So eventually with a drive in active use where all of the sectors are in use, deleting a file and then writing new data will likely mean that that file has been written over and is completely deleted.

There exist secure applications that write over files to secure permanent and thorough deletion. One of the most well-known is Blowfish. That’s great for secure deletion, but for encryption, Truecrypt is by far the superior and best software.

Checksum, scandisk, chkdsk

When a hard drive is undergoing check tests during low-level of high-level (logical) formatting it marks good sectors as valid and broken (scratched) sectors as invalid.

Scandisk or chkdsk are disk analysis utilities that function by writing data on sectors and then read and compare what was written to (and read from) the disk with what was supposedly to be written. The two obviously must be identical! When what was written and what was read from the disk are not identical, then that sector is marked defective and given an invalid indicator and will not be used in normal usage of the disk.

Who does low-level and high-level formats?

The hard drive vendor (Seagate, Western Digital (will never purchase another drive from them), Toshiba, and the like) does the low-level formatting. Then high-level formatting (if you’re like me and like many well-planned and prudent partitions) is done by an administrator, a computer technician, or the average pc-user who knows what they’re doing. If you get into different partitions, you can utilize the fact that each partition functions as a separate drive (see this article for more of a discussion on extended, logical, and primary partitions).


1. http://www.webopedia.com/TERM/F/format.html?page=2
2. http://en.kioskea.net/contents/repar/format.php3
3. http://www.mhsv.org/computer-information/guide-to-computer-forensics/types-of-hard-drive.html #VERY well-written resource

The Continue Statement (Javascript-Style)

Continue and break statements are essentials to almost any programming language. Learning how to use them and what they do in a simple language like javascript can really have an impact on your clarity of interpreting and writing code.

This code is ridiculously simple, but quite a delightful usage of the continue statement in javascript.  It also annoyingly bombards the viewer with 4 alert boxes, but the blatant bombardment makes the effect of the continue statement less ambiguous, kind of an obvious Alert, Alert, Alert, “Oh that’s what continue does!”.
var a = 0;
for (i=0;i{
if (i==5 || i==10 || i==15 || i==20)
{
alert( i + " is a...MULTIPLE OF FIVE!");
document.write("
");
continue;
}
document.write("The number is " + i);
document.write("
");

If a break statement were substituted in the above code, the output would be:

This is number 1
Thus is number 2
This is number 3
This is number 4
5 is a…MULTIPLE OF FIVE! //alert box

and then terminate

Out of all the languages, learning about continue and break statements in javascript and python is probably best because there’s less chance your usage of them will be clouded by the complex nuances of heavier languages. Libre Office, for example, (a full fledged presentation, spreadsheet, wordpressing, database, drawing, and more opensource word-processor suite) was coded in C++ and Java. Of course, there’s continue and break statements in those languages, but they’re full-fledged languages and for just learning what a continue or break statement does, languages that require less architecture to implement a few commands (like python or javascript) are great.

From slashdot, ErichTheRed writes:

“This Computerworld piece actually got me thinking — it basically says that there are few good ‘starter languages’ to get students interested in programming. I remember hacking away at BASIC incessantly when I was a kid, and it taught me a lot about logic and computers in general. Has the level of abstraction in computer systems reached a point where beginners can’t just code something quick without a huge amount of back-story? I find this to be the case now; scripting languages are good, but limited in what you can do… and GUI creation requires students to be familiar with a lot of concepts (event handling, etc.) that aren’t intuitive for beginners. What would you show a beginner first — JavaScript? Python? How do you get the instant gratification we oldies got when sitting down in front of the early-80s home computers?”

That’s 100% spot-on and precisely what to what I’ve been alluding. However, that said, I think javascript and especially python deserve more credit. They fantastic starter languages, but they’re extensible. Addon libraries and modules like pygame for example make these languages very complete and much more capable than something like BASIC, and yet they have the awesome “great introduction, no need to get overwhelmed” feel as what EnrichTheRed refers to as starter languages. But Python is infinitely much more than a BASIC 2.0. It’s a full-fledged language, intuitively written so that it’s elegant, a great introduction for beginners, but decidedly complete and thorough enough like a full-fledged language in some ways for more advanced coders/programmers.

So What Exactly Does Break and Continue “Do”?

So just to clarify, what does the continue statement actually “do”?  Well, both continue and break say to the current conditional (if, if-else) or iterative (for, while, do-while) loop

“Don’t execute subsequent code in the function!”

Both the continue and break statements do that, but the difference is that continue simple reevaluates the function again, in a sense merely “skipping” the subsequent statements after  that one instance that brought continue to be executed.  The break statement, on the other hand, says “Don’t execute subsequent code in the function!” and then breaks out of the rest of the loop, in a sense aborting the rest of the iterative or conditional loop.

Thus, I like to think of the break statement as an “abort!” and the continue as “hold up, I’ll take that or I’ll adjust that, now back to what you were doing!” effect.  You can connote whatever you want with them, but continue and break are extremely potent statements to make your functions, loops, and conditionals behave in advanced ways, accomplishing what you want!

Other Definitions

Some other resources (defining the exact same thing we have detailed above but just using slightly different wording, because people learn differently, the altered wording may help or hurt your comprehension).

From IBM’s site (just one of the many random resources detailing continue statements):

“CONTINUE STATEMENT

continue statement ends the current iteration of a loop. Program control is passed from the continue statement to the end of the loop body.

continue statement has the form:

>>-continue--;-------------------------------------------------><

continue statement can only appear within the body of an iterative statement.

The continue statement ends the processing of the action part of an iterative (dofor, or while) statement and moves control to the loop continuation portion of the statement. For example, if the iterative statement is a for statement, control moves to the third expression in the condition part of the statement, then to the second expression (the test) in the condition part of the statement.

Within nested statements, the continue statement ends only the current iteration of the dofor, or while statement immediately enclosing it.”

This is all basically what we just said.  The continue statement’s “processing” and brings the focus back to the loop-control (in “for” this would be the increment, in a “while” this would be the conditional evaluation and the like!)

Mogrify, Mogrify, Mogrify: Batch Resize and Image-Manipulation from the Command Line!

-resize

-format

here’s some details of the implementation of the -resize option with the very nifty parameter details.

Resize to exact 640×480, change aspect ratio if necessary

mogrify -resize 640×480! *.jpg
Resize to 50% of original size, keep the aspect ratio

mogrify -resize 50% *.jpg
Resize images that are less than 640 pixel wide to 640px wide (image wider will be ignored)

mogrify -resize 640

Resize images to no larger than 640×480 (images with width and height less than 640 or 480 will be ignored)

mogrify -resize 640×480″>” *.jpg
Resize images to 100K pixels

mogrify -resize 100000 *.jpg
Digital Photography Tips and Techniques

Some of the Select Options (There’s Tons more!) that I found interesting and amusing:

-antialias
remove pixel aliasing
-border
surround the image with a border of color
-bordercolor
the border color
-emboss
emboss an image
-flip
create a “mirror image”
-format
the image format type
-frame x++
surround the image with an ornamental border
-gaussian x
blur the image with a gaussian operator
-help
print usage instructions
-implode
implode image pixels about the center
-level
adjust the level of image contrast
-noop
NOOP (no option)
-normalize
transform image to span the full range of color values
-resize x{%}{@}{!}{}
resize an image
-scale
scale the image
-shear
shear the image along the X or Y axis
-tile
tile image when filling a graphic primitive
-transform
transform the image
-transparent
make this color transparent within the image
-unsharp
sharpen the image with an unsharp mask operator
-verbose
print detailed information about the image
-wave x
alter an image along a sine wave

Everything from converting files, batch-processing, creating a montage of thumbnails, displaying slideshows of images, animating gif animations, and more can be accomplished with the this mogrify command.  Check out ImageMagick for basic usage and examples.

VERY Useful Links of some Linux Friends and Compadres on the specific mogrify command

Deactivate that Annoying “Display” or “Execute” Option in Nautilus

Ubuntu is a fantastic operating system.  It’s careening fast.  It’s efficient.  It’s open source.  It’s free.  Some of the best apps (commercialware included) are open-source.  It’s great to efficiently and smoothly use the file manager Nautilus (it is about as sleek as Nemo’s vessel!).  One common obstacle is this option whenever you open a file (typically a .txt file).

 

Familiar?  Right.  Here’s how you set the file manager’s default preferences to automatically display .txt files.

For keyboard-jockeys like me hit Alt-E-N.  That brings up Preferences.  Or Go To Menu—>Edit—>Preferences.  Now click on the second tab, the behaviour tab.  You should now see this.

Under “Executable Text Files” select the “View executable text files” radio dialog button and you’re set!  Now all .txt and similar files that should be “displayed” automatically will.  If you want Nautilus to ask you what to do or to automatically execute text files, you know how and where to tweak that preference now, too!

 

 

Format a Drive From the Command-Line!


[audio: http://validateyourlife.com/vylab/lingeek_20110917_mkfscommand.mp3%5D
Time: 06:27
Edify on the Go!

The bulk of this article is obviously going to be about the mkfs command and all of its awesome 5 options.

For someone who likes 1)CLI and 2)everything related to partitions, hard drives, and the like, this command holds obvious significance and is very dear to me!

  • -V Produces “verbose” output. V for verbose. Verbose just means “detailed” and displaying a lot of system-specific information during the execution of the command. The “-V” option normally isn’t used, but it’s very useful for someone testing/debugging and just those curious about the system interworkings of a command
  • [-t filesystem_type] This is an important option as it enables specification of the filesystem type to be used. Without it, a default filesystem type is used, in linux this is likely ext2 which is pretty useless because even the main linux filesystem is ext4. Plus, one of the best parts of formatting a drive is specifying the file system, so the -t option is an important one.
  • -c A useful safety and security option. I would recommend this option always being used with every implementation of the mkfs command because when you execute mkfs with the -c option you check the drive for bad blocks before building a file system, an excellent and important computer “house-keeping” thing to do!
  • -v Produces verbose output again but I think of the bad-block checking component
  • [-l filename] Reads bad blocks from whatever filename is specified.

Good Links for More Info

http://www.go2linux.org/mkfs-linux-command-line
http://linux.die.net/man/8/mkfs
http://www.cyberciti.biz/faq/howto-format-create-linux-filesystem/

Linuxgeekoid 03 – How to setup Asus 1001p for Ubuntu 10.04

Edify on the Go with Linuxgeekoid Episode Episode 3

Why that OS?

    1. Ubuntu and linux rocks.
    2. 10.10 is flawed, broken, and awful. Ubuntu 10.10 is not suitable for anyone who has a moderate knowledge of computers, an IQ greater than 90, and the desire to accomplish rudimentary things in ways that don’t take 10 seconds to open a folder! 10.10 is broken. I am using a netbook, so have not tinkered with 11.04, it might be (if it reflects it’s delightfully awesome 10.04 counterpart, may be good), quality, but 10.04 is one of the best, fastest, most crisp operating systems with which I have ever worked.

Ultimately, for now (as of July 2011) it’s the best, fastest, and most efficient ubuntu OS (possibly out of all OSes) to run on a netbook (typically <=2gb ram, smaller screen size, typically, slower cpu although there exist some exceptions like the m11x but at the bonus of lightweight portability! Netbooks are still very functional. This entire article was written on the asus netbook of which is the subject of this post, for example. And because the keyboard is so exquisite (I prefer scissor-switch keys to other keyboard types and being an author who’s written over 2.4 million words (roughly 5 times as many key taps!) a good keyboard is important) productivity is increased massively.

This is worth mentioning because some of the hardware adjustments are already taken care in 10.10. If you install 10.10 your wireless works straight-off but hey! You have a deplorably sluggish and flawed OS! Obviously, because I like actually doing the command-line tinkering and learning more about the OS, installing the basic driver(s) and altering grub to adjust brightness is

  • Fun
  • Conducive to productive computational, tech, OS-learning
  • Not a problem in any way especially considering that it means using 10.04 (instead of 10.10), one of the best operating system versions I have used.

Others have used many other operating systems and versions but here’s what I’ve used thus far:

  • Mac OS 6 to 10.6 (every single different change.
  • Windows xp
  • Windows 7
  • (Feisty Fawn; why linux seems to release in a x.04, y.10 fashion seems unnecessary illogical and it would be massively reassuring to comprehend if some logic actually controls that)

A pattern I noticed was that many operating systems got putridly, disturbingly, and infuriatingly “more bloated” as they progressed. By this I mean, they included fancy visual effects and graphics (and rollover buttons) but at the cost of performance and speed. As someone who prefers cli to gui, sacrifing OS speed for some visual graphic is almost tormenting “software abuse’. So that progression was a problem. Anyways, the NBR 10.04 is amazing and suffers from zero of the “bloated os” phenomena.

So here’s how to setup the 1001p

Screen Brightness

Open up terminal (or preferably guake, if you have that nifty terminal-accessing program) and type in:
sudo gedit /etc/default/grub.
Alternatively you could cd to that directory and/or use the gui to navigate through those folders and double-click on the grub text file. But isn’t awesome that you can accomplish all that with a simple 3 part (super-user do, the app, the file path) line of CLI code? Ahh, the joy of linux and geekiness! C’est vraiment.
Next, in /etc/default/grub/ find the line of code (towards the top): GRUB_CMDLINE_LINUX_DEFAULT
Type, copy-paste, and/or add in "ascpi osi=Linux acpi backlight=vendor" to the arguments of that GRUB_CMDLINE_LINUX_DEFAULT line of code.
Finally, update the grand unified boot-loader (grub!) by executing
sudo update-grub2

  • reboot your system

Extrapolation

If you want to understand what"ascpi osi=Linux acpi backlight=vendor". There are some great resources that reveal more details of that code, but something that will get you started is knowing that acpi stands for “Advanced Configuration and Power Interface”. Combined with the backlight-vendor detail, one can deduce that the above code “likely” indicates something like for the hardware to detail monitor brightness variations instead of some other software (like OS possibly).

Wireless

After scouring many many forums and bumbling through a lot of dead ends and people having similar problems and trying commands that didn’t work, ultimately this is the formula:

wget http://linuxwireless.org/download/compat-wireless-2.6/compat-wireless-2.6.tar.bz2
tar xvfj compat-wireless-2.6.tar.bz2
cd compat-wireless-*
./scripts/driver-select ath9k
make
make install
make unload
make wlunload
make btunload
modprobe ath9k

The bz2 actually had a problem with extraction so I just right-clicked in gui and extracted and installed compat-wireless bz2 file and that worked extremely well.

So awesome how quick and efficient can update and install drivers, components, programs, all from command-line. An article on repositories is likely in order and very likely will be the substance content of an upcoming post on linuxgeekoid.

Save Space: Massively Slim down Windows 7 System Partition (to <19gb)

Purpose and Utility

For those who want to keep the Windows 7 System Partition to a minimum (possibly for wanting to conserve and/or use as little hard drive space) keeping Windows 7 system size to less than 19gb (which I have accomplished with, mind you, over 85gb of data media files (docs, photos, video media) (and much more located on internal alternate partitions and an external hard drive), and over 60gb of applications all located on internal hard drive used by the system, but windows works perfectly fine with less than 19gb (18.6gb precisely) and is completely doable with a few space-saving tweaks. I also experience very few “cramped space” issues.

How to Do it

There are many tricks to cut down on system software size, but here is the concise, condensed list that comprises the most helpful and valuable. Basically, this works by utilizing disk cleanup, program files on separate partition, hiberfil.sys deleted, TEMP and TMP relocated, shrinking the recycle bin size, and the user folder relocated to a separate partition.

Get TEMP and TMP off the system partition

The temporary files are used by some programs for (obviously enough) writing data temporarily to the hard drive. Often after a reboot or after the temporary-data-writing program quits, that data is deleted, but nevertheless, the TEMP and TMP folders can balloon in size, shrinking available space on the system partition. Relocating them helps keep the system size to a minimum.

1. Right click on “My Computer” and select “Properties” (this is identical to going to ControlPanel>System).
2. Click on “Advanced System Settings”.
3. Click “Environmental Variables…” (this 1-2-3 should really be called something as it’s the steps necessary to make many advanced system customization changes)!
4. Now simply under “User variables for your_username”, changne the value of the variables TEMP and TMP to a partition (and likely, although this is choosing, but it is recommended for tidyness) and folder of those temp files. If certain programs write a lot to those it will not effect yoru system partition anymore! Excellent! Yippee!

Move the user folder(s) off the system partition

To relocate the individual user folders (like My Documents, for example) this link is helpful. To relocate the entire user folder (C:\Users\this_folder), read on.

    1. Log into a different user account that has administrator privileges (if another user account doesn’t exist other than the one you’re moving, simply create a new user account).
    2. Navigate to and select the user account (typically C:\users\username) you want to move.
    3. Right click that fold and select “Copy”.
    4. Navigate to the new location (ideally on a separate partition or drive), right click, and select “Paste”. That’s it! Extremely simple. And impressive that windows allows such customizations to be made. gnu/linux/ubuntu offers all kinds of these customizations, but Mac OS is usually intolerably locked down, so as usual, windows and gnu/linux ftw.
    5. Now all that is needed to notify the registry of the changed user folder (even thought technically it is already “moved”). Do so, by typing “regedit” in start window.
    6. Next, navigate to the following path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList.
    7. There you will see a bunch of folders starting with (typically) “S-1-5-xxx”, an example of one is S-1-5-21-1608073312-4083020880-3568495165-1000. Click on one (typically one toward the bottom) until under the ProfileImagePath “Name” field, you see under the “Data” field the “C:\Users\username_to_move” username folder that you just copy pasted and that you want to formally move.
    8. Right click on that value, click modify and under the the “Value Data” field update that old file path to the new one (changing C:\Users\username_oldlocation to DriveLetter:\username_newlocation).
    9. Finally to verify a complete and successful move, log out of the temp account, log into the account that was moved, right click on any of the folders in the recently-moved user-folder (like Desktop or Documents or whatever), select Properties and examine the “Location” field. If it shows the location where the folder has just been relocated to, this process is complete!

Additionally, a small bit of house-keeping is to delete the old username folder. Do so by logging out, login under the alternate user account, and navigate to the old location, right click on the old location folder and select “Delete”. Now, completely, all old remnants deleted, new user folder location instantiated.

Shrink the Recycle Bin Maximum Size

This one can be very effective and simple. Obviously, if you always empty the recycle bin after deleting something, this will make little or no difference, but it prevents large recycle bin sizes from accumulating. This is essential for having a compact system.

  1. Simply right click on “Recylce Bin”j.
  2. Click “Properties”.
  3. Under the “Settings for selected location “Custom Size” enter a small value in the Maximum size (MB)” field.

Alternatively, selected the “Remove files immediately when deleted” option ensures that Recycle bin never takes up any space (but files are immediately deleted)! Note, with a shrunken Recycle Bin size, it will be likely that more files you delete will not fit in the recycle bin and thus will be deleted immediately, anyway.

Run Disk Cleanup

This one is self-explanatory and fairly obvious. Simply go to the start menu, type “disk cleanup”, fire up that program, and select anything that is taking up a lot of space and/or you don’t mind deleting.

Uninstall unnecessary programs

Again, to have this properly set up, all your programs should NOT be stored in C:\”Program Files”. Instead, they should be set to install on a separate partition upon installation of each individual program. However, by going to start menu, typing “uninstall a program”, you’re taken to a very useful control panel where you can right click on any program and uninstall it. IF all your programs are on a separate partition, as they should be, then this may make little difference, but it’s still good house-keeping to delete unused programs.

Disable Hibernate and Delete hiberfil.sys

This one is often a HUGE space increase because the C:\hyperfil.sys file usually is equal to your ram size (stored on HD). It’s kind of like linux swap (and prob a separate swap partition should be utilized for it I think, which could be a design flaw in Windows). But nevertheless, running the following code disables the ability for “Allow hybrid sleep” to even occur. Without the computer ever going into hybrid sleep, the hiberfil.sys file (again which is usually, appropriately, the size of physical ram) is unnecessary!

  1. So go to start menu, type cmd.
  2. Right click on cmd and Run as Administrator
  3. Type powerfg -h off and hit Rerturn/Enter.

I love it when succinct code accomplishes a lot and the above code does just that. That command (with the two arguments -h and off) disables the hibernate option and deletes hiberfil.sys, likely freeing up quite a bit of hard drive space on the partition where system is located!

Obvious things

Install all programs on the applications partition. If a program doesn’t let you choose where you want to install it (a preposterous concept), simply do NOT install that program. Only install programs where you decide precisely the install location.

By the way there are other tutorials that detail (20 ways) methods to save space, but some of them make negligible difference and this article focused on the significant ones that free up the most space.

Customize your Open-Source Experience: Thunderbird Compared to Outlook

Tested out outlook and liked a few things about like the vertical layout (all messages and folders 1st column, messages in a folder second column, and then actual message in 3rd column).  This assisted customization of Thunderbird layout to have vertical view (under layout) and this quickly pointed me to the Preferences>Display (it’s slightly different for each operating system) to customize font.  That same link is massively helpful for all kinds of advanced customizations where you change .css files of the program.  An interest, but not my focus now, and outside the scope of this “rudimentary changes” article.  I changed mine to courier 10 because I like small, bland fonts so I can skim over messages quickly and don’t get bogged down.

This post will possibly be added to with additional apps.

Redirecting All Subscriptions from Your Blog to Feedburner

This article is very useful. Feedburner offers some of the best features for:

  • publicizing
  • analyzing subscriptions
  • providing subscriptions

for your blog and/or site.

The main challenges are:

  1. Eliminating pre-existing RSS subscription code.
  2. Creating a Subscribe link Widget
  3. Creating a Subscribe via email box Widget

Eliminating Pre-Existing RSS Subscription Code

  1. Under wordpress admin control panel, go to Appearance>Editor. This pulls up all the .css, .php, and any other “code” sheets for the self-hosted blog.
  2. These will vary for each self-hosted blog, but look for pages like “sidabar” or “footer” or any other place where the pre-built in subscribe rss link may have been coded.
  3. Delete that code. Usually a well-coded self-hosted blog has subscription buttons encapsulated code . That whole chunk of code is safe to delete and doing so will remove previously-existing subscription buttons. This is important because while self-hosted blogs often can redirect to feedburner, usually some problem occurs and it’s best to link to feedburner directly. After you’ve eliminated all pre-existing rss links on the site, you are ready to move onto the next step.

Create A Subscribe via email box Link Widget

  1. Go to http://feedburner.google.com/.
  2. Click on “My Feeds”.
  3. Select your feed.
  4. Select Publicize.
  5. Select Email Subscriptions from the Left Panel.
  6. Copy that HTML code under “Subscription Form Code”
  7. In wordpress create a new widget of type Text/Html.
  8. In that widget, copy the “Subscription Form Code” copied from Feedburner>Publicize>Email Subscriptions.
  9. Place the widget appropriately on your side panel in WordPress.

Create a Subscribe Link Widget

  1. Complete the same steps above except for step #6. Instead of copying “Subscription Form Code” copy “Subscription Link Code”.
  2. Repeat steps 7 and 8.

“Eureka” Computation, More “return” Statement Uses, and String Searches.

Audio Version of This Post

Take a gander at this mini program as it elaborates on our covetted ‘return’ statement:

def find(str,ch):
index=0
while index<len(str):
if str[index] == ch:
return index
index=index+1
return -1

This style of computation is called “eureka” computation because it invovles a search, that when found, stops the function (as in “Eureka” we got it!). The above function searches all characters of the input argument string (passed via argument ‘str’); if it finds the search letter (as indicated by the “ch” argument), it returns it’s string location and exits the function, otherwise it returns -1.

In many ways this is kind of the opposite of the [] operator because if we assign [] to “string”[] with a number of 1, we get the character at that location, or “t”. But our find() function takes a letter and returns it’s string location, numerically. It can intuitively be said that find() (takes letter and returns numerical location) and the [] operator (takes a numerical location and returns the character at that location) are string-related inverses of each other computationally.
Audio Version of This Post
Here’s the same function as above but NOT in “eureka” mode

def find(str,ch):
index=0
while index<len(str):
if str[index] == ch:
print index
index=index+1
return -1

If you input “hello”,”l” in our first “eureka-mode” function (utilizing return statements), the output is:
2

With our second non-eureka function tweak, with the same two input arguments, find() outputs
2
3
-1

The return statement can be utilized in various ways to achieve (usually truncated results, which can be promising and resourceful) eureka-based functions, or the return statement can be neglected for usually more outputs.

def find(str,ch):
index=0
while index<len(str):
if str[index] == ch:
print index
index=index+1
return -1

Lists in Python

Audio Version of this Post

Lists, or what python refers to as a list, is really just what most all other programming languages call “arrays”.

Here are some properties of lists:

  • Lists are mutable.

Unlike strings and tuples, which are immutable, the values at each index of a list can be changed and/or altered. The following example illustrates this:

list2 = [123]

list2[1:3]=[456,789]
print list2
[123,456,789]

So here, the last two indices (1 and 2) were changed from their string values to the three number values. It’s worth noting (for purposes of clarification) that in the above example, the three numbers (or three letters) are considered to be the one single value of that list index.

This shows the mutability of lists.

list2=['abc','def','ghi']
print list2
['abc','def','ghi']
list2[0]=123
print list2
[123,'def','ghi']

In the above example, the element value in the first index (the 0eth element) was changed from abc to 123. Additionally, you can combine the slice operator (illustrated next) to update a range of list values.

    • You can take slices of lists with the listname[startNumIndex:endNumIndex] method. For example. if
      list1 = ['a','b','c','d'] and I wanted just the last two indices, then>print (list1[2:4)
      >[‘c’,’d’]
    • The notation for that took me awhile to comprehend, because of the inclusion of the first 0eth index and the fact that the terminating index always is 1+ the index number. In the above list ‘c’ is indeed the 2eth index, but ‘d’ is the 3eth. The list slice method is non-inclusive for the terminating slice so it’s alwyays one less than that. You can exclude a number altogether as in list1[:2] which would include all the first element values up to the last minus one index. In this case,
      >print list1[:2]
      >['a','b']

      How and why is that? Well, again, omitting the first number means it includes all values up to the second number. In this case, the endNumIndex is 2, but the last number in a slice is always only inclusive to the previous number in the index, meaning it is exclusive to index value 2 (in this instance, ‘c’) and all values after it, so that slice returns the first two values of the list.
    • List elements can be deleted.

      In addition to “nulling” out a single or (with the slice operator) a range of elements, individual (or a range) of elements can be deleted with the del operator.


      >list3 = ["one","two","four"]
      >del list3[2]
      >print list3
      >["one","two"]

      the del command simply deleted the value at index 2 (in this case “four”).

Lists can be cloned.

Cloning a list does not directly involve a special operator nor command, but merely utilizes the slice operator to assign all values of a list to a new list:

>lista=[7,8,9]
>listb=lista[:]
>print listb
>[7,8,9]

And to show that each list is indeed referencing its own distinct set of elements in memory, here’s some sample code testing that out.


lista[2]="nine"
print lista
[7,8,'nine']
print listb
[7,8,9]

Indeed, the two list names, “lista” and “listb”, both point to their own individual set of indexed elements.

Lists can be aliased.
That’s fine and dandy but you may ask “Why not just do lista=listb?” Indeed, that would work in a way.

>lista=[7,8,9]
>listb=lista
>print listb
>[7,8,9]

But here’s where the change is apparent

>lista[1]=9000
>print lista
>[7,9000,9]
>print listb
>[7,9000,9]

That’s actually aliasing the list and superficially has the same result/appearance, but overall “aliasing” is different from “cloning”. A cloned list has it’s own unique set of elements, whereas two aliased lists share the same list of elements in memory. Ultimately the main difference between aliasing and cloning a list is that if you change the elements of an aliased list, it reflects in the other list, whereas changes to elements of one list do not effect the cloned list. Conclusively, aliased lists share one set of indexed elements whereas cloned lists each have their own unique set of indices and elements.

Another side note, if you redefine a list, it breaks any lists aliased to it, so:

>lista=[7,8,9]
>listb=lista
>print listb
>[7,8,9]
>lista=['seven','eight','nine']
print listb
[7,8,9]
print lista
['seven','eight','nine']

In the above code snippet, lista and listb are first aliased to each other, sharing the same index (of [7,8,9]), but then lista is reassigned to a new list; lista is said to be “initialized” (or, in this case, re-initialized). The result is the aliased nature of lista and listb are broken and then each list has its own set of elements.

    • A list can be nested.

      This is where things get slightly complex. A nested list can actually be assigned to one index of a pre-existing list. In other words, an entire list can be “one” element if it is assigned as such.

      listnest=["letters","numbers",[7,2,3.22]]
      print listnest
      ['letters','numbers',[7,2,3.22]]
      print listnest[2]
      [7,2,3.22]

      Here the 2eth index or third element of the listnest was actually an entirely additional list that contained three elements. When just the 2eth index (third element) is printed out the full nested list (composed of two ints and a float) returns.

      You can call a single element from a nested list by using double index call brackets []:


      listnest[2][2]
      3.22

      Matrices (a subset of ‘Lists can be nested’).
      Assigning a “matrix” to a list is really just using multiple nested lists. The only way in which a list actually resembles a matrix of elements is via nested lists. So to instantiate a “matrix” (really just multiple nested lists) one would use the following code.


      >>> matrixlist=[[1,2,3],['one','two','three'],['uno','dos','tres']]
      >>> matrixlist[2][2]
      'tres'
      >>> matrixlist[0][1]
      2

      One important thing to remember is that although the lists are nested, they’re considered each just a normal element and thus they require a comma separating them. If you try to implement

      >>> matrixlist=[[1,2,3]['one','two','three']['uno','dos','tres']]

      You will get a syntax error.

Lists can be combined with string functions (the magical fusion of lists and strings).

One string (module) to rule them, one string module to bind them (and separate them).
Okay going to town with cheesy puns of the string module.

Strings, if you recall, are immutable. But lists are not; lists are mutable. Using some (these are referencing only python 2.7) built-in functions of the string module, we can do some interesting things with strings.

Separate them (with an optional delimeter)
>>> import string
>>> song="Deck the halls with bows of holly"
>>> string.split(song)
['Deck', 'the', 'halls', 'with', 'bows', 'of', 'holly']
>>> songlist=string.split(song,"h")
>>> songlist
['Deck t', 'e ', 'alls wit', ' bows of ', 'olly']

Okay that may need some explaining.

      1. Line one imports the string module.
      2. Line two merely assigns a string (in this case 7 words of a lyric) to a variable.
      3. The third line splits those words using the default delimeter which is a space and returns the resulting list, consisting now of 7 elements.
      4. The fourth line splits the original variable “song” into a list of 5 elements, but the delimeter is now (with funky results) an “h”. This list is stored in the variable songlist. It’s useful to observe that by choosing a certain delimeter, you automatically eliminate that delimeter from the list of a “splitted” string.

Join them (with an optional delimeter)
song=”Deck the halls with bows of holly”
>>> string.join(song,"h")
'Dhehchkh hthhheh hhhahlhlhsh hwhihthhh hbhohwhsh hohfh hhhohlhlhy'
>>> string.join(song,"_")
'D_e_c_k_ _t_h_e_ _h_a_l_l_s_ _w_i_t_h_ _b_o_w_s_ _o_f_ _h_o_l_l_y'
>>> splitsong=string.split(song)
>>> string.join(splitsong,"___")
'Deck___the___halls___with___bows___of___holly'
>>>

Okay the first and second calls of string.join() joins the elements of the list with, respectively, the letter “h” and an underscore “_”. However, remember that strings are considered immutable lists (that have indices) of characters? Well, the original “song” string value was never stored and split, so string.join() looked at each individual letter of the string as a separate element! Before the third call of string.join() the “song” string has been split (with the default space delimeter) into a list of 7 elements (called splitsong) so now each of those seven elements (words previously separated via a space) are joined with the triple underscore delimeter “___”. Fa la la la la, la la la la. Jolly good!

Why Is this Important Again?

It’s important to be cognizant of which lists alias each other, when a list is re-initialized, and when a list is cloned (and thus possessing it’s own set of elements and indices) because all those different code situations change each list and corresponding indices differently depending on the aliased, cloned, or re-initialized situation!

See, aliased lists (like all lists) are indeed mutable, and here the second element at the 1eth index was changed from 8 to 9000 in lista, but since the lists are not cloned, but aliased, the same change (1eth element changed from 8 to 9000) reflected in listb. Aliased lists are the same list with different names. They point to the same index of elements in memory however. This is a subtle (but with more advanced programs), useful clarifying distinction.

Works Used
Downey and Meyers. How to Think Like a Computer Scientist.

Evaluating Differences Between Python 2.7 and Python 3.2

The python site details all the major differences bewteen versions. The really significant ones are the differences between python 2 and 3 in full detail, so if you’re deciding whether to work in python 3.0 or 3.1 or another version, it would be wise to check those out. Here’s a well-written evaluation of the major differences between 2 and 3, describing 2 and 3, respectively as:

Python 2.x is the status quo, Python 3.x is the shiny new thing.

While I’m not certain if programmers trying to run 2.x code in 3.x and getting syntax and runtime errors would consider that “upgrade” “shiny”, the language changes are in some ways significant and in other ways, trivial. I’ll present a small number of (fairly significant) changes that I’ve noticed here.

First off, one of the biggest is
print
The print command is now a function and in 3.2 must be coded as
or else the interpretor will throw an error.

print "word"
worked fine in 2.7, but throws and error in 3.2.

Then there are a bunch of smaller nuance things.

For example in 2.7:

>range(10)
>[0,1,2,3,4,5,6,7,8,9]

But in 3.2, the range() function still works, but has a different way of displaying the result, namely, using upper and lower bounds:

>range(10)
>range(0,10)

commands like

string.find()

in 2.7 have been changed in 3.2 as well.

There are many more minor and major significant changes but trying to run 2.7 code with a 3.2 interpretor/compiler will almost certainly result in a series of runtime and syntax errors. I’ve attempted doing some code-learning in a seperate 3.2 file. I have a compsci_func.py file that I use to practice and write functions. The one that was coded in 2.7 generates an error practically every 3-4 lines if I try to interpret it via 3.2. While coding in 3.2 is interesting, most material is typically written for 2.7 (so for example, examples in books cease to functionally work if using 3.2), and 2.7 code throws errors, I’ll likely do most coding in 2.7. At the very least, it’s important to note that 3.2 requires practically a fresh .py and/or fresh set of functions because of the multitude of nuanced minor or trivial and major (like the print() function) changes to the language.

The Immutability of Strings

Strings in python are immutable. You cannot change them. The most you can do is with a pre-existing string assigned to, for example, var1 is:

  • use the array [] operator to present a slice of the string as in:
    var1 = "bookworm"
    var1[1:]

    OUTPUT
    'ookworm'

  • simply re-assign the variable to a different string

That immutability may seem annoying, but, in practice and functionality, it’s quite convenient and pretty useful because you know unless the variable is reassigned, that string (assigned to a variable or just existing) will always be, simply that same string!

string.whitespace

This utilizes the built-in whitespace function from the string module. This one is fun and moderately useful. string.whitespace uses all the whitespace commands (\n and \t, respectively, newline and tab). So what really looks like two lines if you append a string to that command as in:

print string.whitespace,"hello"

OUTPUT

"hello"

the output is newline and tab.

Permanently Installing Python

There exist three ways to “install” or at least work with python: through just the interpretor (IDLE), from a temporary path to the python interpretor, and permanent path.

It’s important to know at least one (ideally all, however) of these ways. I consider setting up the permanent path to python the most useful because without that upon each reboot your IDEs or python command-lines will not compile/interpret nor execute (because the system processes will not know where to find python)! Thus I recommend permanently adding the path to python.

Using Interpretor Applicaiton

Simple download and open “IDLE (Python GUI)” the application. And you can start using python code from that command line. This is limited to this application though. Useful for a handy calculator, debugging or quickly testing something out in python, but nearly impossible to utilize for/with making any moderately sizes function, set of functions, or mini program.

The IDLE interpretor is brilliantly handy but it’s not sufficient for writing, debugging, and executing anything larger than a very, very small mini function or two.

Temporary PATH to Python

You accomplish this method via two steps:

  1. Locate the source folder of python. Usually this is on “C:\” and called “Python” + your version of python, so somethingly like C:\Python27 or C:\Python26 or C:\Python32 or something like that would be the path of python. Whatever path you get from this step we’ll refer to as “mypythonpath” for the next step.
  2. Simply run the command:
    set path=mypythonpath

    So depending on what your python path is, this could be
    set path=C:\Python27

What are those commands doing? “path” is the variable that holds the location of commands. Any major operating system has (usually multiple) locations for the source of commands. Without “mypythonpath” added to the list of folders where the command line interface looks to execute commands, it will have no idea what “python” is (and communicates this perplexion with something like
python' is not recognized as an internal or external command,
operable program or batch file.

So by adding the python location to the “path” variable, the operating system can then sort of be like “Oh THAT python”, find the location of python, and execute and/or compile/interpret what it needs to!

Permanent PATH to Python.

This is identical in outcome to the previous method (temporary path) except that it lasts through infinite reboots. The moment you reboot using the previous method, you’ll have to reset the python path. This remedies that so that ptyhon is accessible for interpreting/cli/compiling/executing all the time.

These sequential steps couldn’t be more succinct, helpful, and accurate, so I included them directly from an external source.

  1. press Start
  2. select Control Panel
  3. On the Control Panel window, in the left column, press Switch to classic view (If you don’t see this text, go to the next step below.)
  4. Double click on the icon for System
  5. In the System window, click on Advanced
  6. Click on the button Environment Variables
  7. In the new window, scroll until you see the variable, Path; click on it
  8. Press Edit
  9. Carefully use the right arrow button to move to the end of the long sequence of folder names. At the very end, without including any extra blanks, type this:

    ;C:\Python24

— from a ksu.edu site

Successfully Booting and Installing Linux from a Flash or SD Card

This is a useful procedure to know how to do (to avoid CD/DVDs). If you have a netbook without a CD/DVD-rom drive, this is your only option for installing or re-installing any operating system.

Ingredients:

Procedure:

  1. Acquire the Proper Ubuntu OS Version. Download the appropriate version of ubuntu. If you consider an alternative download version, take care to consider the pros and cons of a netbook version (more compact but limited compared to the full desktop version), and an older (outdated by usually more stable) and newer (more up-to-date, but can be decidedly less stable) OS version. It often can be a challenge and necessary trial-and-error process to see which version is most compatible with your hardware. Almost always, however, at least one ubuntu version will successfully boot.
  2. Get Ubuntu Installed on the Flash Drive (or SD Card). Download and use the universal linux installer. This installer pairs the .iso downloaded from the previous step to the destination flash or sd drive letter. Ensure that you select the correct letter drive! This installs “wubi” (Windows-Based Ubuntu Installer) onto the destination drive, if you run the Universal USB Installer from windows. IF you run it from linux, it unstalls, the appropriately abbreviated lubi (and a mac-os rubbish-based installer will be called mubi).
    • IMPORTANT: Trouble-shooting the Installation (if necessary, if not, skip to step 4). You may get a Data error in 'casper\filesystem.squashfs'. File is broken. error. I encountered this and it is quite a common diagnostic error when installing. That error indicates one of two things: 1)the installation failed due to the installer or 2)the installation failed due to a corrupt .iso. Thus, solutions are using a different installer (instead of universal linux installer), like unetbootin or for the second cause of the failed installation, redownloading the .iso from a mirror site or downloading a different version of the .iso. TL;DR, if you get the aforementioned error, your installer is causing problems and/or the .iso; use alternate sources for whichever is causing the problem. Solution Synopsis: Experiencing the aforementioned error during installation will, however, make booting from that destination drive impossible, so this must be resolved to successfully install from an external drive by using a different .iso or a different install (unetbootin installer of universal linux installer). This is irrelevant to your installation details, but after various .isos from various sources, I avoided the aforementioned error by installing netbook-remix 10.10 onto a FAT32 pre-formatted 2gb usb drive using universal linux installer (the cause of the error for me had been a corrupt .iso or simply a .iso not compatible with the drive and/or installer). Again, this may be irrelevant to your situation but often hearing what other people attempted can often help resolve one’s own challenges, so I properly documented those attempts (the destination drive on all of these was the FAT32 pre-formatted 2GB flash drive):
    • Installer: Universal Linux Installer.
      iso: ubuntu-10.04.2-desktop-amd64.
      Result: Failure. The Data error in 'casper\filesystem.squashfs'. File is broken. error.
      Diagnosis: Could be the 64-bit version or a corrupt .iso. The installer worked with another .iso, so it is unlikely for the installer to be the cause of the problem.
    • Installer: Universal Linux Installer.
      iso:ubuntu-11.04-desktop-i386.
      Result: Failure. The Data error in 'casper\filesystem.squashfs'. File is broken. error.
      Diagnosis: Could be the 64-bit version or a corrupt .iso. The installer worked with another .iso, so it is unlikely for the installer to be the cause of the problem.

      Notes: It’s impossible to discern if the .iso was corrupt, incompatible with the USB drive, or some other problem without further diagnostics, so this report suffices as is, especially considering that one version (all that is needed) succeeded.

    • Installer: Universal Linux Installer.
      iso: ubuntu-10.10-netbook-i386
      Result: Success.

      Notes: I had wanted to experiment with installing a full desktop (non-netbook-remix) version, but this suffices.

  3. Boot off the flash/sd drive and Install.Upon successfully making a bootable USB drive (or flash sd card), now you can boot off that and install your operating system. Partitioning is covered here. Don’t forget to include a partiton for swap space, which should on average be equal to your current physical RAM and is useful for things like RAM memory hibernation and unforeseen scenarios or shortage of actual physical RAM.

The Complex Stuff: Drivers, and Individual Hardware Compatibility

It would be preposterous, ridiculous, and unnecesary for me to document variety of computer hardware versions when that is already documented elsewhere, so all of these tweaks and installations are from installing ubuntu VERSION onto an asus 1001p netbook. Again, your situation (hardware and OS version) will likely be different, but you can likely see what you may encounter (and this obviously is incredibly useful for anyone installing said OS onto said hardware).

TL;DR All of these tweaks refer to ubuntu VERSION on asus 1001p. I may update that and include different and OS version if that becomes important, which is unlikely.

Brightness
The brightness adjusts sporadically instead of progressionally (meaning brightness 2 is brighter than 7 and then 8 may be the brightest and then 9 is not bright), so to avoid having a frequently dim screen, adjusting this is important.

The steps for resolving this are:

  1. Run “sudo gedit etc/default/grub from terminal. Some tutorials leave out the “sudo”, a fatal problem because without superuser privileges, the file is uneditable.
  2. Change GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” to GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash acpi_osi=Linux acpi_backlight=vendor”.
  3. Run sudo update-grub
  4. Restart.