base16 Color Schemes

I spotted a nice set of color schemes called base16 and eighties is my favorite. All you have to do is pull down the base16-builder repository and call the ruby script with the color scheme you like best.

git clone https://github.com/chriskempson/base16-builder.git
cd base16-builder
./base16 schemes/eighties.yml

After a few seconds, the output directory will contain color scheme files that are compatible with apps such as atom, console2, sublime text (textmate), visual studio, and many others.

Send and Receive SMS Through Tropo

I wanted a Tropo script that could send out text messages via the REST API as well as forward text messages that were received through the Tropo phone number. This snippet shows how I identified and handled the two cases.

if $action == "create"
  # Script called from REST API
  call "+1XXX5551212", {:network => "SMS"}
  say "Sample Message Text"
else
  # Script called from incoming SMS
  callerId = $currentCall.callerID
  text = $currentCall.initialText
  message "#{callerId} => #{text}", {:to => "+1YYY5551212", :network => "SMS"}
end

ServiceStack Cache Control Filter

While testing with a Microsoft Surface, I noticed that API data was always stale. Regardless of any updates, the browser continued to show the same data as if it had never changed.

The browser cached the original GET requests, and now any GETs to that same resource returned the data from cache. As a first attempt to address the issue, I created a request filter to set the Cache-Control header.

public class NoCacheAttribute : RequestFilterAttribute
{
    public override void Execute(IHttpRequest req, IHttpResponse res, object responseDto)
    {
        res.AddHeader(HttpHeaders.CacheControl, "no-store,must-revalidate,no-cache,max-age=0");
    }
}

Simply add [NoCache] to your service or method to keep the browser from caching the resource.

In the future, I want to take a look at using ETag in conjuction with the Cache-Control header. You can vote for ETag support in ServiceStack at UserVoice .

Hello World

public class HelloWorldService : Service
{
    public object Get(Hello request)
    {
        return "Hello, {0}.".Fmt(request.Name);
    }
    
    [Route("/hello/{name}", "GET")]
    public class Hello
    {
        public string Name { get; set; }
    }
}