February 16, 2010
Cocoa Programming
I've been doing some Cocoa Programming for Mac OSX lately. I've been using Aaron Hillegass' "Cocoa Programming For Mac OSX" and have really had an easy time following along with the book. Before ordering the book, I tried to dive into OSX programming using online material, and while I was able to get some things done, I was having a real hard time trying to wrap my head around general concepts (how does the general cocoa interaction model work? how do I try to understand when to hook things up with connections in interface builder and when to code things? What things are done for me automatically?) and found that this book has been good at explaining these things.
The book itself is pretty easy to follow and has extensive screenshots, not normally something that I would think is important in a programming book, but for XCode and Interface Builder this is surprisingly helpful. Oh, I have to drag from this to that, or that is the pane in the inspector I need to be looking at. A surprsingly large amount of "programming" so far has involved knowing what key to type in which box in interface builder to get some control to watch some value in some object. And knowing which objects that Apple already provides has keys that can be watched to do what you want.
I'm coding on snow leopard (10.6) and the book was written for 10.5 so there are some disconnects there, but so far I haven't run into any errors with the code that I can't figure out quickly. The biggest so far has been an example in Chapter 11 which looks like it is a bit hairy to fix. The amount of commitment I need to make as a student to something that is easy (binding in Interface Builder) compared to writing a (granted, very small!) custom class and using it to basically just type cast is pretty big. It seems like a simple type cast operation could also be accommodated in the bindings / core data paradigm (and it is, using transformations, and a small custom class) but at any rate I have really been enjoying this book.
It makes it much easier to get a handle on where to start, and since I have programming experience (C / C++, Java user interfaces, and perl mostly) I have been able to get through about a chapter per session while doing the examples and challenges.
One of the controversial things seems to have been the introduction of "dot notation" in Objective-C 2.0. This post on Big Nerd Ranch explains pretty well how I feel about it. It is confusing to me. I like the @property and @synthesize tags added to the language a lot; being able to use dot notation sounds convenient, but only if the class is accessing properties. Otherwise it can be confusing. Is that a method call? Is it doing anything tricky with memory? Do I have to worry about it and check the setter / getter selector? I'm going to stick with bracketed notation until I get a better handle on these things.
I also like that Objective-C 2.0 introduced garbage collection, but I also want to do explicit memory management with release / retain for a while.
I've been really impressed with how easy it is to create user interfaces in XCode / Interface Builder. All I have to compare with is Java's Swing platform, and I never used any GUI interface builders with that. I know things are getting better in that area with NetBean's Matisse and some of the Eclipse plugins, but every time I have looked at those they don't seem to save you from writing much of the boilerplate code that you need to navigate user interfaces. With XCode and Interface Builder you really don't have to write much code and things are saved out as data.
I am sure that similar systems exist for Java out there by now, but I don't know where I would start with them and they are certainly external to stock Java vended from Sun (Oracle?)
The other thing that has really impressed me is Core Data. Apple makes it really easy to do the common things, and not hard to difficult things. In my experience with Java, it is as hard to do easy things as hard things (they are both surprisingly difficult.)
I've got a project in mind for Cocoa on OSX, which will probably take a few months (I do not have much free time!) but once I finish up with that I am really interested in looking at iPod / iPad development. It's too bad that there are major differences in the APIs available to the two platforms, but that might be the next thing I look into. I guess I would have to get an iPod Touch or iPad at that point though. :-)
July 16, 2009
Perl on Mac OSX does not like ~
This caused me to lose about thirty minutes of my precious "not working, not sleeping" time (currently at about two hours a day.)I was trying to run some file test operations on some files in OSX using Perl (one of the newer ones, 5.10 maybe) that have spaces in their names. In general, I absolute hate how processing files with spaces is so difficult. One thing I like to do is change the IFS (internal file separator) in bash while doing things with files. This blog post shows a really nice example of doing that.
Anyway, I was doing something basically like:
if (-e $file && -f $file) { ... }
for $file where $file was something like "~/tmpLibrary/covers/Sanderson, Brandon - Mistborn.jpg". It was failing all the time. I was also getting mystifying "failed trying to stat file with newline in it" error messages when I knew the file name had no newlines. I still don't know what that was about. Unfortunately, for files that I knew existed and were regular, the above test was failing.
Why?
After much experimentation, lots of googling (there was nothing on this) I figured it out. And remembered that I knew this was a problem at some point, and must have forgotten. Perl barf on "~/tmpLibrary/bar.jpg". It will work fine with absolute file paths: "/Users/devans/tmpLibrary/bar.jpg". Oh. That is strange, but I guess I can understand that. There isn't any real reason that Perl should expand the path with the user home location. I wouldn't be surprised if it, and would be (was!) surprised when it didn't, but whatever.
So, remember that kids. Don't count on home directory expansion. Not that I could find anything about that (or spaces in filenames, which work just fine) for perl file operator tests, but there you go.
And I spend my free time doing stuff like this for fun. I am a sad, sad man.
July 4, 2009
Stripping DRM from Ebooks
I found a good post on how to remove DRM from ebooks at http://www.makeuseof.com/tag/how-to-strip-mobi-and-prc-ebooks-of-encryption/. They have a link to some python scripts that can remove DRM from some forms of ebooks as long as you know the PID for the book that you bought.This morning I purchased Brandon Sanderson's "The Well of Ascension", the second book in the Mistborn series. I found the first book during Tor.com's launch ebook giveaway, (you can get it too!) and really enjoyed the book. I wanted to read the rest. (Apparently, I might not be the only one.) So I checked online, and I could get the second book for about $14 from Fictionwise. Sounds great. The only problem is that the books they sell there have DRM, Digital Restrictions Management. I am not able to read books that are encrypted with DRM on my preferred ebook reading platform: FBReader on my OLPC with Ubuntu installed on it. So I decided to try to remove the DRM. That would restore my rights as the owner of the book to archive it, so that I can read it in a month, six months, five years, or twenty years. As long as I ensure that I have the regular unencrypted file and software to read it, I should be fine.
If I did nothing about the DRM I would only be able to read the book on the computer that I used to download it. A 15" notebook. It isn't really all that portable.
I was able to strip the DRM as outlined in the link above, but the resulting mobipocket file came up empty when I tried to load it on FBReader. Bummer. So I tried another approach. I took the unencrypted mobipocket file, and loaded it up into the OSX Stanza ebook reading software. Then I saved it again as an ePub file, a more open format. That did open ok in FBReader, and now I can read the book that I purchased on any hardware that I like.
I am a bit disappointedthat I needed to pay $14 for the book. I would have preferred $7 or so since I do not get a physical copy, but ebooks are actually more convenient for me. On Amazon.com the book is actually $7.99 for a new, physical copy (or the Kindle copy, which I am not able to buy, but could use if I could after stripping the DRM) that includes lots of costs for printing, shipping to warehouses, distribution, whatever. Ebooks are a lot simpler when it comes to distribution: you ship them over the internet, with perhaps some up-front computation to encrypt the book using some sort of DRM scheme. Costs would be lower without the DRM. Customers would be happier because things are easier to use. People who want to buy books probably are not the people that are going to go and upload the files to the internet. People who just want to get the book for free can already do that. I can't see how DRM is really helping the industry, but that is the standard for books right now.
Thankfully, it is now possible to get non-DRM'd music files, from Amazon or Apple's iTunes store (but you need to make sure the stuff is iTunes plus still I think?) Hopefully video will go the same way.
I would really like to get a Kindle but I won't do that until I can get one that works in Japan. Until then I will make do with what I have. Even once I get a Kindle though, I would like to make sure that my books do not have DRM on them so that I have control of my files, and what I can do with them is not dictated by a third party (regardless of whether or not I think that the system is reasonable enough, and non-intrusive enough to use.)
BTW, you can use the MobiDeDRM if you get the Kindle PID (type '411' from the Setting menu, according to this blog post.)
June 20, 2009
I hate Fujitsu (AKA upgrading the hard drive on an artificially limited Fujitsu Machine)
My mother-in-law's laptop is "broken". The laptop is a Fujitsu FMV-Biblo MG50S, if you check the page there you will see there are a few others with similar specs. I took a look at it last week. A quick check of the hard drive (first on list of things to check because "I can't put any more pictures on it") and that is the problem: 30GB on a 30GB drive. Nice.Summary: I hate you Fujitsu. Marketing droids added a hidden something somewhere (looks like it was hiding on the MBR) that made Windows see only 30GB of an 80GB drive, and when I did a clone to a new hard drive (160GB) it showed up as 30GB. So to be clear: when cloning a drive using CloneZilla, PNG, or Acronis True Image and the like, if you copied the hidden MBR your new 160GB drive would show up in Windows as only 30GB, even though the Disk Utilities management program would show the full disk size.
Absolutely crazy. Click the "Read More" link to read more about this insanity. For the impatient: do not copy the hidden MBR and you will be fine. Also, I now prefer Clonezilla to PNG. And the GParted boot CD rocks. Also, I hate Fujitsu. If you need to buy a new laptop you really should only consider Apple (coupled with a TimeCapsule) or ThinkPads. For netbooks, do whatever you want but back them up somehow.
read more (1450 words)June 16, 2009
Emacs longlines-mode
I have been a fan of auto-fill-mode (and flyspell-mode for that matter) for a long time. Unfortunately, when I think about it I much prefer free-flowing text. The problem with auto-fill-mode is that it will throw \n characters into your text file when you need to wrap lines. Most email clients will automatically wrap text, and will do it at the size that is best for the user. Or at least, that is the theory.Anyway, I just discovered longlines-mode. This mode in Emacs will wrap long lines (hence the name) but does not insert \n characters into your text file. Also, when you copy text, it copies as long unbroken lines. So this is really nice. I wonder why it took me so long to find this mode?
It makes me wonder what other marvelous mysteries emacs is hiding from me.
June 13, 2009
Using NTT DoCoMo's P906i as a tethered bluetooth modem for internet access with Mac OSX 10.5.7

Finding your phone

Access the internet with it

Set up the access information
So say you have a nice phone, like the DoCoMo P906i, and an unlimited packet package for your phone. (Hey, I do!)
Wouldn't it be nice if you could use your phone for internet access with your computer? You know, what they call tethering? That sounds super cool. Since my phone has bluetooth, it is theoretically possible to have the phone in my bag, computer in my lap, and tell the computer to connect to the phone then get to the internet that way. It turns out that this is possible.
DoCoMo has a page (not that I can find it now) that says as long as you use your tethered computer for (light) web and email access they won't get after you. They definitely say no file access though. Actually, it looks like they want you to join their Mopera service which lets you access the internet on your computer. It works overseas as well. If you don't you can use a separate internet access plan for your phone, but it has a bunch of stuff written there about needing to pay separate fees and to arrange for an internet provider. You can also just use FOMA which is their standard data access plan as far as I know. I finally found the page that shows what you can use and it looks pretty good. You can't do streaming video, peer-to-peer, VOIP, and online games but most other stuff looks good (mail and web is what I am primarily interested in, but they make a point that flash videos are ok. Also system update and some other stuff like that.) This page isn't the one I found earlier this morning which had cute pictures of things that you could and couldn't do, but it has the information, so that is good to know.
So, knowing that this is possible I was interested in doing it. First up: my Mac. Why? Because I looked into doing it on linux initially and that is super hard. So let's see if Apple can get this right.
1.1 Pair your phone and OSX
The easy part: set your computer up to talk to your phone.
Open up the Bluetooth Preferences control panel. Make sure that "On" and "Discoverable" are checked.
On the P906i open up the Bluetooth control application. On my phone that is on the Menu button -> Life Kit -> Bluetooth. Click the Search button (upper-left softkey, the mail key on my phone, サーチ.) The Bluetooth devices in your area should show up. In my case, Blanka, my MacBook Pro shows up, so I select it (center menu button) and it says that this device is not registered, would I like to register it? (未 登録機器です 登録しますか?) So of course I check the "YES" option. It then asks me for my phone's password (端末暗証番号は? 4 digits, enter your own) and asks to enter the bluetooth passkey.
Then at that point I should be able to see a thing show up on the MacBook, but it can not find it because the phone has not turned on bluetooth yet. Really. So you can fix this by going to the 4th option in the Bluetooth list (ダイヤルアップ登録待機 - wait for a dial-up registration) then click the "+" button the Mac to add a device. Have it search for phones (or any device) and when you see your device click it. It will take you to a screen saying that it needs to get some more information about your phone. Let it do that. It will probably time out and give you an error. Back to the phone, put it back in the waiting for dial-up connection mode, then go back and press the "continue" button.
Then your phone will pop up a confirmation about a connection from your mac. Click yes, then it asks for your password, then the passkey for the bluetooth. The Mac should through up a passkey now. Enter that. If things go well, you get a screen that says "Access the Internet with your phone's data connection". Make sure that is checked and click "Continue".
It might ask you to store some stuff in the keychain, let it do that. You should get a screen that asks for your Phone Vendor. Select NTT DoCoMo. The phone model, use "P/FxxxiX (Bluetooth)". For Username and Password you can use anything I believe. Probably best to keep both less than 8 characters and no special characters. For "Phone Number" enter "*99***1#". Apparently when you are overseas "*99***3#" should work. I like to keep the modem and bluetooth icons in the menu for easy access. Click continue, then Quit. You are done!
To start the internet connection, click the modem icon in the menu bar and "Connect Bluetooth". Keep your phone handy if you need to do something there. For me I didn't have to do anything. The phone just went into a magic bridge mode. Seems to work ok.
According to Speedtest.jp my phone connection is like, a Skateboard level. Good for small movies. Maybe. A bit faster than ISDN but that's about it. It says 301k. Checking with Speedtest.net which is a better tester, it says 357 ms ping, 0.35 Mb/s download and 0.24 Mb/s upload. I seem to see from 10 KB/sec to 40 KB/sec in this super short use, so that sounds reasonable to me.
Just for comparison, on my Fiber connection, I get a 12ms ping, 35.71 Mb/s download, 18.77 Mb/s upload.
May 6, 2009
Shamus Young's PixelCity Screensaver

Pixel Ctiy: a procedurally generated city screensaver

Wireframe mode

Colored Block Buildings See all the screenshots of PixelCity that I took.
Get the screensaver from Shamus Young's site.
May 2, 2009
Setting up an AFP (Apple Filesharing Protocol) on Ubuntu and a Firefly iTunes Media Server
One of the things I've been meaning to do for a while is set up my Ubuntu machine to share out the music I have on it. I run Amarok on the machine and love it, but that doesn't help when I'm super lazy and don't want to reach over for the linux machine keyboard when I have a perfectly good laptop in my lap*. (* Of course, I do have a VNC server set up on the machine so I could VNC in and start up Amarok that way, but it somehow feels like cheating.) First step in getting the machine to share out music: set up an AFP server do the other machines in the house (mostly Macs) can see it. That was a lot easier than I expected: just follow the instructions on this post. Great! That seemed to work well. I think. I already had samba up and running on the machine and I am guessing that is what is currently showing up in the Finder. I'll check it out on R.'s machine when I can pry her away from it. The one thing that I did do was to change ATALK_MAC_CHARSET to 'MAC_JAPANESE' and ATALK_UNIX_CHARSET to 'UTF8'. It was pointed out over on this Japanese blog entry that that would be a good idea. I also set up a share for my data folder. I was impressed that this went so smoothly because you need to compile the service from source in order to enable encrypted passwords on the server. It went really smoothly though. Once you have AFP set up, you need to set up Avahi to broadcast the server. This guide is a really nice explanation of how to set up Avahi. So once that is done, you can move on to the next step in the process: and set up Firefly on the system. That setup was also really smooth, with the exception that for some reason, if you change the default password the service does not seem to work. I have no idea why that would be the case, but do have a vague memory of the same thing happening a few months ago when I set it up. Annoying, but not such a big deal. Once I hit up the webpage for the service, set up the proper directory for the music, and did the scan, the share showed up in iTunes just fine. Nice.April 25, 2009
iPhoto 09's Faces Feature
I recently bought iLife 09 and have been using the Faces feature in iPhoto a lot. The Faces feature will look through all your pictures and identify people's faces. Then you can put a name to the face, and gradually iPhoto learns to spot pictures of that person. It is an amazing feature. Facial recognition has been a promised feature from Artificial Intelligence since the 80s, and this (along with Picasa's Name Tags) is the first really commercial product that I have seen facial recognition in. Since I'm a computer scientist by trade, I'm well aware of how these kinds of things work beneath the covers, and while there has been some press coverage saying that this feature isn't ready for mass release, I disagree. I think it does a good job, has a great interface, and more than that, is really fun to use. I find that once I put a name to a face, I want to go through and see what other pictures I can find that the person is in. I also have been adding metadata to my pictures in some way (going back to file name for really old pictures) that show who is in a picture, so it is interesting to see how well iPhoto compares to my tags. Once you have added a bunch of names to faces, iPhoto has a nice cork-board of faces that you can click on to find all pictures they are in, or have iPhoto show you more pictures that it thinks they might be in. Adding names to faces is very easy. When you see a picture, you hit the "Name" button and then get a picture like the one to the left. People who have a known name have their name below their face, and for people whose name isn't known you see either "unnamed" or iPhoto asking "Is this X?" where X is someone you have already named. It is really impressive. iPhoto does a very good job of noticing faces - it doesn't always notice all faces, but it gets most of them - and it does a good job of suggesting names when it thinks it might know who someone is.
It is also easy to scan through a lot of pictures and quickly confirm or refute iPhoto's guesses

It knows faces, but not necessarily human faces
iPhoto is also wrong sometimes, and guess that strange things might be faces. In the middle picture on the right, names have been blurred to protect the innocent and stomach-face-bearing people. Also, iPhoto doesn't know when a face is a human, or whether it is just a face-like object to sometimes hilarious results.
Things that disappoint me about this feature in iPhoto: there should be better intergration with the Address Book. After a software update, iPhoto will suggest people from your address book, which is great. It does this based mostly on email addresses to keep track of people, so you can add someone's email address from address book and you won't get duplicate name suggestions. I wish that in address book though that it would know about the faces in iPhoto and you could get the faces gallery on the Address Book entry. As it is now, you have to go into iPhoto yourself, pic a picture, then drag it over to Address Book. You also lose the nice face cropping that iPhoto does for you. That's too bad. I hope that in future updates that put that kind of functionality into Address Book.
Another issue is that iPhoto 09 adds Flickr and Facebook support, but at least in Flickr it doesn't look like they send the extra faces meta-data. They should make a Flickr "note" around the face with the name, or at least put a list of the recognized people into the photo. As it is now I feel like I have to go in and manually type the names into the description field, which is exactly what I was trying to automate out of the picutre. (uh, no pun intended.) I haven't checked if they do that for Facebook yet. Also the upload interface isn't as nice as what I have been using, Connected Flow's Flickr Export. That has a lot more options and gives you a much better update on upload progress. I'll probably keep using it since I prefer it - you can create new sets with a description and it just generally is more powerful.
Otherwise I am really happy with Faces. It is a fun way to spend time going through your old pictures. I'm afraid that now I'm addicted to trying to name everybody that has ever been in one of my digital photos...
April 15, 2009
OSX Password generator script
http://www.codepoetry.net/products/passwordassistantFound a nice script to open up the OSX password generator window. Might come in handy if you need to generate a bunch of passwords. I'm still looking for a good replacement password safe for OSX / linux / windows (preferably one that works on all three.) I have been using Keyring (an open source Palm application) for ages, and still have my Treo 600 as basically a portable password store (but I don't have it with me at right this moment, so this script will come in handy.)
March 23, 2009
Emacs, Japanese, Putty, Windows, and text entry
I don't know why but I have had to set this up a few times now. If you try writing Japanese via Putty into Emacs, and things do not work for you (instead it looks like Emacs is interpreting things as control characters in some way) then the following magic incantation might help you:
;; Set up Japanese input and coding systems
(set-language-environment "Japanese")
(set-terminal-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(set-buffer-file-coding-system 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(set-keyboard-coding-system 'utf-8) ; This is the magic for windows putty Japanese input
The important bit is the set-keyboard-coding-system. The other things are important to some degree, but the keyboard setting is what determines whether emacs will beep at you or put up some pretty Japanese text.
I actually have Putty, Emacs, and Gnu Screen all playing nicely together now, which is great. But this is only true for version 23.x of Emacs, since 22.x doesn't seem to play well with Japanese in a terminal under screen...
January 7, 2009
Another brief roundup: cheap ebooks, cool indy games, and a neat graphics library
First up, cheap $1 ebooks from Orbit. It looks like this publisher is selling one ebook per month at $1, which is a deal that you can not pass up, even if the books are DRM-encumbered. I'm seriously considering buying at least the first two books, The Way of Shadows by Brent Weeks, and Ian M. Banks' Use of Weapons, even though I can't DRMd books on my OLPC with FBReader.
I highly recommend Use of Weapons by Ian M. Banks, but you should probably wait until next month to pick it up for $1. I have the paperback sitting right in front of me and I'm still going to buy the ebook.
Next, an interesting looking programming language for visualization and graphics. I wish I had more time to look into stuff like that.
Finally, Game Tunnel's list of 2008 best indy games - I want to check these out when I have more time.
January 3, 2009
Getting Tomoe to recognize Japanese characters in English on Fedora 10
I recently set up Fedora 10 on a ThinkPad X60 laptop, which has worked very well. I'll write about that a bit later I think. There are still some issues with the wireless connecting to a WPA2 network, and the Intel 945GM video drivers are apparently pretty crappy right now due to changes in the underlying architecture, but things are working really well on this small laptop.One of the things I am interested in using this laptop for is as a Japanese-English dictionary. To that end I installed GWaEi, a Japanese-English dictionary using the Edict files. I had been using GJiten for a long time, but that project hasn't been updated in a while, so I thought I would try something new. (Warning: I had to compile from source, and make a minor change in main.c to have it default to called "/usr/local/bin/gwaei" when re-setting the language variables. A simple change, shouldn't be tough to figure out but feel free to drop a comment if you want more info.)
GWaEi seems to work well.
The other thing I like to do is use Tomoe, a linux-based handwriting recognition engine for Japanese and Chinese characters. It is conveniently available for install via yum. The problem is that after installation, no matter how many strokes I entered no candidates would show up. That is odd. I vaguely remembered that when I installed Tomoe on Ubuntu recently that I had to copy some file.
So, for those facing a similar problem at home: if you want Tomoe to make suggestions when you are running in an English environment, you will have to do something like this:
$ sudo cp /usr/share/tomoe/recognizer/handwriting-ja.xml /usr/share/tomoe/recognizer/handwriting-en.xml
That took care of the problem for me. Yay! Now I can fingerpaint my way to successful Japanese reading.
My next project: see if I can upgrade to the newest version of Ubuntu on the OLPC that I have, and get Tomoe working on that. It is a bit smaller than the X60 and might make a good machine to take to coffee shops. (That isn't really true though: the keyboard on the X60 is vastly superior to the one on the OLPC, but the OLPC has a much better screen for doing lots of ebook reading.)
Anyway, hope that helps someone out there. Jeez, it seems like my entire vacation has been spent on sundry computer things at home.
January 1, 2009
MAME Frontends in Ubuntu
I have been interested in getting MAME running on my desktop again. I never got SDLMAME working on Fedora 8 because performance was terrible. For some reason, under Ubuntu with my Intel GMA3100 onboard video things work well enough to play pacman at least (and probably others, SFA2 seemed to work well, but as always SSF2T was too fast) so I wanted to see what the state of MAME Front Ends for linux was. (Oh, also I have to run in the software render mode to get the tab menus to show up, otherwise they are garbage. Once things are set up though I don't need the menus, so back to hardware mode which is fast.)kxmame doesn't believe me that my sdlmame executable is a MAME executable, it complains that it can't find any MAME instance and errors out. So that is enough time spent on that one.
kamefu refuses to find any of my roms. So that one is out.
wah!cade seems to work, but it uses bitmaps for the default UI and on my 24" monitor I can't read anything. So I stopped play with that for the time being.
Two more I am looking at are Lemon Launcher (probably won't install it unless I can't get AdvancedMenu to work) and AdvanceMENU which is my current best hope. There is a description of the install process here. So far installing AdvanceMENU has been a real pain. this thread has helped me fix a few SDL errors and of course I had to install a lot of stuff to get this to compile.
Once compiled I couldn't get it to run well: I added sdlmame as an xmame emulator, and had to make some init files for that. But it would freeze when trying to launch a program. I am now checking on the configuration used by Piapara, a bootable ISO that runs advancemenu and sdlmame to see what they use. To do that I had to create a boot cd, mount the iso in a loopback filesystem, then mount the app.img in a loopback filesystem. Finally, the relevant setup info they use is:
emulator "MAME" mame "/usr/bin/mame" "-inipath /mnt/pendrive/sdlmame/ini" emulator_roms "MAME" "/mnt/cdrom/sdlmame/roms" emulator_flyers "MAME" "/mnt/cdrom/sdlmame/flyers" emulator_altss "MAME" "/mnt/cdrom/sdlmame/snap"So they set up the emulator as a mame emulator. Ok. I'll try that.
Also, a new discovery: using the sdlmame option -gl_forcepow2texture fixes the menu corruption bug that I was seeing. So yay for that! Actually on further investigation I also needed to set the filter to 0 and (remove bilinear filtering from output, which makes things look more pixelated and better anyway) and enable gl_glsl in the sdlmame config. It seems to be working well now.
I haven't got advancemenu to work though. I have all these great artwork cabinet and screenshot files, but I can't get advancemenu to launch sdlmame. Ah well. That is enough time spent on that today.
Annoyingly Super Street Fighter II Turbo still runs too fast. Tapper runs well though, so that is good enough.
Spinning down external USB hard drives on Ubuntu 8.10 Intrepid Ibex
Generally, it looks like you can use the sg3-utils package to do that. First, install the package:
$ sudo apt-get install sg3-utilsTo do this right you should probably make sure that your hard drives show up in predictable places. The best way I know to do that is to set a label on the partition, and then it should mount in /media/LABEL. So here is a good article on how to rename external USB hard drives. I saved the script at the URL above as /usr/local/scsi-idle and following along:
$ mount (note that sdc1 has mostly TV shows, sdd has my other data) $ sudo umount /dev/sdc1 $ sudo umout /dev/sdd1 (name both partitions appropriately - one partition per drive) $ sudo e2label /dev/sdc1 BackupTV $ sudo e2label /dev/sdd1 BackupDataThen power cycle the drives. Check that they show up as expected:
$ mount ... /dev/sdc1 on /media/BackupTV type ext3 (rw,nosuid,nodev,uhelper=hal) /dev/sdd1 on /media/BackupData type ext3 (rw,nosuid,nodev,uhelper=hal)That looks good to me. I also added to /etc/local.rc
# added by devans to spin down external disks. # See http://ubuntuforums.org/showthread.php?t=560958&page=3 # and the related wiki entry https://help.ubuntu.com/community/ExternalDriveStandby # Spin down any external SCSI drives after "X" seconds: /usr/local/bin/scsi-idle 900 &which should take care of that. Just for this first time, I ran it myself:
$ sudo /usr/local/bin/scsi-idle 900 &
While that did work ok, it only spun down the hard disks. It did not go the extra step of shutting down the fans on the hard drives, so they are about as noisy as they were before. Still, at least they are spun down now. I set the drives to their "auto" setting, but it looks like that will only kick-in and shut them down when they are unmounted, which I do not want to do.
July 19, 2008
Electric Sheep Beta playing nice with mplayer and xscreensaver on Fedora 8 Linux
I've been a fan of the Electric Sheep screensaver for a long time, but I haven't been running it lately.It turns out that there is now a new linux version, so I thought I would try to install it on my home machine running Fedora 8. The source install went great, I already had all the prerequisites installed, so simple configure; make; make install went fine.
The problem was a strange interaction with xscreensaver and mplayer. I did a system update recently, and mplayer decided that the "stop-xscreensaver=1" setting in my ~/.mplayer/config stopped working. That means every ten minutes while I'm watching videos, the screensaver kicks in. So I switched to the alternative method of preventing the screensaver from starting up by using the heartbeat command to tell the screensaver not to start every 30 minutes.
That worked great. When I got around to installing Electric Sheep though, I found a problem: Electric Sheep uses mplayer to play the videos it creates. Mplayer tells the screensaver to not invoke. So while Electric Sheep worked fine from the command line, when run as a screensaver it would just quit immediately.
The solution: a simple bash script that checks whether electricsheep is running. If it is, it does nothing, otherwise it will call the "do not invoke the screensaver" command. If anyone else is interested, here i the script:
#!/bin/bash
#
# devans 2008-07-19
# This script will check to see if electricsheep is running, and if so, it will do nothing
# If it is not running, it will invoke xscreensave-command -deactivate to prevent xscreensaver
# from running. Mostly this is useful is set as the command to call via heartbeat-cmd in
# ~/.mplayer/config
if [[ -z $(ps -ef | grep electricsheep | grep -v grep) ]] ; then
# echo "suppressing";
xscreensaver-command -deactivate
fi
The whole thing works well if you put heartbeat-cmd="~devans/suppressXscreensaver.sh &" in your ~/.mplayer/config
So far the screensaver seems a bit unreliable. It has trouble starting up sometimes and the screen just blanks. I haven't tracked down what the problem is, but when it works it is really beautiful.
July 12, 2008
Playing around with the OLPC / XO
My family recently came to Japan to meet my wife and her family, and my dad gave me a great toy: an OLPC / XO laptop that he got through the Give one Get One program. I'm excited about the XO project because I think it is a good project: essentially bringing laptops (or ebooks, primarily) to children around the world to help improve education. I think that is a nice goal to concentrate on. There are lots of interesting very small laptops available now, primarily the Asus Eee PC laptop, but I really like the OLPC because it has some very interesting hardware. I actually think the EeePC has better hardware for more traditional laptop use - particularly the keyboard is easier for me to type on, and the machines have better specs - but the OLPC has an amazingly interesting display, and I really like the sturdy build of the hardware. The most interesting thing about the display is that if you bring down the backlight on the display it has a really great, 200dpi black and white reflective display that is readable in sunlight. You just can't get that one a normal laptop. I also like how the color works (just turn on the backlight) and you get color, albeit at a lower apparent resolution. This reminds me of the Apple //e that I grew up using. I want to play with some of the drawing programs to see if by placing individual dots you can change the color like in the old double hires Apple //e display. The next two sections talk about getting Japanese support working under the Sugar interface that ships on the OLPC by default, and installing XFCE as an alternative to Sugar that makes the laptop seem like a more traditional linux desktop. The way I have mostly using the OLPC though is with an install of Xubuntu on an SD card, which is the second main section of this post. The remainder of this post is mostly raw notes about the install process, and probably very boring unless you are into this kind of stuff. You might be more interested in reading about using FBReader to read ebooks on the OLPC, or using Anki to study Japanese. If this looks interesting, click the "read more" link.read more (2790 words)
April 16, 2008
First impressions of OSX 10.5 Leopard and Time Capsule
A while ago I bought a 500GB Time Capsule and Leopard at work to use as a backup solution. It took me a while to find the time, but I had a lot of papers to read recently so I installed Leopard and set up the Time Capsule while reading the papers.First off, I'm really impressed with Time Capsule. It costs only a bit more than an external hard drive, but had a Gigabit Ethernet 3-port switch and 802.11n wireless. It feels very solid, is small, and is very, very quiet. I have an external IO Data 500GB hard drive right next to the Time Capsule, and it just drowns it out. Even after turning off that drive, I had a hard time hearing the Time Capsule. I'm really shocked at how quiet it is.
Setting the Time Capsule up was really simple, Zero Conf is just great for getting things on a network and making it easy to find them. Since we've got wireless at work I turned off the wireless interface, and just used it to extend the wired connection I already had. Once I set up Leopard on my machine, I started the Time Machine backup, and I have to say again that I am really impressed with how quiet the drive is: I had to listen pretty hard to hear the write noise. I was using ethernet plugged into the Time Capsule for the backup, so I was surprised that I was only getting about 10 MB/sec (sometimes up to 12) to the drive, which surprised me. The Gig-E connection should be able to support 125 MB/sec. Well, not really of course, but 10 MB/sec is an order of magnitude less than I expected!
Interestingly, the 802.11n interface should typically get (according to Wikipedia, so who knows if this is true) about 9.25 MB/sec, or about what I was seeing with the ethernet connection! Wow. Now I want to get one of those Time Capsules at home...
I'm very, very impressed with Time Machine. I haven't played with going back in time for the recovery stuff yet, but it looks like it will be great. I had been using an rsync-based backup solution that would use hard links to not duplicate files that have changed, but there are some problems with that solution. It works very nicely, but every four hours I run the backup script, and for about ten minutes the hard disk thrashes madly as rsync runs down the file tree looking for new files. I had it in a cron job, and nice'd the process so the machine is still totally usable, but there is a noticeable drop in performance, and sometimes you get the dreaded beach-ball while it thinks about file operations.
Time Machine uses a very similar approach, but Apple does some other magic that lets them link directories (not possible with standard Unix tricks as far as I know) and more importantly uses a DBUS-style notification system that tracks file operations, and keeps a list of things that have changed since the last backup. It doesn't have to check the whole file system for changes, it just has a list of things that have changed. The backup is impressively fast. I'm really impressed with how easy it all comes together: this is a consumer solution. There are no real drawbacks: the backup is so fast you wouldn't notice it happening (after the initial full backup) and the drive is so quiet that you can just forget it.
That's all I have to say about that. There are some other things about Leopard that I've noticed that I like:
- The "Spotlight" window is now a real finder window and you can use exposé to find it. In Tiger if you are in finder and do a "show application windows" the Spotlight window does not exist!
- Spotlight is a bit faster now for launching applications, which I use all the time.
- I like the coverflow view for windows much more than I expected. Being able to see large views of PDFs makes it really nice to look for a paper. It also helps recognizing Word and Excel documents quickly much more than I expected it would.
- They fixed the annoying "yellow cursor bug" in the X11 server. Yay!
Here are some annoyances:
- Mail.app again defaults to sending Japanese email in UTF-8. Generally, I think this is a good idea, but for some reason if email isn't in ISO-2022-JP for Japanese a lot of mail clients turn it into gibberish (mojibake). What really surprised me is that this happened with someone on Windows Vista - I don't know what client he uses, but if you are on Vista shouldn't your email client be able to read the headers and use UTF-8? Most mobile phones can only accept ISO-2022-JP, but I would think big computers could deal with it fine. By the way, to set the default encoding for Mail.app, you can enter "defaults write com.apple.mail NSPreferredMailCharset "ISO-2022-JP"" in a Terminal window. I vaguely remember having to do something like this on Tiger as well.
- I don't know if they fixed this, but at one point after a recent Security update in Tiger, all text pasted into Mail.app lost carriage returns. It was awful. There are ways to work around it (paste into Text Edit first, make rich text, paste into Mail.app, then make it plain text again) and so on, but that is annoying. I'm sure I'll notice this pretty quickly because I'm always pasting text into email. But I haven't noticed it yet. (I hope it is fixed.)
February 18, 2008
Added Gravatar support for comments
This person wrote a Gravatar plugin for bBlog and I set it up here for the comments. I like the idea of Gravatars a lot, so I'll try them out and see how it goes. If you are interested in the procedure, download the function.gravatar.php file from the website above, throw it in your bBlog_functions directory, go to the admin panel, and rescan to pick up the plugin. Then you have to edit the bBlog/inc/bBlog.class.php file, search for the format_comment function and insert the line$commentr['posteremail'] = $comment['data']->posteremail; before the return statement.
Then you have to edit your template file to put the gravatar image where you would like. The code should go into the comments section in the post.html file. I added a <img style="margin-right: 10px;" src="{gravatar email=$comment.posteremail}" align="left"/> line to template and things are working great.
I would actually like to add Wavatar support on top of the Gravatar stuff, but that would take more than five minutes, so it will have to wait until I get more time.
Also, if you want to change any of the default values, you can set them in the call to the gravatar plugin in the template file (e.g., add {gravatar email=$comment.posteremail size=80 default=http://example.com/image.png}).
February 17, 2008
Dave, your forms are EVIL!
A while ago, I got this email from a friend of mine:i left a long comment on your starbucks entry, but i got a character wrong in your CAPTCHA, and it told me to click the "back" button and try again. however, when i did that, all the entries in the form were BLANK! I LOST MY COMMENT! AIEEEE!!!!!This is a problem, because I don't like evil in any form. Particularly in my forms. I've been really busy, but spent about thirty minutes poking around at the bBlog internals (looks I chose a bad horse: the bBlog project seems to have died!) and made the field values sticky on an error with the captcha submission. If you are interested in the changes, here is a diff file that you can apply via patch:
patch -b bBlog.class.php bBlog.captcha.diff against an unmodified version 0.7.6 bBlog.class.php from the bBlog install.
Once that is done, you have to modify your template to add value="{$commentFieldPosterXXX}" where XXX is some value. The only exception is {$commentreplytitle} which remains the same.
Here is the relevant portion from my template:
<div class="formleft">Comment Title</div>
<div class="formright"><input name="title" size="80" type="text" id="title" value="{$commentreplytitle}"/></div>
<div class="clear"> </div>
<div class="formleft">Your Name: </div>
<div class="formright"><input name="name" size="80" type="text" id="author" value="{$commentFieldPosterName}"/></div>
<div class="clear"> </div>
<div class="formleft">Email Address: </div>
<div class="formright"><input name="email" size="80" type="text" id="email" value="{$commentFieldPosterEmail}"/>
Make Public? <input class="checkbox" name="public_email" type="checkbox" id="public_email" value="1" checked=\
"checked"/></div>
<div class="clear"> </div>
<div class="formleft">Website: </div>
<div class="formright"><input name="website" size="80" type="text" id="url" value="{$commentFieldPosterWebsite}" />
Make Public? <input class="checkbox" name="public_website" type="checkbox" id="public_website" value="1" chec\
ked="checked" /></div>
<div class="clear"> </div>
<div class="formleft"><img src="/randomImage.php" alt="verification image"><br>Image verification:</div>
<div class="formright"><font color="red">{$commentFieldError}</font></div>
<div class="formright"><input name="verification" type="text" id="verification" /></div>
<div class="clear"> </div>
<div class="formleft">Comment:</div>
<div class="formright"><textarea name="comment" cols="80" rows="10" wrap="VIRTUAL" id="text">
{$commentFieldPosterComment}</textarea></div>
Of course, you also need to follow the relevant directions in my original post on adding a captcha for comment protection in bblog. But it looks like things are working well for me here.
The diff patch is here.
Go to Page: 1 2 3








