Adding LaTeX to Notes with Ruby

February 15, 2008

I’ve finally come up with a some what novel use of ruby that is saving me a bunch of time at school, so now I’ll pass the savings on to you!

The Problem:

I want to take notes in class using my Mac. More specifically, I want to use OmniOutliner (though this method should be adaptable to any editor that can embed images). However, in more than a few computer science classes I’ve had, the mathematics get pretty heavy. And thus far summations, fractions, large equations, etc. don’t like to be typed out. They hate it. This has limited my ability to use my afore mentioned Mac as a note taking center for those classes.

So how can I still use OmniOutliner to take notes that include a large mathematical component?

The Solution:

In a word LaTeX. Let me explain.

Hopefully everyone’s familiar with LaTeX – a markup language used to format books, papers, etc. What its really good at is creating equations. The syntax is different, but not difficult, and it allows you to basically write out as complicated mathematical formula as you like in plain text. This gets converted to your actual equation using the TeX typesetting program.

I’d used LaTeX before a semester or so ago for writing up my homework for a particular class. For this, I’d installed the requisite packages via MacPorts and used the best editor of all time, TextMate, to write up the document and convert it to pdf.

But how do we add formatted LaTeX equations to a program like OmniOutliner, which doesn’t know how to parse LaTeX? Well, thats what this post is about.

conversion

More after the break.

Read the rest of this entry »

Advertisements

Quicksilver trigger: open with Textmate

September 20, 2007

Just made my best trigger yet! For those not in the know, quicksilver can be used to create custom short-cuts that do something when you press a certain key combination.

I had already made a open Gmail trigger, so I can open Gmail just as simple as command+option+g. This ones pretty nice, but the one I did today combines my favorite Mac app (Quicksilver) with my favorite Mac editor (Textmate).

One nice feature of Textmate is its ability to open folders and display their contents on a side drawer. The part that always bothered me was getting to the right folder while in Textmate. I usually had it opened in the Finder, but then would have to re-navigate to it when I wanted to edit files in the folder.

But No More!

For this trigger I turned on the proxy objects in the Quicksilver section of the Catalog.

proxy-on.png

This Gives you access to the ‘Current Selection’ proxy object, which represents what you have highlighted at any given time. Folders, files, whatever. It’s a very useful proxy.

Now we are able to create a trigger that opens the Current Selection (i.e. a folder) in Textmate.

Quicksilver textmate trigger

Assign this to your keychord of choice (I picked command+option+m but I don’t know if thats a good one) and you’re ready to use Textmate, via Quicksilver, all the more efficiently.

Update:

I found a problem with the key combination I choose, namely option+command+m is used to highlight text in the best pdf viewer / editor : Skim. So, what to do? I don’t like having three modifier keys as part of the key combination, so I didn’t really want to move to control+option+command+m.

So I took advantage of another Quicksilver feature that lets you limit where your triggers are used. If you open the information pane for your trigger, and select the ‘Scope’ tab, you can set limits or exceptions to the validity of your trigger.

scope.png

I could have also just disabled it in Skim, but so far I can’t think of another place this would be useful except in the Finder…

Btw: You just type the name of the program you want to limit the scope to – so type it right.


OpenVPN Server on Mac

September 26, 2006

Spurred by a unhelpful digg post on setting up an OpenVPN server on Windows, I decided to finally get OpenVPN working on my Mac, which is currently running as my web server / other servers. I eventually found some help, but it took awhile, so why not gather it all up here.

What is OpenVPN?

A VPN or Virtual Private Network essentially connects a remote machine to a network, over the Internet, securely. A common use for VPN is to let a user at home or on the road make an encrypted connection to his office’s network as if he/she were actually in the office. In this type of setup, you would be able to connect to file servers, mail servers, or printers remotely, without having to worry about someone on the Internet watching what you do and snagging private information.

I wanted to use it so I could use VNC to connect to some of my home machines on my laptop at school.

OpenVPN utilizes SSL, the same technology used to encrypt websites to make its connection secure. Its also OpenSource and free, which are two good reasons for using it. It is also fast and very powerful, once you get things set up.

One alternative to OpenVPN commonly cited is Hamachi. It seems easier to set up and can run on the major 3 OS platforms. The main reason I shyed away from Hamachi, as many people do, is because it is closed source, and owned by a company. That means you just really can’t be sure about what its doing or how its doing it. Sometimes this is acceptable, like when using Skype, but sometimes, you’d just rather have the open software. Plus, OpenVPN is a much cooler thing to have running on your system anyways.

Configuring The Server

This was where there isn’t a lot of Mac specific info. Most tutorials deal with using Linux or Windows. Thats fine, probably what most people have as servers. But I wanted it on a Mac! The ever useful Darwinports has a port of OpenVPN, labelled “openvpn2”. They have the regular openvpn port, but it is an older (1.6) version, and that won’t due.
Install it by using the command

sudo port install openvpn2

This will get you most of the packages you need to get things going.

Now we turn to the OpenVPN site for configuration instructions. You can follow the Linux instructions pretty closely, and things will work out well with a few exceptions:

  • The easy-rsa folder can be found at /opt/local/share/doc/openvpn2/easy-rsa . I copied the openvpn2 folder to someplace easier to find like /opt/local/etc/openvpn . You could make it easier and put it in /etc/openvpn too, but sometimes I forget to check there…
  • The sample server and client configuration files can be found at /opt/local/share/doc/openvpn2/sample-config-files. I also grabbed the server.conf file and copied it to my simplier openvpn folder. Making these copies will also ensure your changes won’t be overwritten when OpenVPN is updated.
  • according to this hint from macosxhints.com,tunnelblick might be needed to get OpenVPN working correctly. Download tunnelblick here,the current version I got was 3.0 RC3. We will be using it as our client as well, so more info in that section below

So with the help of the OpenVPN manual and the nice tip about tunnelblick, we should have a working version of OpenVPN on our server.

Configuring the Client

Like I mentioned, we need tunnelblick to connect to our server. Tunnelblick is a very elegant and easy to manage GUI front end to OpenVPN. The 3.0 RC3 version comes with everything bundled together, and all you need to do is drop it into your Applications folder.
Run it and you should see a little tunnel in the upper-right hand corner of your screen.
It should also add the folder ~/Library/OpenVPN. In this folder I copied the ca.crt, client.crt, client.csr, and client.key which were created on the server during the PKI section of the tutorial. I used fugu to move stuff over from the server.
Now you can click on the tunnelblick tunnel icon and then click on “details” to get to the meat of the program. Select “edit configuration” to modify the important stuff. I basically copied OpenVPN’s sample client configuration, and pasted it into here. Modifying the destination IP address and the location of the crt and key files. I had to use the entire path file to get these to work correctly for some reason, namely:
/Users/username/Library/openvpn/ca.crt . I don’t know why I couldn’t use realitive file names, but it wasn’t having it.
Also, I started by using the local IP address of my server to make sure things were working correctly before trying to connect to it from the Internet.
When that was all finished, I selected “Connect” and you should be connected to your own VPN server!

If you have file sharing turned on, you can check your connection by hitting apple + k to go to the connection dialog and connecting to afp://10.8.0.1 (if you followed the tutorial exactly, else use the IP address you set it up for). This should connect to your server.

The next step is to get more machines from your intranet on the vpn. But that is for another post, as I haven’t quite figured it out yet…


Automatic Network Photo Transfer

August 1, 2006

picture-2.pngThe last part of my photo management project was to have an easy way to move images into Picasa. While we will use the Ubuntu box to view and edit pictures, most of our time is spent on our Macs. So there will be times when we have a folder of pictures on a Mac, and want to get that to Picasa as easily as possible.

I used Automator to create a stand alone application that should accomplish just that. First I needed a way to connect to the Ubuntu box. In Automator there is the option to connect to a server, but you have to make sure that that particular folder was shared and enter a password and bla bla bla… too much. Since I had passwordless entry through ssh set up already, why not leverage that to get to the Ubuntu machine?

With a little searching I found an upload with scp Automator action. Perfect! scp is an extenstion of ssh, and this Automator action takes care of moving the folder over too. To use it in Automator, I went to ~/Library/ and created the folder “Automator” then moved the .action file to this folder. When you restart Automator, the upload with scp action will be there. So the Automator workflow first uses “Ask for Finder Items” to select a folder and then “Upload with scp” to copy it to the correct directory on the Ubuntu machine. I have it set up to copy the folder into the “My Pictures” folder inside “PicasaDocuments”. That way, Picasa will automatically add the folder to its listing. It’s so easy!

I then saved the workflow as an application called “PhotoDrag”. Now when I want to copy a folder of pictures over to Picasa, I simply ctrl + space to open QuickSilver, type “phtod” to open PhotoDrag, select the folder, and thats it. PhotoDrag will use scp to move it over to Picasa, and Picasa will automatically add it to itself.

In order to use PhotoDrag on other Macs, you have to grab the scp .action file as well and put it in that ~/Library/Automator folder.

As an aside, I used Mikon to quickly / freely / easily change the ugly default Automator icon into something more relevant.


Picture Backup with Rsync

July 30, 2006

snapshot6.pngUtilizing the Rsync setup I created earlier to backup the Documents folders of our laptops, I came up with a method to backup my newly organized picture collection.

The situation is as follows: My Ubuntu machine keeps the working copy of my photo collection and I would like to back up all the pictures as often as possible to the G3 PowerMac, which has an extra hard drive and is on all the time (its the webserver, printserver, MySQL server, etc).

To accomplish this, I set up passwordless authentication between these two machines, like in the other Rsync setup and then used this shell script on the Ubuntu box to get things moving:

#!/bin/sh
rsync -e “ssh” -rca –delete-after ~/PicasaDocuments/ username@192.168.1.x:/Volumes/back/pictureBackup -vv

/bin/date > ~/backup_script/log.txt

There’s not much difference between this and the previous shell script. This will build a list of the folders / files in the PicassaDocuments folder on my Ubuntu machine, and then match that list on the extra hard drive in the PowerMac (/Volumes/ is the location of all the mounted drives). the “–delete-after” means that if an item was deleted in the original folder, it will be deleted in the backed-up folder as well (not delete the originals after backing-up, like I feared it meant).

After this completes, it should write the date to log.txt in my home directory on the Ubuntu box.

Since both of these machines will be on most of the time, I decided to add this script to Cron to get it working every night. I used KCron (shown above), the KDE GUI to Crontab. Gnome has a Crontab editor too. I set it up to run this script every night at 11:15. After the initial backup of all the pictures, the process seems to run in 5 – 10 minutes. Its a bit taxing to the Ubuntu system, but it can handle it when nothing else is going on.

So with this system, I keep two copies of all my pictures on two different hard-drives. Not a bad deal.


Picasa on Linux

July 27, 2006

snapshot4.pngWell I finally got around to installing Picasa onto my Ubuntu box. Coming back from a 2 week vacation with a few hundred pictures got me interested in photo organization again. In my opinion, iPhoto is a dog. I wish this wasn’t true. I wish I could gloat over Windows users with the speed and ease of iPhoto, but I can’t. Each time I open that thing up I get frustrated. It organizes pictures in a convoluted date based system, it takes forever to start up, forever to scroll through pictures, and two forevers to do anything else.

I have avoided using iPhoto by trying out iView Media Pro for awhile. While it can organize photos in a much more systematic way, its still slow. Plus, every time I want to do something in that program, it takes me 30+ minutes to get it done. The UI is not very friendly to me, and options that I think should be obvious (like copying a picture to the desktop by dragging it there) aparently don’t exisit. Plus now that Microsoft has bought out iView, I don’t think this program is going to get any new exciting features any time soon.

And so I installed Picasa on Ubuntu. I found instructions which made the process trivial, so that was nice. I wish I could say that all my photo organization problems have been solved through Picasa, but alas, this is not the case. While I have seen Picasa work incredibly fast on very outdated Windows XP machines, on Linux on top of Wine, it remains sluggish and CPU intensive. However, this performance hit seemed to decrease after sitting there for awhile (I couldn’t tell you why). But while editing photos, I probably won’t be able to do much else. Picasa also seems to add extra folders to its viewer that it should be ignoring (the “originals” folders that appear after editing an image).

Even with the slowness, I think I will continue to use Picasa because its organization features are just that good. It takes the best of both worlds of sequential and event organization. The folders are arranged by date, and separated by year, but within this date system, you assign meaningful names to the folders. Plus all the image folders are stored at the same level. So instead of drilling down to specific days like you have to in iPhoto, i.e. 2006 >> 12 >> 25, you have folder names like “Christmas 06”. Plus you can tag your photos with keywords to help you find them later.

I know that iPhoto has some tagging features and the folder setup has gotten better, but it still doesn’t seem nearly as intuitive or easy to use as Picasa is. Plus, with 8,000+ photos, Picasa still moves faster than iPhoto on my iMac that has … 25 pictures.

Google: we’ll buy anything you want us to if you get a team of developers to make a Cocoa version of Picasa, I promise.

I also came up with a decent backup system and automatic-remote-picture-addition system that I will detail in the next few blogs.

Update: Aparently others have problems with iPhoto as well.  Not many solutions yet.


Welcome, G4, to your New Home

May 28, 2006

g4.jpg

Thanks to a very generous group of people, I now have in my possession a lovely new (for me) Power-mac G4.

It's a bit slow (400 MHz) but its running Tiger just fine. I looked this particular model up in MacTracker and it looks like it is a pretty decent machine.

What I plan on using it for is to combine all my server processes into one machine. Up until now, I had been using two computers to handle various tasks: web server, printer server, backup server, ftp server, afp server. The two machines I used before were a very old / slow machine running FreeBSD, and my newer 1 GHz Ubuntu box.

Printer sharing was a pain to set up in FreeBSD. That seemingly simple process took me probably a week to get it up and going. With Mac OS X, all the processes were set up simply by going into System Preferences and checking some boxes.

My afore mentioned custom backup system needed to get setup again on the new machine, but that wasn't difficult as Mac OS X already has rsync on it. I did have to add a new hard-drive in it, as the 10 gig default doesn't give much extra storage space, after the OS install. Hopefully that disk drive will last for awhile, but they are pretty old.

With all the excitement of the new Intel based Macs, it was kind of fun to be just as excited with a machine built in 1999.

My favorite feature of the PowerMac: The built in speaker. Combine this with iTunes and the "say" command and you get endless opportunities, like setting an alarm and have iTunes play me a song in the morning. Or press a button and have my Mac tell me the current time… or even the current temperature! Pretty exciting stuff. I'll have to play around with some scripts and see how much my Mac will tell me.