Archive for the ‘Uncategorized’ Category

You are what you buy?

Recently I have slipped into thinking I am defined by what I consume. For example, if I buy this REI shirt that will make me more of an outdoors person. Or if I found a clever deal for a bike rack on Craigslist, it will show the world how frugal I am and make me more of a biker. Or if I wait to buy a new TV, that shows that I have self-control and am not going beyond my financial means.

I also start zeroing in on what I will buy in the future. I spend a lot of time curating shopping lists, or finding the right reviews, and trying to decide whether I will buy a thing this month or next month based on my budget.

This is silly. My identity is not defined by what I buy, when I buy it, or whether I had good self discipline. I think I have been too much focused on how these exterior things define me.

Instead, I want to focus on things I create, adding value to the world instead of just consuming value. So for example, at work, I should be getting my projects done on time, and creating value by collaborating with my coworkers effectively. At home, I can create value by caring for others in a sacrificial way. I can create value by writing blog posts, or by being a good steward of things I already own. I want to have a vision for the future that is defined by how I will be faithful to God, not by how I will be faithful to my budget.

Learning in the midst of information overload

We live in a world where we are easily inundated by information. Our news feeds constantly update, providing an endlessly scrolling list of tidbits. There are always more Youtube videos, more podcasts, and more articles in our feed readers.

My own story roughly matches this. In the past I tried to cull my list of subscriptions: follow the right people on Twitter and unfollow the ones who tweeted too much. I tried to save time by only clicking on the interesting headlines. Ultimately I found that I still couldn’t keep up, and I was afraid of missing out on what I wasn’t clicking on.

The main mistake is “trying to keep up” in the first place—or having this passive, feed reading behavior be your only way of learning new things. Reading Twitter is a good way to keep up, but it shouldn’t be the only professional development that you do. Sure, it might help you discuss the latest ideas with your coworkers at lunch, but it’s also not going to go very deep for actually improving your professional skills.

Active Learning

Stop Passive Learning. Start Active Learning,” by Andrea Angela was the original impetus for me to write this blog post. The main point of the blog post is to stop endlessly consuming news feeds, because it leaves you constantly feeling behind. Then you have free time, and this allows you to choose a topic to learn, and then look for resources around that topic.

I like that Angela acknowledges that we won’t always have the mental capacity to do “active learning,” and that it is at those times that he turns back to his news feeds in a more passive approach.

Another blog, “Improve Your Self-Improvement” has a similar idea. Don’t just learn something and then set it aside. Share what you learned with others.

Ratio of producing to consuming

After I read about active learning I immediately remembered John Sonmez’s video about the 70-30 rule. This rule talks about the ratio of consuming to producing. Spend 70% of your time producing and 30% of your time consuming. Producing is making value for others, and consuming is just a passive activity where you are looking to be entertained or “informed” but you aren’t actually using that information.

When I think about the 70-30 rule I think of several contexts where I am producing and consuming.

At work, I probably do follow this ratio. In the work context, I would associate producing with tasks like coding, debugging, documentation, and giving demos. I would associate consuming with things like reading my email, checking out the work news feed, and reading the all-company announcements and stuff.

The other context is my after-work work, a term borrowed from “Improve your Self-Improvement” meaning professional development or personal development that is career-related that you do on your own time. In this context, I am striving to move more toward the 70-30 ratio. Some producing tasks include writing blog posts (yay, doing that right now), or taking notes, or coding on a side project. Some consuming tasks include watching Pluralsight, reading my RSS feeds, or other articles I come across on Twitter.

In conclusion, I want to be more proactive, and come up with my own ideas, rather than trying to react and digest others’ ideas all the time. I want to have my own opinions about what is important to keep up with in the tech industry, rather than just assuming that the newest thing is important to me.

Computer security reading list (part 2)

I came across Bruce Schneier’s “CRYPTO-GRAM” many years ago when it was an email-only newsletter, and ever since then I’ve been interested in security. Taking St. Cloud State’s Computing Ethics class (CSCI 332) gave me more connections with how security affects computers.

Continuing my last post, Computer security reading list (part 1), this post includes some resources on computer security. Not that I’ve read everything linked to here, but I’ve read enough to be drawn in and informed. I hope that you may find these useful as well.

Blogs (continued)

  • Google Project Zero Project Zero is a team at Google that looks at different systems and finds and documents zero-day vulnerabilities.

Articles

Lectures

Computer security reading list (part 1)

Blogs

Books

Talks

Reports

Three weeks with a smartphone

Three weeks ago, a shiny new Galaxy S4 arrived in the mail. I purchased the Samsung Galaxy S4 GT-I9500 32GB (unlocked) on eBay. The phone was released about a year ago, but I found a vendor who was selling it new. When it arrived, it had Android 4.3 on it. Recently, an update arrived to my phone for Android 4.4, an OS which by now is 6 months old.

Initial setup

There were a lot of questions and informational boxes, both from Samsung and Google. I was a little overwhelmed. Later on, I went back into the different apps and looked more carefully at the settings.

Many apps I used on my iPod were also available on Android. I installed Facebook, Twitter, Dropbox, ESV Bible, Olive Tree, Springpad, Pleco, Webster’s dictionary, Google authenticator, MPR Radio, and Crashplan. A few apps I had not been able to use on the iPod, because they only supported iOS 6 and higher. This list included Amazon MP3, and Bandcamp, though I don’t use either of them often. Apps I installed that were not on iOS include Firefox and F-Droid, which I’ll talk more about later.

Comparison with iOS

Before owning the Galaxy S4, I owned a 3rd generation iPod touch for 2 years. It wasn’t a phone, and it didn’t have a camera, but it did a lot of the things a smartphone does, provided I was in wifi range. I installed a number of apps and used Apple’s included apps as well. When I bought the S4, I had to get used to the differences in the user interface.

Some physical differences that stuck out to me:

  • Don’t rest your thumb on the bottom edge of the phone, you’ll bump the back button. I had to get used to holding my Android differently than my iPod touch.
  • The sleep button is on the side instead of on top, which means that there’s no side to rest the phone on when it is horizontal.  Which buttons do you want to mash if watching a video in widescreen?
  • The sleep button also becomes a shutdown menu if you long press it (same as the iPod), but the definition of “long” is much shorter on Android. I’ve seen that menu way too many times.

Some software differences:

  • Rearranging icons on the home screen is much different.
  • Launching apps and going home feels slower on the Galaxy S4. This is a little disconcerting, considering the S4’s hardware is 4 years newer.
  • Two different photo apps: Photos and Gallery. Apparently Google is trying to shift over to Photos.
  • The lock screen clock widget is inaccurate half the time. The little numbers in the upper right are always right, but the big numbers aren’t always right. This is unacceptable.
  • I like not having to install iTunes in order to transfer music on the phone.
  • Apps live in two places: In the Apps list (shows all your apps), and possibly on your home screen (where you can add widgets, arrange to your heart’s content)

Overall, iOS feels more integrated. Apple has had more time to refine their product. The lock screen clock widget and the apps living in two places are excellent examples. Another example is system updates. For Android, when you get an update depends on the device you’re using and which carrier you have. For iOS, you get the update when it comes out.

On the other hand, Android is much more customizable. I installed F-Droid, a 3rd party app store with only open source apps in it. So far I’ve installed KeePassDroid, SatStat, and FillUp from it. It makes my inner free software person happy. You can also install custom keyboards, root your phone, and even replace the firmware, things I haven’t yet been adventurous enough to do.

If my readers have any thoughts about iPhone vs. Android, I would welcome them in the comments.

Being objective about Objective C

(Sorry, couldn’t resist the pun.) A few months ago, I started a new job that required me to learn Objective C and Cocoa/Cocoa Touch development on the Apple platform. In this post, I’ll relate a few concepts that I learned in other languages that crossed over to the Apple platform.

MVC architecture

In web app development, the view is (arguably) the DOM. The DOM is loaded at a certain point in time: when the browser is finished parsing the initial payload, a load event is generated, and as a developer you can specify a handler for this event. This allows you to do things when that view appears, like populate it with data.

In iOS, the load event is similar to viewWillAppear. A NSViewController subclass can implement this method to perform custom behavior when the view appears, such as updating the UI based on the contents of some property.

Connecting the view to the controller

In Cocoa/Cocoa Touch, outlets and actions are used to connect objects in the view with code in the controller. Outlets are for linking objects in the view to a property in the controller. This allows the controller to manipulate that object, for example, setting the title of a button object. Actions are triggered when an event happens to an object. For example, an action responds to a click on a button. Action methods are passed the sender of that action.

I would compare outlets to DOM objects, and I would compare actions to DOM event handlers. Xcode makes creating outlets and actions a drag and drop operation, but in Javascript, you use document.getElementById or jQuery. DOM events are attached to an object, and specify a callback function, which can also take an argument of the sender (the this keyword).

Event loops

An event loop handles all incoming events and allows the application to respond appropriately. More generally, an event loop takes a queue of messages and processes them one at a time. An example of a message would be “call this callback function”. Processing that message would be actually executing the callback. For example, in Javascript, you specify a callback for the click event. When the click happens, the message to call that callback is placed on the message queue. The loop processes messages one at a time, so if you have another Javascript function that is currently processing a table (maybe shading the rows), the click callback message will not be processed immediately.

The Cocoa main event loop, GLib main event loop, and Javascript event loop are conceptually the same.

Node.js uses a single-threaded Javascript event loop to great advantage. Using Node, it is fairly easy to implement a scalable, event-driven web application.

Cocoa extends the main event loop, allowing you to create other queues. Queues are event loops that may or may not run on another thread. However, messages dispatched on the same serial queue will always be executed one at a time. This allows you to protect variables that aren’t thread safe by only accessing them from a particular queue.

The Glib event loop is used by a GUI library such as Gtk+ to make a Linux application. I’ve used these libraries while fixing a few Gnucash bugs and while writing a Twitter client.

Conclusion

My experience with Gtk+ and Javascript allowed me to quickly pick up core Cocoa concepts and design patterns. Now if I could only remember to do all UI stuff on the main queue!

Moving a WordPress blog to Nearly Free Speech

Up till recently, this blog has lived on WordPress.com. Now I’ve moved it to http://www.rratliff.com/, where I have control over more of the configuration. I’ve had some experience with WordPress before, but I wanted to update my knowledge. Also, with all this recent talk about privacy on the web, I wanted to set up my own server and see how I could eavesdrop on my visitors learn about it.

For my non-tech friends, here is some quick background. WordPress is two things. It is a blogging software, which anyone can install on a web server that they control. It is also a company who has installed this blogging software on WordPress.com. They control it, but they give it away as a free service (and also have a paid service for those who want more advanced features.) I’ve chosen to move from the free service to the service that I can control. Now I pay NearlyFreeSpeech.net some money to host my blog on their site, but again, it gives me more control over the configuration, and more opportunities to learn.

Things I learned

  • How to list all the tags in Subversion. (I used this to make sure I was downloading the most recent version of WordPress.)
  • An SQL process can have multiple databases in it.
  • WordPress can use a single database to host multiple sites by using a table prefix.
  • In the world of web servers, file permissions matter. For most of my life up till now, I’ve been working on single user systems. Therefore I have not needed to worry about the group and other sections of the unix permission modes.
  • The ability to export and import a blog from WordPress.com to self-hosted WordPress is pretty cool.
  • How to install a WordPress plugin manually. The fastest way is to SSH into the host and wget the zip file. Then unzip it there.
  • My hosted site does not utilize HTTPS right now. Therefore several passwords that I use to administer WordPress are transmitted in the clear. Say hello to my government surveillance friends, and hackers too? Hopefully not.
  • Piwik is a really cool way to do web analytics. There’s two pieces.
    • One is the Piwik tracking Javascript, which is added to all pages on my website. This can be done by the WP-Piwik plugin.
    • The other is the Piwik web server, which handles the requests from the tracking Javascript and then stores the information in the database. It also provides a Dashboard for admins who log in to view the analytics data.
    • Also, Piwik can anonymize part of visitors’ IP addresses to reduce the amount of personal information that is collected.
    • Google Analytics provides a free (as in price) service, but my analytics data is being aggregated with the analytics of a lot of other website, thus contributing to Google’s database. They use this for marketing, which I view as a form of corporate surveillance.
  • WordPress by default does not generate valid HTML. I fixed it on my site by modifying functions.php. See WordPress category tag validation error fix for more information.
  • I installed the Use Google Libraries plugin to change the jQuery to use Google hosting. This has a small speed benefit for users.

Still to learn

  • How to get Apache to do what I want. I really want a good rating in Google Page Speed. Two sticking points right now are leveraging browser caching and enabling gzip compression. There are WordPress plugins that will manage my .htaccess for me, but I think it would serve me well (pun intended) to learn how to configure it myself. Another tool for testing blogs is ismyblogworking.com
  • It would be cool to set up a staging environment, where I can work on plugins and WordPress tweaks without worrying about disabling my production website.
  • It would be nice to have blog posts and pages stored as files instead of in a database. That way I could put them under version control.
  • Either WordPress or my web host has poor performance, because I’m getting the “Reduce server response time” suggestion pretty consistently from Google Page Speed. I know a static site would help immensely in this area, but at the cost of some convenience of administration.
  • Even cooler would be to tie the version control and the staging environment together. When I am happy with the way my blog looks in the staging environment, I can commit the changes, then push (deploy) them to the production blog.
  • My host supports some sort of HTTPS/SSL. I’d like to learn more about this and then consider asking them to enable it.
  • Another suggestion from Google Page Speed is “Eliminate render-blocking JavaScript and CSS in above-the-fold content.” To fix this will require diving into WordPress themes, which I am not looking forward to.
  • There are more recently popular blogging frameworks, such as Jekyll or Octopress.

Keep WordPress speedy by resizing images

When you upload an image to WordPress, it is stored in its original size on the web server. WordPress allows you to specify an image size. WordPress will create an additional copy of the image at that size and insert that in the page instead.

Here is an example:
Original size: 1858×1233 (652 kB)
Wordpress copy: 1024×679 (336 kB)

This means that when people view your page, they have to download 0.5 times the original file size. This is a smaller file download, and it will help your page load faster.

Point to remember: If you choose a size when you insert an image, it tells WordPress to create a smaller file download. This will help your page load faster.

Resizing images

After inserting an image and viewing the page in a web browser, usually you’ll find that your image is too large. So then you go in the Edit Image window and set a smaller size, e.g. 70%:

This presents a problem: If you use the Edit Image window, WordPress will not automatically resize your image file a second time. It will only display the image smaller. This means that the web browser is still downloading the full size file, but it is just viewing it smaller.

I tried resizing the cabbage image above to 70%. Here is what happened:

WordPress size: 1024×679 (336 kB) — Recall that this is due to our choice of size in the Insert Image box.
New size at 70%: 717×475 (336 kB) — But this image could be 186 kB if I resized the actual file.

See the difference? If you resize an image with the Insert Image box, it will actually save space, but if you resize an image with the Edit Image box, it will not actually save space.

Conclusion

Correctly scaling your images before inserting them into a post will solve this problem. If you are going to be inserting a lot of images, use a test image. Insert a single image and use the Edit Image box to find out what size looks right. Then on your computer, resize all your images to this size before inserting them into the post.

Misc notes

Another thing you have to take into account when viewing images is the maximum width of the content in your theme. For example, this blog (bobbyratliff.wordpress.com) uses the Twenty Eleven theme, where the maximum width is 585. Even if I choose the 1024×769 option, the image width is limited to 585. In other words, it will show the cabbage image as 570×377.

Another solution is to add image sizes to the insert image dialog. If you have hosted WordPress, you can use the Additional image sizes plugin to do it.

Google Page Speed is a great tool for troubleshooting slow sites. It has a list of rules that it evaluates your website against. When your page breaks a rule, it will tell you why and give some clues on how to fix it. The information in this post applies to the suggestion “Serve scaled images.”

The role of a computer scientist

When I meet people, I often end up telling them that I am a college student, and my major is computer science. “So what are you going to do with that?” they ask. “Programming” is my usual answer. There are many possible careers for computer science majors, but in this post I’d like to write about the role of a computer scientist. What is a main, overarching goal to our work?

Frederick P. Brooks gave a speech in 1994 in which he addressed the goal of computer science. The transcript is entitled “The Computer Scientist as Toolsmith II.” In it, he argues that when computer scientists write programs, their primary goal is to satisfy the needs of the user. Users will use our tools to get their job done. In short, we are toolsmiths. Brooks writes, “We make things that do not themselves directly satisfy human needs, but which others use in making things that enrich human living.” In other words, an engineer can use a computer drawing program as a tool to design a bridge. Or a parent will use a social networking program as a tool to communicate with friends.

In making our tools, we should make them well. It goes without saying that the tool should not break when you are trying to use it. The tool should not be too complex or hard to maintain. When we work as toolsmiths, we should do good work.

Merely talking about how we make our tools does not fully address the question. We also need to address this question: What types of tools should we make? To discern this requires some sense of morality. Wolterstorff writes,

There is something deficient about the person who does good work for its own sake without ever asking whether it’s a good thing that this work be done. The estimable craftsman asks two questions concerning the good. He asks whether what he is doing or making for its own sake is a good example of its kind: a good violin, a good arpeggio, and so forth. But he also asks whether doing or making a good example of this kind is a good thing to do. (quoted in Think, by John Piper, page 120)

In other words, we should ask two questions:

  1. Is this a good tool?
  2. Is making a tool of this type a good thing to do?

The second question is a challenging question to ask. It is a question that transcends individual preference. At the very least it requires people to think ahead of possible uses of their tool. I do not wish to analyze every tool that has ever been made and fit it in this grid. I do wish, however, to provide two examples of tools where this question should have been asked.

The first is the recent flu virus that was genetically modified to travel via airborne particles. Basically, a deadly flu virus was made even deadlier. The US government asked the researchers to limit the amount of information is published in academic journals, for fear that the findings would be turned into a flu pandemic. The New York Times has an article on the deadly flu virus. One researcher went so far as to say, “This research should not have been done.” In other words, it was not a good thing to even do this kind of research, even if it was done well.

The second example is the trend of personalization in internet websites. This results in “a bubble” around you that only includes news that you want to hear. For example, search engines change their first page of results depending on who is searching. Facebook internally sorts your friends into who you want to hear from and who you do not. This has been explained at dontbubble.us and in a recent TED talk, “Beware online ‘filter bubbles’.” When a computer filters our results based on what we like, we miss out on things we need to hear. A human newspaper editor can create a balance of different articles on a front page, but a computer filter will only put things that we want to hear. The filtering technology is very good at what it does, but it is not a good tool, as it dulls our thinking and takes away our exposure to ideas we disagree with.

In conclusion, the computer scientist has two roles: to make tools well, and to determine which tools should be made. This requires both technical expertise and a moral compass. It is my desire to see more and more programmers have a moral compass to guide them in their work.

Power usage

I recently purchased the P3 Kill A Watt EZ (model 4460), and I have been using it to measure the power usage of a few items around my dorm room. I was originally inspired to do this from one of Jeff Atwood’s posts on power usage.

Desktop power usage

The first item I measured was my tower, the HP Compaq dc7900. It has the following specifications:

Intel Core 2 Duo E8400
4 GB RAM
Seagate 160GB
Western Digital 500 GB
ATI Radeon HD 2400 XT

The power measurements are as follows:

switched off 3 watts
on, idle 60 watts
on, BOINC at 50% 80 watts
on, BOINC at 100% 90 watts
suspend 4 watts

BOINC is free software that allows you to participate in a variety of distributed computing projects, and I used it to perform some CPU-intensive tasks for my testing. When I say BOINC at 50% and BOINC at 100%, I was utilizing BOINC preferences. It has an option, “On multiprocessor systems, use at most __% of the processors.” My system has 2 cores, so the 50% roughly corresponds to one core at full utilization, and 100% corresponds to both cores at full utilization.

It is interesting to compare these measurements to Jeff Atwood’s measurements. Two articles from 2005 give measurements of 118 w for a desktop, and 160 w for a server. My dc7900 specs are strikingly similar to Jeff’s 2005 desktop, and mine was a budget model purchased in 2009. For similar performance computers, we come to the conclusion that idle wattages have dropped by half in 5 years.

Probably more instructive is a comparison with Jeff’s 2011 Home Theater PC, which draws 22 watts idle. This is with a Mini-ITX board, and other power-saving goodies.

Monitor power usage

The next item I measured was my 22 inch widescreen monitor, an HP L2245wg. I learned that switched off and in power save mode, it uses the same amount of power, 3 watts. Switched on, it uses different wattage depending on the screen brightness.

on, 0 brightness 21 watts
on, 50 brightness 29 watts
on, 100 brightness 42 watts

Looking at the results, I was rather shocked that the power usage doubles when the brightness is turned up. It is better to keep your monitor’s brightness down, and this is best practice for monitors anyway.

Laptop power usage

Finally, I measured the power usage of my Eee PC 900, which I had recently installed Xubuntu 11.04 on. The power measurements are as follows:

idle at Xubuntu desktop, minimum brightness 16 watts
idle, wireless switched off 14 watts
idle, wireless on, maximum brightness 17 watts

Then, out of curiosity, I booted my Eee PC with Minix 3, since it is a small operating system designed for embedded use. I used version 3.1.2a for USB stick, which can be found in the MINIX previous versions. (The latest stable release is 3.1.8.) The power usage of this was 15 watts.

In summary, for my laptop, there is strikingly little difference between minimum brightness and maximum brightness. The difference between MINIX and a full-fledged operating system, Xubuntu, is minor as well.

It is also interesting to compare my Eee PC’s power usage with some of Jeff Atwood’s measurements. His Dell XPS M1330 (in 2008) used 20 watts idle, and his Dell Inspiron 300m (in 2006) used 15 watts idle. From this small amount of data, I can jump to the conclusion that, unlike desktops, laptops have not significantly improved their power usage.