Jim's Depository

this code is not yet written
 

OS X will sometimes hang for 10+ seconds, frequently earning you the dread beachball. Anything that causes the program’s main thread to stop processing events will earn you a beachball, but I can suggest two:

First the easily explainable: Your hard drive might be failing. Hard drives generally fail slowly. They start detecting problematic sectors and rewrite them to good sectors and continue on their merry way. Eventually they might have to try many times to recover the data, during this time the drive is unavailable to your computer and any program that tries to access it will get a beach ball until the drive either successfully remaps the sector or gives up. Disk drives have a thing called S.M.A.R.T. which lets the computer track how the drive is failing. Do not be deceived by Disk Utility’s claims that your S.M.A.R.T. status is good. I’ve had two notebook drives failing miserably, with unrecoverable sectors (lost data) and Disk Utility was perfectly happy. Get something like Apple - Downloads - System/Disk Utilities - SMART Utility and use it. Some drives report strangely. You might have a false positive.

Second and bordering on witchcraft: If you look in your /var/log/system.log and see lines with INSERT-HANG-DETECTED you might do a tail -f /var/log/system.log and see if it correlates with your hangs. I had that on a desktop and a laptop. Now, for the strange page… Safari is tracking your web browsing and keeping images of the web sites you visit, even if you clear your caches and history. As part of Top Sites there is a directory of screen shots from web sites you visit. Not finding a GUI way to clear those, I did a rm Library/Caches/com.apple.Safari/Webpage Previews/*.png and a rm Library/Caches/com.apple.Safari/Webpage Previews/*.jpeg – on both machines my random freezes stopped. I can only posit two explanations, neither of which sounds very good. It is possible that one of the images in there is corrupt in such a way that it takes a long time to parse, and Safari parses it frequently. The other is that beyond a certain size, that directory causes terrible performance in some frequent algorithm.

Further thoughts on INSERT-QUEUE-HANG…

The error text comes from the CFNetwork framework. The question, is what is it inserting into or querying? Some sort of cache seems reasonable.

I read through the latest CFNetwork sources Apple has made available on their open source server, but these are pretty old (10.4?) and don't have these tests in them.

But at least it's a pointer.

Under Mac OS X there is a program named “security” which lets you manipulate the keychain. Its error messages are a bit useless though.

If you find yourself trying to validate a certificate and getting  Cert Verify Result: CSSMERR_TP_INVALID_CERTIFICATE as a result, it could be because the certificate has entries in the subjectAltName encoded in something other than ASN.1 IA5String. In particular, PrintableString is accepted by openssl and firefox, but not by OS X. 

When seen from Safari, these certificates will bump the browser back to the previous page, and if you look in the debug console will show: The certificate for this server is invalid. You might be connecting to a server that is pretending to be YOURHOSTNAME

There. Hopefully this bit of text and some googling will save someone else an afternoon.

Until recently, you got a single identity per credit card with your Amazon Web Services (AWS) account. It you wanted to grant limited access to your S3 storage to a program or server you were pretty much out of luck.

Now, Amazon is slowly rolling out subordinate accounts, with something they call AWS Identity and Access Management (IAM). Unfortunately for you, as of March 2011 they haven’t gotten around to making the web based management interface, so you are going to get to tour a bunch of command line programs written in Java.

  1. Go to IAM Getting Started Guide and start following steps to install Java and Amazon’s tools, then set a half dozen environment variables. (Go back and install sun-java6-jre if you are a Debian user, make sure non-free is in your apt source lists. Other Java implementations might work, I don’t know. And the right answer for JAVA_HOME is /usr in Debian)
  2. If you get a bunch of “Unable to execute HTTP request: Network is unreachable” errors, it probably means you have a partially functional IPv6 address. You can turn your IPv6 off with  echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 ip addr del ::1128 dev lo
  3. You don’t need to mess with groups if you don’t want to. Just use… iam-usercreate -u YOURNEWUSERNAME -k -v
  4. Copy down the first two lines, that is the AWSAccessKeyId and AWSSecretKey for the new account.
  5. Copy down the third line, this is the “arn” you will use to set your access.
  6. Now it gets strangely painful. As near as I can tell, there is no way to reference your newly created User account in the “Grantee” section of the S3 management console, so you are going to have to delve into writing policies. You can use the policy generator to make an S3 Bucket policy. Use the “arn” you saved from line 3 as the “Principal”, set the privs you like, and for the “Resource” you can include a partial key with a “*” as a wildcard. Mine came out like this:
    { “Version”: “2008-10-17”, “Id”: “Policy1299041893976”, “Statement”: [ { “Sid”: “Stmt1299041882010”, “Effect”: “Allow”, “Principal”: { “AWS”: “arn:aws:iam::711941626500:user/MyUserName” }, “Action”: [ “s3:DeleteObject”, “s3:PutObject” ], “Resource”: “arn:aws:s3:::MyBucket/*” }, { “Sid”: “Stmt1299041882010”, “Effect”: “Allow”, “Principal”: { “AWS”: “arn:aws:iam::711941626500:user/MyUserName” }, “Action”: [ “s3:ListBucket” ], “Resource”: “arn:aws:s3::: MyBucket” } ] }   The first half gets me PUT and DELETE on objects. The second half gets me GET on the bucket. I don’t really need that, but boto needs it when I create the bucket object to then do my put.
  7. Apparently Amazon engineering hates developers.
  8. There is an orthogonal mechanism where you make IAM policies that grant permissions to your users. That might have made more sense, but absent a web console to view them I thought I’d go with the bucket policies.

So, there you have it. Restricted roles in your S3 account.

If you want to go straight Python, it looks like using boto is easier than wrestling Amazon's tools to the ground:


This uses those orthogonal policies I mentioned above. It disturbs me a bit because if I ask the question "Who can access this bucket?" I have to go ask all of the users, which seems wrong.

If you use Orbitz, they will sometimes tack on unwanted travel insurance. You will know this happened when you get an email from Access America with your policy. Orbitz will then pretend they can not remove it and direct you to a dysfunctional voice menu system at Access America, I suppose to try to wear you down. (There are no appropriate options, and I never could get to a human. It appears to always have “higher than expected volume”.)

Don’t let them win.

  • http://www.accessamerica.com/
  • Find the Modify/View Policy link
  • Your policy and departure date are in the email
  • They will thank you and maybe in 30 days give your money back.

Update: Refund arrived.

An January 20th iFixit published Apple’s Diabolical Plan to Screw Your iPhone about Apple’s evil pentalobular screws and their $10 kit to live with them.

As viral nerd stories go, it has everything. There is a powerful evil villain, an underdog hero, an articulate, attractive nerd (if you found the video), educational material, and a happy ending.

Let’s see how it turned out for them…

Alexa measures internet traffic with some system of taps and spies unknown to me. But you can ask it about a web site and see how their traffic fairs over time:

Google Trends will tell you how search term frequency is changing with time:

I think we can safely say that article tripled iFixit’s web traffic. It’s too soon to know the long term effects, but presumably some of those eyeballs were connected to memories that will come back when they need help repairing their devices.

Attachments

google-ifixit.png 23111 bytes
alexa-ifixit.png 35389 bytes

Another key life skill in place. The video at YouTube - Scientific Tuesdays - How to Breathe Fire Safely with Corn! covers it in both more and less detail than is required.

Most important hint: Exhale!

Second most important hint: have potable water on hand.

My hairline must have seen this coming, it has been getting out of the way for years.

I’ve spent all morning working on the next feature to be added to a piece of software I haven’t told you about. I finally added it by typing a string of 14 characters in one line of a source file.

I’m coding at about 30 minutes per keystroke.

Before one spends a good deal of time converting the RFCs into a well formatted EPUB with modern, legible typography… one should read RFC COPYRIGHTS & IPR.

I learned a new language (the actual purpose of the exercise), and had a grand time with fuzzy algorithms for deriving the intent behind the sequence of bytes, but ultimately, I can share it with no one and will not finish it. (Sorry Mechanical Turk, you will not get to labor away on my edge cases.)

Long story short on the RFCs: It doesn’t appear that anyone thought out the copyright issues for many years and now it is too hard to resolve it. 

Probably the best solution would be to find the 10% of RFCs that matter and build replacements with proper rights assignment and move on, or just live with them as is.

I’ve published tinycamd version 0.3.

tinycamd is a webcam program for Linux which makes Video4Linux2 devices available for http access. It is mind bogglingly efficient when using cameras with JPEG or MJPEG hardware compression. When using UVC (USB Video Class) cameras it includes a handy HTML 5 based page for adjusting the camera controls.

You can find the code at Google Code: tinycamd. You can read the attached man page.

Attachments

tinycamd.pdf 7363 bytes
I'm currently using a variety of cameras, but overall I find the UVC driver cameras to be most reliable under Linux. Having an actual specification that isn't reverse engineered from packet traces does wonders for quality.

I recently bought some WinBook WB-7144 HD webcams from microcenter at $30 for a two-pack. Cheap, reasonable quality, and solid driver support in Linux.


Hi Jim, FYI trying on a Linksys WRT160NL router with OpenWRT Backfire:

root@openwrt:~# tinycamd -d /dev/video0 -s 1280x720 -f 5 -F mjpeg -p 8090 -v
formating 1280x720 pf=MJPG
got format 1280x720 pf=MJPG
driver does not support VIDIOC_G_JPEGCOMP
fps=5
fps came out 1/5
Starting listener on 8090...
Failed to create watchdog for request thread: Success
Segmentation fault

I’ve written jpegapp which can be used to remove, insert, and extract the application specific segments of a JPEG file. I used it to embed transparency information in JPEGs, but you can use it however you like, some things that come to mind:

  • Remove EXIF or other strange camera information from JPEGs that you publish.
  • Attach source annotations to images when your create them automatically.
  • Yank out some application’s data to analyze.

A PDF of the man page is attached to this article.

You can find the source code over at google code jpegapp. BSD licensed. Enjoy.

Attachments

jpegapp.pdf 4474 bytes
more articles