"Reboot Even If System Utterly Broken"

I've had some system instability on my laptop for the first time in ages, and had to recall a trick I learned several years back. On a linux machine, even if everything else is entirely locked up, one can safely reboot. The gist is, by using the Magic SysRq key you can force low-level commands in. This consists, on my laptop at least, of holding left alt and the print screen key down while typing out the letters REISUB, with the mnemonic "Reboot Even If System Utterly Broken". Personally, I think about the store REI and submarines. Each letter sends a specific command, namely:

  • R - This takes the keyboard input away from the X session
  • E - Sends SigTerm to all processes, asking them nicely to shutdown
  • I - Sends SigKill to all processes, forcing them to shutdown
  • S - Syncs all changes to disk
  • U - Unmounts all file systems
  • B - Reboots the machine

With all the processes stopped, all changes written to disk, and all file systems unmounted, there is no risk of file system corruption when rebooting with this method. If you follow the link above you can see that there are a good many things you can do with the Magic SysRq key, even intentionally initiate a system crash, but the sequence above seems to be the single most useful.

HP Laserjet P1606dn on Ubuntu 12.04

Today I had a large batch of papers to print and decided that duplex would save a lot on paper and heft, however the driver I had set up for the office networked printer did not support duplexing. I went down a bit of a rabbit hole trying to get everything working, so I'm going to lay out the final process below.

  1. Determine the IP address of the printer. This can be done by holding down the green "ok" button for several seconds causing it to print the status page.
  2. Install hplip through your package manager or just "sudo apt-get install hplip"
  3. Run hp-setup from bash. Choose Network/Ethernet/Wireless and under Show Advanced Options check the Manual Discovery box and type the IP address in the box next to it.
  4. The next screen should show one entry for your printer, if it does not then either the IP is incorrect or other network issues are present. Assuming it's there, simply click next.
  5. It will download the HP driver for it (the one that doesn't duplex, strangely) and will have you provide a description, location, etc.
  6. After the wizard closes, open the System shortcut through unity. From here open up Printing.
  7. Your newly added printer will be in the list, right click and go to Properties.
  8. In the window this opens, there should be a line for "Make and Model", click the button next to it that says "Change..."
  9. At this point it will search for drivers, go ahead and cancel this and select "Provide a PPD file".
  10. Now is a good time to grab the file for the OpenPrinting.org. Just look for "directly download PPD" and make sure the file name is "Generic-PCL_5e_Printer-hpijs-pcl5e.ppd". Feed this file to the previously opened window.
  11. With that driver chosen, under "Printer Options" in the printer properties window you can now set an option for Double Sided Printing. Choose "Long edge (standard)".
  12. Print away, it should finally work. I did end up restarting CUPS a few times (using sudo stop cups and sudo start cups at the terminal).

 

Best of luck with this demon machine, leave additional confusion in the comments.

Christmas Recipes

At my annual Christmas shindig I provided a few treats to the friends that could make it, and there was some interest in getting the recipes. I'll give a quick run-down for two of them here, namely the chocolate mousse and spiced cider. The chocolate mouse was adapted from The Joy Baking by Barbara Grunes, while the cider was modified from the food.com recipe for Marley's Mulled Cider. I know the steps outlined below might be overly specific, but this post will serve as a future reference for myself as well.

Chocolate Mousse - Makes 4 servings
Nutrition per serving

Calories Carbs (g) Fat (g) Protein (g) Sodium (mg) Sugar (g)
349 18 29 6 96 13

Ingredients

  • 4 oz (1/2 cup) of bittersweet chocolate chips (one can substitute butterscotch chips or any other candy that melts entirely)
  • 2 tbsp of butter
  • 2 eggs, separated
  • 3 tbsp white sugar
  • 1/2 tsp vanilla extract
  • 1/2 cup heavy whipping cream

Procedure

  1. Set out three bowls. Use hot water from the sink to raise the temperature of the first bowl as much as possible, and then dry it off and quickly add the chocolate and butter. If the residual heat is not enough to melt it together, microwave for 20-30 seconds, it's very easy to burn it at this point.
  2. Once melted, thoroughly mix the chocolate and butter together with a spoon or spatula. Place the bowl in the refrigerator and let it cool.
  3. In the second bowl, crack two eggs and separate out the yolks, I use a slotted spoon. It is critical to not get yolk in the whites, as the presence of fat will entirely prevent them from being whipped up correctly by breaking the surface tension on the tiny bubbles. Keeping the whites in this second bowl, add the yolks to the first bowl containing the chocolate and butter and mix them in completely. Return that bowl to the fridge.
  4. In the bowl containing the whites add two tablespoons of sugar and mix very thoroughly, until the whites are bubbly. I use a handheld electronic mixer as it takes a lot of effort to whip them enough by hand. This step does much to determine the consistency of the final product.
  5. In the third bowl use a mixer to whip up the whipping cream, vanilla extract, and remaining one tablespoon of sugar. Again,  mix until thick. My indicator is when the cream retains wrinkles on the surface surrounding the point of mixing.
  6. Take the first bowl out of the fridge and gradually mix in the contents of the second bowl. Then fold in the whipped cream and mix until completely homogeneous.
  7. Pour into 4-5 serving glasses and place in fridge for at least an hour, but up to 24 hours. Longer setting time will produce a firmer and less 'soupy' mousse.

Spiced Cider - Makes 8 servings

Nutrition per serving

Calories Carbs (g) Fat (g) Protein (g) Sodium (mg) Sugar (g)
230 55 0 0 58 55

Ingredients

  • 3 quarts apple cider
  • 1/2 cup brown sugar
  • 1/2 teaspoon whole cloves
  • 1/2 teaspoon whole allspice
  • 2 cinnamon sticks
  • 1 sliced orange
  • 1 dash salt
  • 1 dash ground nutmeg

Procedure

  • Put everything on the list in the crockpot or slow cooker.
  • Set it to low for 6-8 hours. By the end the cinnamon sticks should have rehydrated and 'unfurled' quite a bit.
  • Serve directly into mugs. Add rum if desired (not included in the numbers above, a shot of rum adds 105 calories).

Ceramics at home: Slip casting mugs

Having had brief exposure to the concept of slip casting in MSE classes years ago, I decided to make some mugs as Christmas gifts using a mold I'd acquired years back. The process was fairly straightforward as I chose probably the laziest and most repeatable approach to forming ceramic objects. The first step was acquiring the slip, glazes, rubber bands, and a sturdy bucket. All together this totaled about $20 between Marjon Ceramics and Ace hardware. I went with low-fire slip on their advice, specifically because ceramic slip suffers substantially more shrinkage on firing (about 1/3 shrinkage compared to 1/15 for low-fire slip).

Mold with rubber bands
Mold with rubber bands

The mold was banded together after a few minutes or sorting out the best way to do that (the single vertical band required rotating the mold pieces and bracing them with books on both sides while I lowered the band on a bit at a time). The slip was well agitated then poured and allowed to deposit for about 30-35 minutes, which turned out to be a little less time than I should have allowed. The excess was poured into the bucket and allowed to drain at an angle for several minutes. This was then transferred back to into the jug using a funnel. A knife was used to trim off the sprue (excess lip).

Mold with deposited clay
Mold with deposited clay

 

It took about two hours for the deposited clay to release from the mold. At that point the mold was carefully removed from the clay, being very careful not to dent nor gouge the soft clay.

Freshly cast mug
Freshly cast mug

The mug was left in front of a small floor fan over night to drive off the excess water. The next morning, using a wet paper towel, the flash, seams, and rim were smoothed out. Once I had all four of them complete and dried, I packed them up very carefully and made the trip back to Marjon to get them fired. They were able to get them done quickly, taking about two days to bisque fire.

Carefully packed bone-dry mugs
Carefully packed bone-dry mugs

After the bisque fire they took on a flat off-white color and much smoother texture. I applied two coats of glaze to every surface, choosing different colors for the different mugs. While the outside surfaces were brushed on, the interior surfaces were rolled on; that is, the glaze was poured in and the vessel rotated to produce a good coating of all the surfaces.

Bisque fired mug
Bisque fired mug

Once glazed there were handed back over to Marjon for the final firing cycle. Two days later I stopped by and picked up the mugs, just in time for the Christmas party too.

Finished mugs, side view
Finished mugs, side view

The resulting mugs were a bit thin, so if I try this again (and I probably will, given how much leftover slip I have) I'd likely increase the slip time from 30-35 minutes to 45-55 minutes to produce heftier mugs and spend more time cleaning up the seams, which ended up being really apparent in the finished pieces due to variations in glaze thickness. Also I would consider more detailed glazing methods or use of ceramic decals to put designs on them. As a first foray into making ceramics at home, I'd call it a success.

Less than quiet times

I only wish things were as quiet as the inactivity here would normally suggest. Coursework and research has conspired to keep me busy lately, so I haven't had the opportunity to write up any updates. I've had projects that I would have liked to write up come and go; hopefully I'll find time for them once classes end and I've got some space to breath. As I despise posts without content: did you know the entire 6-episode run of Police Squad (imagine an extra 3 hours of sight-gags al la Airplane or Naked Gun) is on YouTube these days? It made my day.

I should be making a fair few gifts this Christmas, and if I have the presence of mind to snap a few photos I may post about those.

Communicating Scientific Results in LaTeX

Communicating Scientific Results in LaTeX [tex, bib] [pdf]

I recently gave a short 15-minute presentation as part of the Optical Sciences 2013 Community Speakers series on ways to extend the usefulness of LaTeX to improve communication. This was given alongside another presentation focusing on what LaTeX is and how to get starting using it, so I veered into topics perhaps more interesting to an already-initiated audience. I included concrete step-by-step instructions on getting started with Beamer and BibTeX, as well as cursory (and flashy) examples of chemfig and pgfplots with generating code presented side-by-side.

Jones Vectors and Visualizing Polarization

I recently had an assignment wherein I was presented with a handful of polarization states and asked to estimate the Jones vector for each one. Usually this isn't so bad, as there is only so much variation between linear, elliptical, and circular, however they also asked that I add the appropriate phase such to have the vector indicate a specific point in the trajectory. I spent some time thinking it through, but did finally decide to spend a bit of time writing a program to check my answers. Parametric plotting in Python turned out to be trivial, so it went quick. The result of that is this script, which creates two functions. One of them, jones_plot(), will take in a two-element Jones vector and generate a 2D plot of the trajectory of the tip of the electric field vector. That is, circular polarization will draw graphs of circles, and so on. The second of them, jones_check(), takes in the same Jones vector, but returns a string describing the nature of the polarization.


jones_check([exp(-1j*pi/2), -0.5j])
=> 'Linear polarization at 26.565051 degrees CCW from x-axis'
jones_check([exp(-1j*pi/4), -0.5j])
=> 'Right elliptical polarization, rotated with respect to the axes'

 

The jones_plot() output for [ exp(-1j*pi/4), -0.5j ]
The jones_plot() output for [ exp(-1j*pi/4), -0.5j ]. Red dot indicates phase = 0, green dot indicates phase = pi/5
The code is probably not bullet-proof, but it provided a good means for practicing manipulating the vectors and understanding how to interpret them. For the curious, the sign convention used is decreasing phase in the style of Hecht's Optics 4th edition.

LaTeX Header Files: Making Life Slightly Easier

I compose a lot of documents in LaTeX. Homeworks, course notes, personal records, and meeting minutes all get typed up in TeX at some point. While the majority of the commands are quick to learn and easy to use, there are a few cases that popped up again and again that took a non-trivial amount of time either to type or to remind myself how it was done. Accordingly, some time around two years ago I started putting together a header file that I could include at the top of a document via \input{../physics_header.tex}, and it would take care of the majority of the packages and the like. While one can argue that I shouldn't have a bunch of packages included when I don't need them, the compile time is essentially negligible compared to the 3-second headache of having to go back and add "\includepackage{graphicx}" every time I want to add an image to a document.

After a bit I realized it was an ideal place to store my oft used, as well as my not-so-oft used, custom commands. I ended up bringing together the majority of the custom commands I'd written so far and organizing them by category. They mostly covered vector calculus, matrices, and quantum mechanics notation. I encourage you to take a look at the PDF I've put together regarding the commands, and if they're useful to you, grabbing a copy of my header and taking the useful bits for your own. Given that LaTeX allows me to include symlinked files, it's been very easy to sync the header across systems with Dropbox and continue using my commands everywhere.

That all being said, I have been cautioned about getting too comfortable with custom commands, as some academic journals that accept TeX files for compilation on their end aren't especially fond of them. It hasn't been an issue for me yet, but if it ever is I imagine writing a quick script to un-shorthand all of these things would be quick.

WordPress Upgrade Headaches

WordPress prompted me to update to the latest version, and of course I figured nothing would go wrong. The update ran well enough, but I was totally unable to access the back-end of the website afterward. The process was running out of memory. I discovered that my host, NearlyFreeSpeech.net limit the amount of memory for each PHP process to 32MB unless you pay an extra fee. It's not much to get it bumped up to 64MB, only a few cents a day, but I always prefer the cheaper option. I was able to regain access to the admin panel by renaming the folder /wp-content/plugins to /wp-content/plugins.old, which prevented them from being loaded.

In the mean time I also went ahead and installed W3 Total Cache and, in doing so, ran headlong into another problem. It seems the 'tmp' folder created by the installation script does not belong to the same user as my FTP account, so even with permissions set to crazy (777) I was unable to save any settings. I had enough privileges to rename it and create a new 'tmp' folder, which ironed out the problem. Hopefully the site is running a little faster for everyone as a result.