I made Chloroform

rubyrailsmongodbapplications

I need a contact form for my site so I made a thing. It’s called Chloroform and anyone can use it.

Testing sessions in Sinatra

sinatratestingrack

When testing an authentication system within Sinatra one of the things needed to be tested is that a session variable has been set, usually to the users unique id. Unfortunately as of Rack >= 1.0 it is not possible to set the session during the request.

Require entire Rack app for testing

rubyracktesting

When testing a Rack app, such as Sinatra, it’s easy enough to require the file your app is in. However, I like to split up my helpers, models and routes into seperate files and need to require the entire app at once.

Static site blog search with Tapir

javascriptapi

Creating a search facility for a static site can be quite tricky. But thanks to a handy web service called Tapir it’s never been easier. As long as your site has an RSS feed Tapir will index the feed and the results can then be easily searched with the Tapir API.

Uploading files with Sinatra

rubysinatra

Sometimes it’s the simplest things that slip my mind. Like how to uplaod a file, for instance. How? Like this…

In-browser design with Guard and Rack

rubydesignrackguard

I’ll admit when it comes to web design the only time I touch Photoshop is when I need a quick graphic for a site. Almost all of the design work is done live in the browser. A side effect of this used to be editing a document. Compiling it (if it was sass, haml etc.) and then going back into the browser and refreshing.

Not anymore. With a little help from some Ruby libraries and a small browser plugin any change is updated almost immediately in the browser.

OmniAuth with Sinatra

sinatraomniauthauthentication

Back in Episode #241 - Simple OmniAuth of Railscasts, Ryan Bates showed how to easily use OmniAuth as an option for logging into your web apps. As I’m not a massive Rails user and prefer to use Sinatra for my small/medium sized applications I ported his code to Sinatra and used DataMapper instead of Active Record.

Login to server via SSH without a password

ssh

If you’re anything like me then logging into your server via a terminal is a daily occurance. And it’s common tasks like this that are perfect for a bit of automation. By following these quick instructions you will be able to login to your remote server with just two words in your terminal, and no need for a password to be entered in the process. Lovely stuff.

Javascript countdown timer

javascript

Need a quick countdown timer in Javascript? Here you go.

Roll your own Sinatra authentication

sinatraauthenticationtutorial

At some point in time you are going to want people to login to your website. If you’ve currently been using Sinatra and need this feature, you might be tempted to reach for Rails and use a hand gem. Wait! It’s not that hard. In tutorial I’ll show you how to easily roll your own authentication and create a basic platform for a user based website.

This tutorial assumes you have an understanding of Sinatra and DataMapper. If not go have a quick look now. They’re so easy it’ll only take a minute.

New VPS can't resolve any external address

vps

If you’ve just set up a new VPS and are having problems resolving any external addresses while trying to install/download software the following might help. It did for me!

Paginate an array with Ruby

ruby

Here’s a quick one to paginate an Array in Ruby. This little Array monkey patch makes it easy to paginate an array of pretty much anything.