Category Archives: Programming

Book Review – Superintelligence

Superintelligence: Paths, Dangers, Strategies
by Nick Bostrom, 2014

When the book chooses to include a jacket blurb that says “A damn hard read” by the Sunday Telegraph, you know they’re not screwing around. Definitely reads like a lengthy academic paper (260 main text pages). Covers the paths to a machine intelligence takeoff and possible efforts to control or shape such a future. Basically, a super intelligent machine or being will have motivations and capabilities that are hard to control, and if we don’t tackle the control problem before the intelligence takes off, we’re all doomed.

I like the closing paragraphs:

Before the prospect of an intelligence explosion, we humans are like small children playing with a bomb. Such is the mismatch between the power of our plaything and the immaturity of our conduct. Superintelligence is a challenge for which we are not ready now and will not be ready for a long time. We have little idea when the detonation will occur, though if we hold the device to our ear we can hear a faint ticking sound.

For a child with an undetonated bomb in its hands, a sesible thing to do would be to put it down gently, quickly back out the room, and contact the nearest adult. Yet what we have here is not one child but many, each with access to an independent trigger mechanism. The chances that we will all find the sese to put down the dangerous stuff seem almost negligible. Some little idiot is bound to press the ignite button just to see what happens.

Nor can we attain safety by running away, for the blast of an intelligence explosion would bring down the entire firmament. Nor is there a grown-up in sight.

In this situation, any felling of gee-wiz exhilaration would be out of place. Consternation and fear would be closer to the mark; but the most appropriate attitude may be a bitter determination to be as competent as we can, much as if we were preparing for a difficult exam that will either realize our dreams or obliterate them.

This is not a prescription of fanaticism. The intelligence explosion might still be many decades off in the future. moreover, the challenge we face is, in part, to hold on to our humanity: to maintain our groundedness, common sense, and good-humored decency even in the teeth of this most unnatural and inhuman problem. We need to bring all our human resourcefulness to bear on its solution.

Yet let us not lose track of what is globally significant. Through the fog of everyday trivialities, we can perceive – if but dimly – the essential task of our age. In this book, we have attempted to discern a little more feature in what is otherwise still a relatively amorphous and negatively defined vision – one that presents as our principal moral priority (at least from an impersonal and secular perspective) the reduction of existential risk and the attainment of a civilizational trajectory that leads to a compassionate and jubilant use of humanity’s cosmic endowment.

Book Review- The Soul of a New Machine

The Soul of a New Machine
by Tracy Kidder, 1981

soul of a new machine

Maria has her students read this book in Computer Systems class. So I decided to read it. It certainly provides good insight into hardware/software engineers. How they act. Their temperaments. Their biases. Their need for ‘interesting’ or ‘creative’ work and their willingness to reinvent the wheel so that it can be created ‘here’. Having played a similar role at my job, I can say that the depiction is pretty accurate. The 35 year old book is still relevant today.

That being said, one of my least favorite things in the world is to read other people’s code. A short logic jump would say that I don’t particularly like to debug or help people debug. As such, reading about other people debugging was not my favorite subject matter ever.

The story focuses upon a new 32-bit microcomputer being built at Data General. Tracy Kidder became embedded in the development group and followed their actions for about 1-2 years. Data General declined in the 80’s and was bought by EMC in 1999. A more recent version of ‘writer gets embedded with development team’ is Scott Rosenburg’s Dreaming in Code.

Saving Details from Research Papers You’ve Read

I read 212 research papers in the 12 months following June 2014. Some were for coursework. Some were for research. Some were just because I felt like it.

database screenshot

As anyone who knows me will tell you, my memory for details is not very good. I’m more of a big picture person. So I worry that I won’t retain much from this giant expenditure of time in reading research papers.

I’d like to describe my current system for saving information from research papers for later use. I have a few use cases for this effort:
Use Case 1: Upon writing a research paper, I want to know which papers I’ve read about the topic so that the literature review moves more smoothly.
Use Case 2: When I go to interview for a job at a university, I’d like to know which papers I’ve read from the faculty there. This may provide opening discussion topics.
Use Case 3: I’d like to save my ideas for follow-up actions (after reading papers) in one place.
Use Case 4: When topics in diverse fields reference the same topic, I’d like to be the person to connect the fields.

Last year, I saved the first page of every research paper I read in a binder with my hand-written notes on the first page. This provides a form of storage, but it is not at all searchable or cross-reference-able.

This year, I designed a template that contains all the information about a paper that I want to save. I then designed an import process to port this information from the template (text document) to a database that I can query easily. Here is my process for that, including code and database setup:
1. Install MySQL ( locally on your most-used computer.
2. Create a database called “papers_read”.
3. Run the code in the attached files to create your database tables (The code is attached here as .txt because my website doesn’t allow me up to upload .sql. Just fix the extension so it is “.sql”): papers, authors, keywords, and notes.
4. Create a folder on your computer called “Paper Notes to Upload”. Put the following template file in the folder: template.
5. Install Python and the related library MySQLdb.
6. Save this Python code wherever you save your code: addNewFromTemplate (again, the extension has been changed to .txt for security reasons. Rename to .py). Update the “folder_to_add” directory in the code to point to the folder you created in step 4.

Now, whenever you read a paper:
A. Fill out the template with the paper details, and save the text file as something OTHER than ‘template.txt’ in the folder created in step 4.
B. When it is convenient (there may be multiple files to upload in the “Paper Notes to Upload” folder), run the Python code. This will upload your notes to the database.
C. Move the paper notes out of “Paper Notes to Upload” folder after uploading. If you run the code again with them still in the folder, they will be uploaded again.

Some notes on the template:
-Do not use colons in any of the fields you save, as the code uses colons to parse the document. If the title of the paper has a colon in it, use a comma instead.
-I grab the number of citations from Google Scholar by searching for the title of the paper.
-“Comma-separated Keywords” is for you to list the keywords in the paper, with a comma between each.
-In the authors section, be sure to delete any extra/unused author spaces. Feel free to add more if necessary, following the pattern of the first 6.
-Under Reading Details, the Hours to Read is how long it took you to read the paper in hours (can be decimal). The Not Read is a place to list sections/pages not read. The Skimmed is a place to list sections/pages quickly skimmed for which another read would be necessary to understand all the details. Reason Read is a reminder of why you read the paper. Methodology Used lets you list the methods used in the paper (i.e. survey, lab experiment, mathematical model, optimization, etc.), if that is relevant to your work.
-Under My Notes, “Keywords for me” lets you list more keywords that the paper did not list itself (comma-separated, again). FollowUp lets you list actions that should be done after reading the paper. Note1 through Note5 let you list notes to yourself about the paper. Limit each note to 200 characters and do not add more. No need to delete unused notes.

I hope this helps. It’s the process I use. Feel free to alter to fit your needs. Let me know if you use it and if you have any questions. All the code is my own and it is fairly fragile (but works for me); feel free to let me know if you have issues or a better solution.

Code Monkey Monday- Cropping Images in LaTeX

Suppose you have an image that you wish to insert into your LaTeX document or presentation. You can crop the image to your specifications prior to saving and importing it, using your favorite image editing software. Or you can crop it on import, with the following syntax:

\includegraphics[trim=1cm 2cm 1cm 2cm,clip,width=1in]{imageName}

The trim command takes the specified amount off of the left, bottom, right, and top of the image, respectively. The width command tells LaTeX how big to make the image in print, scaling it up or down as necessary.

Code Monkey Monday- Hiding Excel Equations in Cells

This isn’t a particularly high-tech post, but it helped me out in tricking innocent bystanders of a cell’s true intention. Suppose you are using Excel and want to show someone a nonsensical output from a cell evaluation. You type in something innocuous, like =rand(), which should give a random number between 0 and 1. If you want the “random” number to always be between .5 and .75, however, you could type =rand()*.25+.5. In my case, I wanted to show someone the equation “=rand()” but the output from “=rand()*.25+.5”, so that whenever I updated, it would give a number between .5 and .75. The observer would be confused and hilarity would ensue as the “random” number always falls between .5 and .75. To do this, type “=rand()” at the far left of the cell equation box, like normal. Then put a bunch of spaces until you get to the middle of the equation box, and put “*”. Then put more spaces until you are off the initial screen and type the rest of the equation “.25+.5”. Now, when the equation is viewed, the observer will only see the “=rand()”, unless they are looking very closely and notice the odd multiplication sign in the middle of the line. In my experiments, I have found that Excel will delete your excessive spaces if you only put “=rand()” on the far left and “*.25+.5” off the screen. For some reason, the spaces are not deleted if you type something in the middle of the equation box. Use this information as you will.

excel hiding equations

Code Monkey Monday- Transferring a MySQL Database with MySQL Workbench

I have a desktop work computer and a home laptop. For a recent project, I needed access to the same MySQL database from both computers, as I worked on the project at both locations. The database was hosted locally on my work computer. One option would be to VPN to my work computer, but that wasn’t an attractive option for various reasons. I decided that I wanted the database hosted on both computers locally.

To move a MySQL database to another computer,
1. Open MySQL Workbench on the computer currently hosting the database.
2. Goto Server -> Data Export in the menu
3. Select the database you want to copy, and select a destination in the “Export to Self-Contained File” field.
4. Click Start Export
5. Once done exporting, transfer the dump file to the other computer
6. Open MySQL Workbench on the second computer
7. Goto Server -> Data Import in the menu
8. Select “Import from Self-Contained File” and the dump file just transferred.
9. Click Start Import.

You should be good to go. Copying multiple databases or giant databases might be trickier, but this works in most cases.

Code Monkey Monday- Math Mode in Microsoft Word

If you write in LaTeX (or can learn), you’re well-equipped to write mathematical equations in newer versions of Microsoft Word. I have Word 2010 installed on my computer. To enter math mode, hold down the Alt key and hit the “=” key. Math mode accepts LaTeX-like formulas. It is slightly better than LaTeX as well, because you can see exactly how your equation will look as you type it. Whenever you’ve finished typing a complicated symbol or function and want it to display, just hit spacebar. You can click outside the math mode box or type Alt+= again to exit math mode.

Here’s an example. In math mode, type “\int_0^24 \lambda(t) dt” to get an integral that looks like \int_0^{24} \lambda(t) dt. This saves you from having to find and click on all the suggested symbols in Word to get an equation you want.

Thanks to Alex Mills for this suggestion.

Remember that you can also use LaTeX in WordPress blog posts.