Fantom wrapper for Mailgun

April 17th, 2013

Posted a Fantom wrapper for Mailgun. Has first-class support for basics (send, unsub, spam, bounces, logs, stats). But really simple to work with raw REST API too.

The Fantom Linode Guide

February 27th, 2013

I’ve stubbed out a basic guide for getting Fantom up and running on Linode. Its a bit of a work in progress – but mostly gets you from start to finish:

  • Installing Fantom on Debian
  • Setting up init scripts
  • Configuring ngnix as proxy server
  • Setting up automated deployments

Its hosted on BitBucket – so feel free to send me pull requests if you have corrections or improvements (I’m by no means a linux guru…):

https://bitbucket.org/afrankvt/fantomlinodeguide

init.d example for Fantom

August 15th, 2012

Update 27 Feb 2013 – While this should still be valid advice – it’s been superseded by a more comprehensive guide covering the whole process of getting Fantom up and running on Debian: http://www.andyfrank.com/blog/2013/02/fantom-linode-guide/

––

Been meaning to post this for awhile. Below is the init.d script I use to run Fantom on my personal sites. I’m running Debian 6 – but should be straightforward to tweak for other distros. Might need to apt-get a few things like pgrep – can’t remember what came out of the box.

A few caveats:

  1. I always install and run each “app” using a dedicated user with its own Fantom runtime. I find this really simplifies security, process management, and versioning. This example uses the fan user.
  2. This script should properly block until process cleanly exits. But don’t have a good way to know when start is complete – so just waits a few seconds. You can tweak depending on your app.
  3. This script redirects stdout and stderr to the same log file. You can tweak as necessary.
  4. I’m using a script (boot.fan) to launch my site. But you can launch Wisp or another main directly from bash string.

Example server layout:

    ~/               User home directory
      fantom/        Fantom runtime
        bin/
        lib/
        ...
      dist/          App path env
        fan.props    Empty fan.props to force PathEnv
        lib/         PathEnv lib for App
        ...

Example init.d script for Fantom:

    #! /bin/bash
    # /etc/init.d/example

    FIND_PID="pgrep -u fan java"
    STDOUT=/home/fan/var/stdout.log

    case "$1" in
      start)
        PID=$( $FIND_PID )
        if [ -f $PID ]; then
          echo "Starting example.com..."
          sudo -u fan bash -c  'cd ~/dist; ~/fantom/bin/fan boot.fan &' &> $STDOUT
          sleep 3
        else
          echo "example.com is already running"
        fi
        ;;
      stop)
        echo "Stopping example.com..."
        PID=$( $FIND_PID )
        if [ -f $PID ]; then
          echo "example.com is not running"
        else
          kill $PID
          while kill -0 $PID 2> /dev/null; do
            sleep 0.5
          done
          echo "stopped"
        fi
        ;;
      status)
        PID=$( $FIND_PID )
        if [ -f $PID ]; then
          echo "example.com is not running"
        else
          echo "example.com is running"
        fi
        ;;
      restart)
        $0 stop
        $0 start
        ;;
      *)
        echo "Usage: /etc/init.d/example {start|stop|restart|status}"
        exit 1
        ;;
    esac

    exit 0

Cinco de Mayo meets Kentucky Derby

March 24th, 2012

Weekend project for a friend.

Cinco de Mayo meets Kentucky Derby

Converting Linksys WRT54G to Wireless Bridge

March 5th, 2012

We’ve been doing some repurposing of rooms the past week or two. In the process, an office got moved to the opposite side of the house from our FiOS modem. That office unfortunately is home to a circa 2005 Dell Workstation with no WiFi support.

Since I had an unused Linksys WRT54G router collecting dust, I spent a few minutes googling if I could use that to avoid stringing Cat5 down my hallway. Turns out with the help of some open source firmware (DD-WRT), you can do just that (and more).

The overall process is pretty straightforward – but as is common for this type of thing – lots of out-dated, inaccurate, or not fully defined documentation. So I thought I’d add to the mix ;)

What This Post Covers

Just so you don’t waste time readings this – this post specifically covers:

  • Linksys WRT54G ver 2.0
  • Installing DD-WRT firmware v24 SP2 [Beta] Build 13064
  • Configuring router as a Client Bridge
  • Issues using WPA2 security
  • Primary router is a Verizon FiOS ActionTec MI424WR-GEN2 (firmware version 20.19.8)
  • Date just for reference: March 2012

Bridge vs Repeater vs Yadda Yadda

I’m no expert in this area, so I took some time to get my bearings on what I actually needed to accomplish. There are lots of terms and setups, and overlaps between setups, but a bit of googling should set you straight.

In my case, I simply wanted to join a second LAN network over a wireless “bridge.” The second network would not provide wireless access, so the primary router is the only wireless access point for clients. So we want to setup our second router as a Client Bridge.

If you wish to also provide wireless access from the second router, I believe you want to configure it as a Repeater Bridge – which requires different instructions than I present here. More information on the different modes:

http://www.dd-wrt.com/wiki/index.php/Repeating_Mode_Comparisons

If any of this information is inaccurate, please let me know.

Installing DD-WRT firmware

DD-WRT is a Linux distribution which replaces the factory firmware, opening up lots of additional features for routers like the WRT54G. Since I only really cared about the bridge capability, I chose the micro binary. Wikipedia has a good overview of what each version supports:

http://en.wikipedia.org/wiki/DD-WRT

This video covers very simple and clear instructions on installing DD-WRT firmware onto the WRT54G (ver 2.0) – from downloading the binary to uploading the firmware onto the router:

http://www.youtube.com/watch?v=QZ_oW8-fmIA

I had no issues following these instructions – and were alot simpler than some other ones I came across. Once complete you should see the new DD-WRT admin console when you pull up 192.168.1.1 in your browser.

Configuring Router as a Client Bridge

Once you have DD-WRT up and running, we need to configure the router to act as a client bridge. The best instructions I found for this are here:

http://www.dd-wrt.com/wiki/index.php/Client_Bridged

These again worked (almost) without incident. If the primary router is configured for WPA2, things will likely not work from my experience and what I could find online. Luckily it’s very simple to isolate the issue to security. Disable security on both the primary router and your second router, then retry, and everything should work like a charm.

Using WPA2 Security

If your primary router is setup to use WPA2, and things didn’t work, you have a few options:

  • Drop to WEP security
  • Drop to WPA security
  • Enable WPA2 TKIP + AES support on primary router, WPA on secondary

Both WEP and WPA should work just fine between the DD-WRT and your primary router. I spent a good deal of time trying to find a way to maintain WPA2 on my network, and the only real solution was to enable mixed mode.

So configure your primary router to use WPA2 TKIP + AES, then set the DD-WRT to use normal WPA security. This worked for me without a hitch. I would assume this only reduces protection for the traffic over the bridge, while all traffic over the primary router should be using the more secure AES encryption. But I really don’t know enough about this stuff to say for sure.

Would love to know if this is accurate, or if enabling TKIP + AES reduces security overall.

Markdown for Fantom

February 5th, 2012

Sunday Funday project for today – Markdown for Fantom:

https://bitbucket.org/afrankvt/markdown

Markdown is a great little plain-text format created by John Gruber that converts nicely to HTML. Fantom’s own Fandoc was heavily inspired by Markdown. We just simplified a few things and added some Fantom conventions in a few places. But I’ve wanted the full Markdown syntax at my disposal for some time now.

Luckily it was a pretty simple project – I was able to essentially take the great Markdownj work as-is and wrap with a native Fantom API. Code is available over at BitBucket and is licensed under the BSD license.

LESS for Fantom

January 22nd, 2012

I worked up a Fantom wrapper around LESS this week. Code and docs over on BitBucket:

https://bitbucket.org/afrankvt/less

LESS is a great little “extension” to CSS that adds lots of convenient features like variables, mixins, and nested rules that make developing and managing complex CSS much easier.

The Fantom wrapper adds:

  • An API interface to compile LESS files from a Str input or a File reference
  • A simple command line interface for compiling LESS files to CSS files
  • A BuildTask for integrating LESS into your Fantom build pipeline

Draft Mini Web Framework

July 24th, 2011

I’ve posted a project I’ve been working on in my spare time recently:

Draft Mini Web Framework

Draft is a small web framework designed to notch in above WebMod, provide some useful features, while trying to leave as much freedom as possible for your app. Details over on the project site.

Its still a work in progress, but decided it was far enough along to start being useful to anyone who doesn’t mind getting their hands dirty. Hopefully I’ll have it wrapped up here in the next few months, and can be more generally useful to developers looking for a simple and lightweight solution for developing web apps in Fantom.

Sketching Logos

January 5th, 2011

Was flipping thru an old moleskin and found two sketches I made back in Fall 2009.

Fantom logo sketch

First was a little sketch of a potential logo for the Fantom language. For whatever reason, when we changed the name to Fantom, I got this 1920s/Art Deco motif concept in my head (hence the typeface). I’m pretty sure its because of the movie The Shadow, but I keep trying to tell myself thats not the case… Never really had time to come up with a real logo — but this is one I sorta liked.

Axon logo sketch

Second was a logo for the Axon scripting language we designed for our day job at SkyFoundry. Would love to give these both some good Photoshop treatment if I ever find the time.

Blue Collar Languages

September 27th, 2010

Cay Horstmann wrote an interesting response to Stephen Colebourne’s NBJL post:

Creating a “blue collar” language isn’t something that happens every day.

When done by “blue collar” people who have sketchy knowledge of programming language theory, the result is often problematic. Look at PHP–I trust that I won’t have to elaborate… Or Groovy, many of whose properties (particularly in the MOP) are under-specified and constantly shifting.

Few “white collar” people have an interest in designing a blue-collar language. They give us languages that dazzle us with their brilliance and innovation. After all, that’s what a researcher is rewarded for.

Interestingly he made no mention of Fantom in this context, which means I assume he hasn’t looked at it any detail. That was one of the explicit design goals.

Which makes me wonder – do people pass over Fantom because of the exact same reasons they search for new languages? You want a simpler, more expressive language, with great APIs, that make your life easier 9-5. But you take a look at Fantom, and move right along, since you don’t see buzzwords like monads, or some ground breaking new syntax?