Category Archives: Programming

Monday AM (Academic Minutiae): Python Installations

It is comical that today’s XKCD deals with bloated Python installations. I am in the midst of torching my old installation(s), which no longer seems to work.

I have previously advocated using Eclipse and PyDev as a Python development environment. But, as Java/Python/Eclipse updated and screwed up my workflow for the billionth time, I’m fed up with it. I’m switching to the Anaconda environment. It’s supposed to be good for data science related tasks, and seems to have an interface similar to RStudio. I’ve already learned that it’s important to install this environment locally instead of “for all users”, as it’s terrible at handling admin permissions.

Academic Minutiae will be my new Monday post series until I get bored of it. I’m sure there are an infinite amount of administrative or tedious tasks I can joke/complain about.

Book Review – Humans Need Not Apply

Humans Need Not Apply: A Guide to Wealth and Work in the Age of Artificial Intelligence
by Jerry Kaplan, 2015

Expands on the ideas in this video:

Actually, I got the causation backward when I checked out the book from the library. I thought the video above was based on the book, but: “I would also like to acknowledge that the title for this book is not original – it is borrowed from an outstanding short video of the same name by the famously reclusive C.G.P. Grey. I’m a big fan. Check out his work on YouTube.” (pg. 210)

Good discussion of how synthetic intelligences can do many things better and faster than humans ever could. However, optimistic on the whole: “I’m supremely confident that our future is very bright – if only we can figure out how to equitably distribute the benefits.” (pg 197)

Quick read.

BlockSite Firefox Extension Comments

I started using the BlockSite extension/add-in to block sites that I wanted to keep myself from visiting during work (Youtube, ESPN, etc). The programmer has a bit of a sense of humor in the comments that are shown when you try to visit a blocked page. Though the English isn’t great, here are the comments:

“Alright so you have tried it first time. But don’t try it again.”

“You have already tried 2 times.
I know that you will try this. But please stop now.”

“You have already tried 3 times.
Come on! Stop doing this.”

“You have already tried 4 times.
Seriously? You should be doing something else.”

“You have already tried 5 times.
I am begging you. Stop trying.”

“You have already tried 6 times.
I hate to tell you this, but this site is still blocked.”

“You have already tried 7 times.
I told you before, it is blocked.”

“You have already tried 8 times.
Are you hoping that it will eventually be unblocked?”

“You have already tried 9 times.
One more and you will hit two digits. This is seriously the waste of time.”

“You have already tried 10 times.
What? 10 times? I am not talking to you. Try sharing this extension”

“You have already tried 11 times.
No! I am not talking to you.”

“You have already tried 12 times.
I told you that I am not talking to you.”

“You have already tried 13 times.
Alright, you are starting to make me angry.”
(same for 14 and 15)

“You have already tried 16 times.
Knock knock! Who’s there?”
(same for 17-21)

“You have already tried 22 times.
I won’t tell you this joke, because you keep trying.”
(same for 23-24)

“You have already tried 25 times.
You look great, but that won’t help you to get on this website”
(same for 26-29)

“You have already tried 30 times.
How about instead of trying try to share this extension to your friends.”
(same for 31-34)

“You have already tried 35 times.
I will stop changing my quotes on the number of 36”

“You have already tried 36 times.
The last post. I am done. Please stop trying now.”
(same for 37-39)

“You have already tried 40 times.
Seriously this is the last thing that I am going to say. Stop trying to reach this site, it is blocked by BlockSite”
(same for 41-99)

“You have already tried 100 times.
Alright, since you made it that far, you deserve a reward. I will give you an echo when I will figure it out.”
(same for 101-149)

“You have already tried 150 times.
Still no reward for you for keep trying. There is no guarantee that you will get some reward”
(same for 151-199)

“You have already tried 200 times.
Alright here is your reward. The joke: What do cows do for entertainment? They rent moovies!”
(same for 201-249)

“You have already tried 250 times.
Allright, since you are full of enery, I am going to tell you some jokes.”
(same for 251-299)

“You have already tried 300 times.
You know that I am sad, that you are wasting time here?”
(same for 301-319)

“You have already tried 320 times.
But at least you can have fun if I tell you some jokes.”
(same for 321-339)

“You have already tried 340 times.
Don’t forget to tell them to your friends, I am sure that they would love to hear them.”
(same for 341-359)

“You have already tried 360 times.
What do you call a sheep with no legs? A cloud”
(same for 361-379)

“You have already tried 380 times.
Good one right?”
(same for 381-399)

“You have already tried 400 times.
What does a fish say when it runs into a wall? DAMN!”
(same for 401-419)

“You have already tried 420 times.
That one I like”
(same for 421-439)

“You have already tried 440 times.
What do you call a fish with no eye ? FSH !”
(same for 441-459)

“You have already tried 460 times.
What is invisable and smells like carrots? Rabbit farts.”
(same for 461-480)

“You have already tried 480 times.
Why do gerillas have big nostralls? Coz they got big fingers!!!!!!!!!”
(same for 481-499)

“You have already tried 500 times.
Ewwwwwww”
(same for 501-519)

“You have already tried 520 times.
A magician was driving down the road..then he turned into a drive way…”
(same for 521-539)

“You have already tried 540 times.
Two snowmen are standing in a field. One says to the other : Funny, I smell carrots too.”
(same out to at least 1111)

I wonder if it ever changes again. All software should have Easter eggs. Especially when Easter is on April 1.

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

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.

LOW TECH SOLUTION:
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.

HIGH TECH SOLUTION:
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 (https://www.mysql.com/) 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.