Dan Schaefer is a web designer living in Ventura County, California. He’s been a part of several startups, doing everything from engineering to sales to marketing.
Uno! Use Sinatra to Implement a REST API
The REpresentational State Transfer (REST) architecture provides a very convenient mechanism to shuttle data between clients and servers. Web services and protocols, like HTTP, have been using the REST architecture for many years, so it is a well-tested and mature concept.
A Simple Admin for Padrino
Padrino is an excellent website framework that makes it easy to implement complex web applications in a lightweight environment. Although it’s built on Sinatra, Padrino uses a Rails-like approach when generating code, establishing an organized file structure, and implementing database functionality.
This article briefly introduces the Padrino framework and how it can be used to create a simple admin interface within a Sinatra-like environment.
A Brief Introduction to Sinatra
In a nutshell, Sinatra is a DSL (Domain-Specific Language) that processes HTTP connections. Specifically, Sinatra compares incoming user requests with entries in a list. When the first match is found, Sinatra executes the associated code and sends the results back to the user.
For example, consider an HTTP[ruby]
GETrequest arriving on this URL:
The DSL code within your Sinatra implementation may look like this:[ruby]
get ‘product/laces’ do
get ‘product/shoehorn’ do
put ‘order/shoppingcart’ do
In the above code, the words
putmay look like Ruby commands, but in reality, they’re part of a filter that looks for HTTP verbs like
Eye-Catching Animations with GreenSock
In this article, I’ll briefly describe the GreenSock tools for tweening and timeline construction.
A Brief Introduction to Tweening on a Timeline
Animation developers use “tweening” to fill in frames of animation between two points in time. (The word “tween” is derived from the word “between.”) For example, when a developer wishes to animate a ball rolling from point A to point B, she need only draw a picture of the ball at each endpoint and let the computer fill in the frames between.
Animation developers use timelines to move their animations along. For example, the developer specifies precisely when the ball gets released from point A and when it arrives at point B. Additionally, the developer uses an “easing” function to govern how the ball accelerates and decelerates along its path. Easing gives the appearance that the ball conforms to familiar laws of physics.
Tweening on a timeline can get very complicated, especially when there are several objects moving around the screen, each with its own path, speed, and timeline. It gets even more complicated when revisions need to be incorporated after the design review. It turns out that it’s far easier to revise tweens and timelines programmatically rather than graphically. In other words, instead of arduously redrawing frames with revision, you simply change some of the numeric variables.
The GreenSock Tools
The names of the GreenSock libraries are self-explanatory: The “Tween” libraries allow you to tween visible elements around the screen, and the “Timeline” libraries allow you create independent timelines on groups of objects. Note that an object can be a part of more than one timeline.
Let’s look at a simple example to see how tweening on a timeline works with the GreenSock tools.
Visualizing Data with D3