SSH Tunneling on Insecure WiFi

Using public wifi can be dangerous since the connection is inherently unencrypted. Whenever connecting to public wifi at coffee shops or airports I’ve always tunneled my traffic through my SSH server at home. This can be done fairly easily in a few simple steps (I’m working on a Mac but there’s plenty of tutorials to do this on Mac, Windows or Linux):

  1. ssh -D8080
  2. change your system’s proxy settings to use SOCKSv5 on localhost port 8080

OSX Networking Settings (Proxies)

This worked fine but I always worried that some traffic my not flow through my tunnel. I’d usually verify that everything was set up properly by visiting a site such as which echoes back your IP address (and verifying that it is my home IP).

However, this is error prone since you need to explicitly direct traffic through the tunnel and some applications may not use your system’s proxy settings. So I recently started redirecting traffic through the tunnel using a firewall rule rather than in specific applications. This ensures all traffic will go through the tunnel.

After doing some research I found a tool which acts as a transparent proxy called redsocks ( and configured my firewall to redirect. (adapted from

  1. install redsocks (sudo brew install redsocks)
  2. configure redsocks to proxy traffic from port 8888 to localhost:8080
    base {
        log_debug = on;
        log_info = on;
        log = stderr;
        daemon = off;
        redirector = generic;
    redsocks {
        local_ip =;
        local_port = 8888;
        ip =;
        port = 8080;
        type = socks5;
  3. install firewall rules to redirect traffic to proxy (sudo ipfw add 00100 fwd,8888 tcp from me to not me not dst-port 22)

So this worked great until I tried to connect to a vpn which was using split tunneling. VPN traffic would travel through the tunnel but all other traffic does not. Since my firewall rule was capturing all traffic I think it caused none of the vpn traffic to travel through the tunnel, so to fix this I added a rule with a higher precedence which would allow all vpn traffic through the tunnel.

  1. figure out what tunnel the vpn is using (netstat -nr)
  2. allow traffic to that tunnel (sudo ipfw add 00010 allow tcp from me to any via utun0)

From what I understand though, using a ssh tunnel as a vpn is not ideal since tcp over tcp can result in very poor performance. This seems to be working pretty well for me as a quick way to secure my internet access on the occasion that I’m on public wifi. I’m aware that this set up doesn’t tunnel my dns traffic but that can easily be done by adding a rule to route udp traffic through the tunnel as well.

Let me know if you guys have any suggestions or feedback!


Halloween Automatic Photobooth

Halloween at Workday is crazy. The office transforms in to different worlds from movies and video games (see photos from last year’s Halloween).

The theme for our team this year was Super Mario. Part of our decorations included a photobooth which captures photos of people punching a mystery box hanging from the ceiling. A trigger was rigged inside the mystery box (A) which triggered a pocket wizard (wireless transmitter). The pocket wizard fired off my camera (B) tethered to a laptop running EOS Utility. EOS Utility automatically downloads the image to the laptop and displays it on a 2nd monitor (C) for you to see immediately. I also wrote an application which continously scans for photos to upload to my SmugMug gallery and displays a QR code you can scan to get your photo (D).

Photobooth Setup

The photos were uploaded here:

Sample Image

Sample Image


Equipment Guide: Buying your first camera

I’ve been asked this question many times, so I figured I’d just blog it. The answer to the question “Which camera should I buy?” really depends on your budget and your style. The first question may be easy to answer, how much money you have… but the second question might require some discovery. With that said, this guide is really written with a specific friend in mind but I am providing my rationale for each item I’m listing here so hopefully this will be useful anyone who stumbles upon this page**.


I’m recommending Canon equipment here not necessarily because I think Canon is better, but because I shoot with Canon and I’m more familiar with the gear and because my friend who I’m writing this for is looking to buy a Canon. If you’re just starting off, I recommend you try out all the other brands too and see how you feel about them. IMO, a camera is a camera… but choose wisely because once you pick a platform you’ve got a lot of money invested in the lenses and probably won’t want to switch.

First, some plug:

  • Invest in good lenses first because they don’t obsolete, they keep their value and you can keep using them when you upgrade your body
  • Prime lenses are ideal for learning photography IMO. I have a post about this.

And some recommendations:

In the digital world, camera bodies become obsolete just as fast as computers. About every 12 months, Canon announces a new model. Thus, I’d recommend saving money on the camera body now, and spending more down the road when you can truly utilize the additional features on the camera.

Some more thoughts when picking a camera:

  • Megapixels don’t really mean much. Anything over 8MP is more than fine for most things you will be doing with your photos anyway.
  • Look at the maximum ISO for the camera and read reviews on how well they perform at each ISO. ISO is the sensitivity to light; the higher the maximum ISO, the better your camera will perform in low light. A typical entry-level DSLR will have an ISO range of 100-1600 iso to 100-6400 iso.
  • Hold the camera in your hands. While I’d generally recommend buying it online because you can generally get a better deal, it’s a good idea to stop by a camera store and try holding these bodies. You’ll realize that the Rebel series have very small grips and if you have large hands you might prefer to go with the 50d.

Rebel XS – Currently the least expensive DSLR in Canon’s lineup. This will set you back around $400-500.

Rebel T1i/T2i – If you’re interested in also doing video.

50D – This body is targeted to the “prosumer”. It has many of the features of Canon’s higher end cameras, but without the hefty price tag. It also has a more ergonomic grip.

40D with a 28-135mm lens attached.

Some thoughts about lenses:

  • Primes! They’re cheaper and they generally produce better photos for their price (compared to zooms). One of the characteristics that you look for in a lens is the maximum aperture. That is–how wide can the opening become?
  • You generally want a lens with a large maximum aperture. The larger the opening (the smaller the f-stop number — eg. f/2.8 is a larger aperture than f/4) the more light can get through (better in low-light situations) and the more background blur you get (referred to as bokeh)
  • Why do you care about bokeh? Nice background blur/shallow depth of field is one of the things that will set your photos apart from those taken with a point and shoot camera.
  • Lenses generally keep their value, so treat it as an investment.

Some Terminology (Canon):

  • EF – Is Canon’s lens mount. EF stands for “Electro-Focus” and replaces its predecessor, the FD mount (which is not compatible with EF). The cameras I recommended here will take both EF and EF-S lenses. EF-S is a subset of the EF mount which will only work on certain camera bodies.
  • USM – Ultrasonic Motor is the type of motor used in the lens’ AF (autofocus) system. USM is typically faster and quieter than the standard non-USM motor used in cheaper lenses. If you can afford it, find lenses with this type of motor. You can tell if a lens has this feature by looking at the name. For example, EF 24-70mm f/2.8L USM has this feature, whereas the EF 50mm f/1.8 II does not.
  • IS – Image Stabilized lenses have special gyros in the lenses that detect movement or vibration and compensate for the shift to mitigate blur in images.
  • f/xx – The maximum aperture of a lens is denoted by f/(value). For example, the maximum aperture of the EF 50mm f/1.4 USM is 1.4. Remember, smaller number means larger opening.


EF 50mm f/1.8 II – For around $100, you can get a lens that will get you very professional results. This is a prime lens so that means there is no zoom. At 50mm on these digital bodies, you’ll be fairly zoomed in making this lens ideal for portraits and still life photography. Its a great lens to start off with but if you mainly want to shoot landscapes, you may want to consider a different lens. Check out the Flickr pool to see what people have done with this lens: If you can afford to spend a little more, go for the EF 50mm f/1.4 USM. It has a nicer autofocus (AF) motor/focus ring and it has a slightly faster aperture (meaning that it can perform better in low light).

The Sigma 30mm f/1.4 is a great lens. 50mm used to be the “normal” lens on 35mm film bodies because the field of view closely mimicked the field of view for human vision. These digital camera bodies have a 1.6x crop-factor compared to 35mm film so (30mm * 1.6x gives you 48mm) which is very close to the normal field of view. I really believe that prime lenses are the best way to learn photography because you can focus on composition and exposure. This is a great lens to do that with. It has a HSM AF motor which is Sigma’s equivalent to Canon’s USM.


If you’re going to be shooting a lot of landscape or stuck in tight spaces, you might want a zoom lens. Note that the 50d kit comes with the 28-135mm. I’ve shot with that lens for many years and I love that lens. It’s a good deal and a great beginner’s zoom lens. The other two lenses are very new in Canon’s lineup. They are a bit wider than the 28-135 so you get a wider field of view.

You’ll notice that the less expensive Canon zoom lenses have slower apertures than the expensive one which has f/2.8. If you’re going to be shooting in low light, it is best to get a zoom with a fast aperture. Also, these f/2.8 lenses do not change apertures as you zoom. The EF 28-135mm f/3.5-5.6 will be f/3.5 when you’re zoomed to 28mm and f/5.6 when you’re zoomed to 135mm which is slightly annoying to compensate for. Essentially, this Sigma lens gives you that nice fast aperture for a relatively cheap price tag.


If you’re shooting sports, I recommend the 70-200mm. It is one of the cheapest L-series lenses you can buy (L-series is Canon’s high-end lenses that feature superior glass and build quality). I have shot with this lens for many years and still have not outgrown it. It produces stunningly sharp images and the AF motor is blazingly fast. If you are planning on doing portraits, the 85mm 1.8 is a great choice. It produces amazing bokeh and has a reasonable price tag.


Pick a body, and then pick one or two lenses to go with it. I started off with the Rebel XT. For a while my kit was the 28-135 with the 70-200. I used the 28-135 as my walk-around lens and 70-200 for portraits and shooting sports. If you have questions, want some recommendations or advice, feel free to leave a comment or email me at me at prenticew dot com.

Hope this guide was useful.

** – If you’ve stumbled upon this page some time in the future, its worthwhile to look at what’s new. Lenses won’t change very much but the camera bodies will.

, , , , , , , , , , , , , ,


You know its finals time…

Analytics Pageview Rankings

A few quarters ago, I took PHIL 230. Our final exam had a quote id section so I quickly wrote a quiz app which I distributed to the class. Since then, the professor has been circulating the link as a study tool. So once a quarter, my web traffic spikes a day before each final exam :).

Last Quarter's Statistics

This Quarter's Statistics

Pageview spike this quarter

Last Quarter's Statistics

If you want to try it out, swing over to:

DISCLAIMER: I wrote this in all of two hours or so and never looked back… I know there are some backend flaws, so don’t break it please :)

No Comments

Senior Project Done!


Finally! It is done! The weight of 50 pages of senior project in my hands make me happy. If you’re interested in reading it, it’ll be up on digital commons soon enough (keep an eye out for a link).




Learning Photography — Prime Lenses

Whether you’re new to photography or you’ve been shooting for a while, if you’re still using your kit zoom lens — you should consider getting a prime lens as your next lens.

July 16 - The Spiffy New Lens
An EF 85mm f/1.2L II mounted on my 40D

What is a “prime” lens? A prime lens is a lens with a fixed focal length meaning that it can not zoom. So you may wonder why in the world would you want to get a lens that doesn’t allow you to zoom? Well there are at least a dozen reasons I could give you — among them: primes are cheaper (generally for the quality you get), sharper, and faster.

Zoom optical systems are generally fairly complex because they have to correct for more factors; thus, with a simpler design, primes often require less glass (lower price) and/or produce a higher quality image (higher image quality). Furthermore, prime lenses often have larger apertures (especially for the price). You’ll find primes with apertures around f/1.4 for under $500, whereas most zoom lenses with an aperture of f/2.8 are going to very likely cost over $1k! Faster apertures also make these lenses great for taking photos at night or in a dim room without a flash. The shallow depth of field makes these lenses great for taking portraits with a beautiful background blur as well.

In addition to the tangible benefits, prime lenses also help reinforce important concepts in photography. Many photographers become lazy and use zooming to compose their images. Zooming rather than physically moving yourself to recompose your shot makes a big difference! Using a prime lens forces you to move around to recompose and makes you a better photographer. Using a prime also encourages the photographer to focus on other thing such as focusing and exposure.

Shows the same subject shot at 24mm vs. 200mm.

Shows the same subject shot at 24mm vs. 200mm.

You can see in this example that the same subject shot at two different focal lengths produce two extremely different images. Notice how the wide shot at 24mm emphasizes the shape of the glass and there is quite a bit of the background in view. In contrast, the 200mm shot compresses the detail and the glass looks pretty flat. Not as much of the background is also in the shot because the field of view is narrower. Because of this, telephoto lenses are generally preferable for shooting portraits because it does not emphasize facial features such as the nose or chin.

So which lenses should I get? Here’s a list of some prime lenses…

Read the rest of this entry »

, , , , , , , , , , , , , , , , , , , , , ,


Cal Poly Spring Dance Show 2010

Highlights: Cal Poly Spring Dance Show – Images by Prentice Wongvibulsin


This year’s student choreographed dance show was even better than last year’s! You can find all 250 photos in the gallery below ( Also, photos from last year’s show.

Spring Dance Show 2010 – Images by Prentice Wongvibulsin

, , , , , , , , , , , , , ,

1 Comment

Discovering Research Week at Cal Poly YouTube Ad

This begun as just a joke over dinner, that we should do a spoof of “The Man Your Man Could Smell Like” commercial for Old Spice, and now — here it is:

Discovering Research Week @ Cal Poly (

When we shot this, we didn’t actually have the Discovering Research Week passports so I got to use Mocha for AE for the first time. Mocha is AMAZING. I also never used the sky as a blue screen before but it worked surprisingly well!. Unfortunately it was very windy when we shot this and I lack time and fancy-expensive equipment to make things better. All this was shot on camcorders rented from MDS on campus. Maybe some day I can afford the 5D Mark II :).

Special Thanks to
Dana Tryde at Clark Valley Farm
El Abar the horse
and Kara Schricker

If you’re bored, check out the other commercials I’ve done for eWeek:

No Comments

Jen at Sunset






No Comments

Erasing Iterators from STL Containers (STL Vector, etc.) in a Loop

for( vector<aType>::iterator it = aVec.begin(); 
      it != aVec.end(); 
      it = (*it).shouldDelete()?aVec.erase(it):it+1){
   // do stuff

, , , , , , , , , ,