Mike Coutermarsh
  • Home
  • About
  • Twitter
  • GitHub
Sign in Subscribe

Using Bullet with Rails 2

The Bullet gem helps you optimize your Rails app by pointing out where you have N+1 queries in your code (check out this RailsCast if you have no idea what that means). I recently needed to set it up for an older Rails app, still running Rails 2. Here’
Aug 28, 2013

Install Java during build - Cloud66

If your Rails app requires Java and you’re using Cloud66, you’ll want to setup a script to automatically install it on your web servers during the build process. You can do this with deployment hooks. These let you specify shell scripts to run during the build process of
Apr 27, 2013

Setting up Redis on Cloud66 for Sidekiq

Cloud66 will automatically install and setup Redis for you after analyzing your app. By default Cloud66 will provide a REDIS_ADDRESS environment variable with the IP address to your redis server. To get it running with Sidekiq, add the variable to your Procfile. worker: env RAILS_ENV=$RAILS_ENV REDIS_
Apr 25, 2013

Sharing data across controllers - Angular JS & CoffeeScript

Here’s an easy way to share data across multiple controllers in Angular JS. First, setup a service that contains shared variables that you want to be accessible across controllers. I create getters/setters for each piece of data. This is a simple example. # shared attributes service. app.factory "Shared"
Apr 6, 2013 1 min read

How I hosted a local television contest for $2.37 on heroku

Big spender. There’s my heroku bill after hosting the voting for a local television contest. $2.37. Over 40,000 people used the app over a period of 2 weeks. I spent the same amount on coffee this morning. What?! How?! I’ve always been really interested in scaling
Apr 1, 2013 2 min read

Rails/Grape API - Simplify your PUT methods

Updating objects with Grape can be a little tricky and can lead to pretty bloated PUT methods. The simplest way to keep your code clean is to use update_attributes. Then you can pass in your params and update your object with just 1 line of code. project.update_attributes(
Mar 31, 2013 1 min read

Grape http basic authentication

Grape makes it really easy to secure your API with http basic authentication. Here’s a quick example on how to authenticate via HTTP basic with devise. class Api < Grape::API # /private resource :private do http_basic do |email, password| user = User.find_by_email(email) user && user.valid_password?
Feb 9, 2013

Terminal Tip: Rerun as Sudo

Ever forget to sudo a command? Instead of typing it out again, save yourself some time and try this: $ sudo !!
Jan 12, 2013

Heroku Tip: Pre-boot

When pushing new code to heroku, it shuts down and reboots your dynos. The problem with this is that it can take a few seconds for them to come back online. This makes your application really slow for anyone currently using it. The way to fix this is to use
Jan 3, 2013

Adding SSL to Heroku with Cloudflare

TLDR; Adding SSL to your Heroku app is easier and less expensive if you use CloudFlare. Heroku & SSL All Heroku apps already support SSL by piggybacking on Heroku’s SSL certificate (https://your-app-name.herokuapp.com). Unfortunately, if you need SSL on a custom domain, you’ll have to buy Heroku’
Dec 23, 2012 1 min read

Mathy-Poll - Voting API with Math CAPTCHA

Mathy-Poll is a voting API that asks basic math questions before recording the vote. It was originally written in Sinatra when I was still fairly new to Ruby. Today I had some free time and decided to move it over to Grape/Goliath. Grape is a micro-framework that’s specifically
Dec 19, 2012 1 min read

Grape/Rails API Cross-Origin Resource Sharing

If you want to allow access to your Grape API from other domains, you need to implement CORS! It’s easy with the rack-cors gem. Here’s how you do it. Add rack-cors to your gemfile. gem 'rack-cors', :require => 'rack/cors' Then go to your application.rb and add: [gist
Dec 16, 2012

geturl - provide path. get url.

Check this out. I’ve been using it for a couple months. Need to share a file really quick? Just run: geturl filename It uploads the file and places the URL in your clipboard. Get it on GitHub.
Dec 2, 2012

Organize your Grape API (in Rails)

Grape is a Ruby framework for developing API’s. It’s fairly easy to mount it onto an existing Rails application. One of the challenges I had with it was organizing the file/class structure. The Grape documentation is a little weak in this area. If your API has more
Nov 26, 2012 1 min read

Send email on your users schedule

The best time to send your customer email is when they are awake… and at their computers. When your customers are distributed throughout the world it gets a little tricky. We read somewhere that open rates at 9am and 4pm are significantly higher than any other time of the day.
Nov 16, 2012

Rails + Grape + API Key Authentication

When adding a Grape API to an existing Rails application you have a few options for user authentication. Probably the simplest and most basic way to authenticate an API is by issuing API keys to your users. How it works… 1. User submits their Username/Password to the API. 2.
Oct 24, 2012 2 min read
← Newer Posts Page 4 of 4
Mike Coutermarsh © 2023
  • HTML/CSS to Image API
  • Twitter
  • GitHub
  • LinkedIn