I think it’s important to understand how your applications work without the aid of an IDE. But man, oh man. It sure is nice to have a good IDE while you are trying to be productive in a language. I installed PyDev today now that I feel very comfortable with how python applications are built and run. It is so nice to explore what’s available by just typing code. In my IDE, I can just type “platform.” wait a sec and see all my available options. I’ve been using TextMate for the better part of two years now. It’s a great text editor, but it sure is nice to have a full featured IDE to not only write the code, but see warnings and errors very quickly. It’s nice to see the structure of my code in the outline view. By far, my favorite feature is the integrated debugging. Setting breakpoints, stepping through code, and inspecting variables is a beautiful thing.
Author Archives: jason
Parallels Share Ubuntu Filesystem with Mac Lion
I would like the ability to write the code on my host computer (Mac) and run them on my virtual machine (ubuntu 11). Parallels does not come with a built in way to share ubuntu folders with your Mac like it does for Windows. Using sshfs and openssh-server you can still accomplish it.
First make sure you can log into your virtual machine using ssh and your public/private keys.
1) Install openssh-server on the ubuntu VM
sudo apt-get install openssh-server
2) Make sure you can ssh into your vm
ssh user@address
3) Generate ssh key pair. I assume you use the default rsa keys. If you already have keys, you can skip this step.
ssh-keygen
3) Add your ~/.ssh/id_rsa.pub to your authorized_keys
scp ~/.ssh/id_rsa.pub jason@10.211.55.5:id_rsa.pub ssh jason@10.211.55.5 mkdir ~/.ssh chmod 700 ~/.ssh cat ~/id_rsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
4) You should now be able to login to your VM without supplying your password
ssh jason@10.211.55.5
5) Install sshfs on your mac. I like to use Homebrew to install my open source software. You need to install fuse and sshfs. If you’ve previously installed MacFus, or OS Fuse, you need to uninstall it for this doc. You can probably get it to work, but this guide won’t tell you how!
brew install fuse4x sshfs
6) Now you should be able to connect to the filesystem of ubuntu. This creates “/Volume/ubuntu” folder that you can open from finder, or terminal, or textmate!
# mount mkdir /Volumes/ubuntu sshfs jason@10.211.55.5:/home/jason/ /Volumes/ubuntu -oauto_cache,reconnect,defer_permissions,negative_vncache,volname=somename # unmount umount /Volumes/linux
Sometimes your VM will change it’s ip address. If it does, you may need to clear out your ~/.ssh/known_hosts file. It’s ok to just wipe everything out because it’s simply a cache of the keys of the servers you’ve accessed.
Thanks to Philipp Klaus for the sshfs info
Thanks to ubuntu docs for the openssh-server info.
Error when configuring to use the EJB interceptor binding API. JAX-RS EJB support is disabled.
I’ve gotten this error twice while using Glassfish inside eclipse. I’m not sure of the root cause but after hours of searching both times, I thought I should document how to get around this error. After I shut down the glassfish server and restarted eclipse, the error went away.
Native looking Mac apps using Python & wxPython
So, I went down the road of using wxRuby, but it seems that it is a dead or dying code base. Seems most Ruby-ists are interested in Rails, not in desktop applications. I also failed in my attempt at packaging up a ruby desktop app to make it appear native. I kept running into 64bit vs 32bit issues.
Anyway, after quite a few months break from my project, I decided it made more sense to develop my blenderfarmers render farm client application using Python. Blender itself uses Python to perform all it’s scripting tasks. This would guarantee that Python is installed on every computer that is running Blender.
Turns out, it doesn’t even matter if python is on the target machine because built into Python is the ability to bake the python application into an executable. Ruby has this ability too, but I just never could get it working. In one hour, I was able to create a shell wxPython window and “freeze” it to a native Mac package that behaves just like a native app. Beautiful!
I know this is Mac centric, I need to test on Windows too, but my experience is it is harder to get working on my Mac, than my Windows virtual machine.
Great page that helped: Optimizing for Mac OS X
mysql query tracing
# Turn on logging set global log_output=FILE; set global general_log=1; # Turn off logging set global general_log=0;
The log file was writing it to mysql/data/{hostname}.log on my machine.
I recently used this to discover why a Rails app was taking 15 seconds to load a page. I know this is also shown in the Rails log, but I wanted to show the impact of the SQL statements alone. It is much easier to look at the MySQL log which isolates the SQL calls.
This application was performing over 600 database operations. I’m amazed at how many developers don’t take the time to truly understand the impact their code has on a database. Sad to say, this kind of crappy code is all over that application. I hate inheriting crap.
Convention over configuration
I think convention over configuration is one positive idea that Ruby had brought to the java world. One of the criticisms that is lobbed at java is that it has too many XML configuration files. I don’t think this is a weakness in the java language as much as it is the desire to make an extremely flexible system that doesn’t require a re-compile to change optional parameters. It centralizes these choices into a configuration file instead of throughout several source code files.
This configuration file explosion isn’t exclusive to java. I’ve seen it in rails applications too. The only difference that I can tell is that Rails uses a more terse file format known as YML. The production Rails app that I am working with has dozens of these configuration files. Frankly, it looks no different to me than other production java projects I’ve been on.
YML may be easier for a developer due to the terseness of it, but I don’t think it is any better for the folks who are expected to maintain these configuration files (the production support teams). In fact, I would think XML would have an advantage in this area because of the ability to validate an xml document based on a schema. I am not aware of these sorts of tools for YML.
Video Capture with C#
I’m having lots of fun writing a video capture application in C#. Windows Media Foundation is supposed to be the “cool new way” to do this. Unfortunately, there just isn’t a lot of support yet in the drivers and as far as I can tell, Windows Media Foundation does not work with the DirectShow drivers that capture cards use. So, I’ve gone down the rabbit hole of learning how to write a video capture application using C# and DirectShow. There just isn’t much information out there because everyone seems to want to use C++.
After opening Microsoft’s sample C++ app to do video capture, I’ve come to the conclusion that Microsoft COM C++ just makes me feel stupid. It’s always made me feel stupid. I used to think it was me. I know now, that it’s just an ugly API and you have to be able to think in strange ways to do COM. I’ve learned so many languages and libraries now that I can say, it’s just one ugly mess. I’m glad they’ve been going down the CLR route.
I’m using http://directshownet.sourceforge.net/ to handle the interop layer. I have it capturing video from my Intensity Pro capture card. My super fast hard drive and SATA3 system is just barely able to keep up with the uncompressed AVI file that I’m capturing. I could compress it, but I don’t want to lose ANY color information as we will be using this footage for green screen magic.
command line
One of the things that I love the most about my Mac is the command line. I know the Mac is well known for it’s beautiful user interface, but that doesn’t stop at the graphical user interface. It extends to the command line user interface as well. One of the advantages of being based on unix is that all the command line power that is available on unix is also available on the Mac. I know microsoft has recently upgraded their command line abilities but they can’t really compete with decades of knowledge on command line usage on unix. There were many times that I felt a little helpless on my windows box when I wanted to do something cool. I felt helpless because a lot of the stuff I was interested was for unix only. I do not usually experience that on my Mac. The unix environment is just more naturally geared for the free software world.
Per Project RVM Selection
I work on Rails as a contractor as well as my own projects. My main contract uses rails 2.x and ruby ree 1.8.7. Naturally, I like to use the bleeding edge on my own projects. This causes me problems going back and forth. I found that you can create an .rvmrc file that will set the environment for you when you run ruby in that directory.
You just put the same command you would normally type at the prompt to switch RVM environments in the .rvmrc file and it works!
echo "rvm ree@global" > .rvmrc
This will enable you to simply change directories and not have to think about which version of ruby and gemset you are using. cd into that directory, type ruby –version to verify it loading the right ruby version.
Startups
I’m currently working at a startup. One of the things I love about startups is the commitment I see from a lot of developers. I remember when I first moved to Colorado, working at 2am with other developers. It’s sorta like a party. I think it’s why I loved the Rails Rumble so much. It is 10:30pm, I just drank 6 shots of espresso. Another developer and I are planning on working perhaps till people show up in the morning and beyond to get some functionality done. This is so not a corporate thing to do. I love it!