Using Webhooks.io and RequestBin for Early Phases of a Rails Application

Earlier today I wanted to use Getstream's real time webhooks feature. To enable the feature, I had to get in contact with their support team and provide my app id, feed slugs and my callback URL for the webhook. But there was one problem, I didn't have a callback URL since I'm only in the beginning phases of using this feature.

I had the option of giving a temporary callback URL. I decided against this because I didn't want to be dependent on contacting them to make the URL change later. Instead, I decided to do some research to see what my alternatives were. Surely, I'm not the only one who has ran into this problem before.

During my research I discovered webhooks.io and I'm glad I did. Webhooks.io can serve as a reliable and scalable proxy for your webhooks. You can set up buckets in order to route the different webhooks your application might consume. For every bucket, you provide inputs and destinations.

Webhooks.io Bucket Configuration

The following shows how I setup my bucket configuration within webhooks.io. Webhooks allows you to create multiple destinations for a single input, but for this example we will be creating a single destination. The input will be the request from get stream and the destination will be a new RequestBin. We are using RequestBin in this example so that we can inspect the getstream payloads. This is temporary since we have not built a callback feature into our Rails application.

getstream_webhooks_requestbin.png

Input - New Callback URL

Instead of configuring getstream with:
https://www.MyRailsApplication.com/callbacks/getstream

Get stream will now call:
https://gateway.webhooks.io/v1/getstream/ReallyLongID

Destination - Where to Route The Request

  1. Create a new RequestBin at http://requestb.in/
  2. Within webhooks.io, create a new destination and set the Endpoint URL to your new RequestBin URL

Now, when a request comes into webhooks.io, that request will be sent to your RequestBin. Now we can inspect the HTTP requests that are being sent from getstream prior to development. We also have the added benefit of using the sample request payloads in our integration tests during development.

But remember, RequestBin is only a temporary solution while developing the callback functionality within the Rails application. Once you have built that feature, you can easily create or modify the destination to point to your Rails application.

getstream_webhooks_rails.png

Grid Size Display Indicator with a Gem: rails-bootstrap-sass-grid_size_display

Have you ever wondered if you're viewing a col-xs-* or a col-sm-* grid when using Bootstrap? If you're using Rails and the bootstrap-sass gem, take a look at this new gem I wrote: rails-bootstrap-sass-grid_size_display. It adds a bar at the top of the page that changes colors based on the grid breakpoints.

The gem uses the media queries defined in the Bootstrap documentation:

@media (max-width: @screen-xs-max) { ... }
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... }
@media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... }
@media (min-width: @screen-lg-min) { ... }

You can even control when to display the bar using query parameters.

Take a look at the documentation here:
https://github.com/jgdreyes/rails-bootstrap-sass-grid_size_display

I hope you enjoy!

Permutations, Combinations and URL Shortening - Creating random tokens

I have a model, let's call it Post. I want the public URL for a post record to be similar to Instagram's public URLs: https://www.instagram.com/p/BC3HEDGiJrp.

Instead of using post#id as the identifier in the URL, I'll use a token. The token doesn't need to be difficult to guess or secure, but it needs to be unique and URL safe.

Instead of using the often suggested SecureRandom let's follow blog.codinghorror.com's approach on URL Shortening. Towards the end of the article, he asks: "Each new URL gets a unique three character combination until no more are left. How many URLs would that take?"

And it just takes a bit of math to figure it out! Permutations to the rescue. Or wait, is it combinations? Let's have a quick refresher:

If the order doesn't matter, it is a Combination.
If the order does matter it is a Permutation.

For post tokens, order does matter so we will use permutations. Luckily Ruby's Array class defines a few methods that are helpful for this:

  • array#permutation
  • array#repeated_permutation - allows for character repeats
  • array#repeated_combination - allows for character repeats

It is to our advantage that we can generate the set of possible tokens ahead of time. Now, when a new Post is created, we can assign it an unused token. This solves our problem of making sure each token is unique.

Here's the final code:

How I got over my fear of sleeping outdoors

Last night I slept outdoors for the first time in my adult life.

my MSR Hubba Hubba NX Tent at our farm campsite

my MSR Hubba Hubba NX Tent at our farm campsite

I used to envy friends who would tell me about their camping adventures. I too wanted to sleep on a beach, camp in a Redwood forest and especially experience Yosemite overnight. But I just couldn't get myself to do it. I was scared. There were too many unknowns and everytime I started to plan a trip I would feel so overwhelmed with fear that I would convince myself overnight trips were not for me.

But this year is different. This year I'm tackling my fears head on. So I set a date and planned a camping trip. Here's how I did it.

Book it and just go!

I figured if I book a campsite then there's no turning back. Having a concrete date set and a little bit of money on the line really helps me feel committed to doing something. I attempted to use reserveamerica.com and found myself over-researching trying to find the best campsite for the dates available. Luckily I stumbled upon Hipcamp, think Airbnb for camping. There are plenty of sites available to those who live in Northern California so I picked one and booked it.

Buy some gear

Now that I had a date set, I needed some gear. I didn't have a tent or a sleeping bag and in my usual fashion I decided to do a ton of research on the gear I needed. I knew eventually I would want to go on a multi-day backpacking trip so I opted to keep all of my gear light and packable. I watched a ton of videos on how to properly pitch various types of tents and opted for something that was super easy to set up. Once I found the tent and sleeping bag I wanted, I went to REI and purchased it.

What will I eat?

my msr pocket rocket stove, msr fuel canister and gsi minimalist cookset

my msr pocket rocket stove, msr fuel canister and gsi minimalist cookset

I wanted to try freeze dried food so on my trip to REI I picked up a few Mountain House MRE's. I went home and did a practice run with them for dinner. The food was pretty tasty and I was excited to bring them on my trip. But I had another problem. I'm terrified of fire and I hate lighting matches. So much so that even lighting birthday candles scare me. So how was I supposed to light a campfire or get the backpacking stove started? I decided to bring a long barrel lighter so that I could put some distance between me and the camping stove. When it came time for dinner I lit the lighter and had my husband turn on the stove. We alternated so I had practice with turning on both the lighter and the stove.

Scared of bugs

I have an irrational fear of bugs. And I knew that sleeping outdoors would present an interesting challenge for me. I decided to setup a few rules at our campsite to avoid bringing home the creepy crawlies:

  1. Close every bag
  2. Check for ticks every hour
  3. Keep the tent zipped up
  4. Launder clothes right when we got home

My husband thought most of these rules were pretty silly, but it helped keep me sane. The first hour I was constantly swatting bugs away from me, but I quickly got tired of doing that and stopped. Eventually I got so sleepy that I just decided to take a nap and I'm sure there were tons of bugs near me. I just didn't have the energy to worry about them so much.

And that was it. After this one trip I've decided I love camping. I'm still scared of bugs and fire, but now I realize there are ways to contain the fear. I can't wait to go camping again and hopefully go on my first backpacking trip!

5 Reasons Why We're Moving to Boulder

I absolutely love San Francisco. I love it so much that I've never left it. So why have I decided to pack up and move? Because I want to experience what it's like to live outside of my hometown and I can't think of a better place than Boulder.

After both of my visits I came back home thinking, "Boulder is a place I could move to." So I'm doing it! I'm packing up my bags and moving to Boulder for 2 months. Here's why I've decided Boulder is a great first stop for me.

Coffee shops

Pearl street alone has an abundance of coffee shops. It seems as if there is one on every block. Most of them are pretty low key and I'd be happy to call any of them my office for the day.

Try: Ozo Coffee on Pearl

Rocky Mountain National Park

The park is absolutely beautiful. It's an easy hour drive from Boulder and gives you access to beautiful landscapes. Summer hiking is stunning and back country snowshoeing trips are an absolute must.

Nymph Lake in Rocky Mountain National Park - Andrew E. Russell

Nymph Lake in Rocky Mountain National Park - Andrew E. Russell

Try: Guided trips with Footpaths of the World

Local Hiking

There are tons of local hiking trails right in the city. I'm super excited to hike the Flatirons and not even have to leave the city. And since I'll be working part-time, I'll be able to visit the trails during the week and hopefully avoid the crowds.

Try: Flatirons 1-2 trail

Tech

Boulder has a tech scene. It may not be huge, but there's a good presence. It was fun to walk around Pearl Street and see startup signs next to the local restaurants and coffee shops. It's also great because that means that Boulder has coworking spaces.

Try: Impact Hub Boulder

Food

There's a lot of variety of food here. And you can pick if you want to indulge and grab tasty burger and fries or go healthy and choose a Paleo friendly meal.

Try: Amu, Blooming Beets Kitchen


San Francisco is a really hard city to leave, but I'm ready to move to Boulder. I'm excited to try something new, especially in a city that has so much to offer.

I'd love to hear what you loved about Boulder!

Benefits of Coworking Spaces for the Individual

desk_plant.jpeg

I love working out of coffee shops. As a remote software developer, one of the biggest perks I have is the ability to work from anywhere. My top choice would be at a local coffee shop. Why? Because everyone is pretty chill and purchasing one cup of good coffee buys me hours of free WiFi, a good spot to code and unlimited people watching!

There are drawbacks though. For one, who will watch my machine when I have to use the restroom? What do I do if there are no outlets to charge my devices? And the most important question: What if I make the trip all to find that there are no tables?

What if I make the trip all to find that there are no tables?

If you’re constantly running into these issues, I highly suggest trying out a coworking space. Coworking spaces are now more accessible and affordable for individuals/freelancers. Many offer day passes so you don’t have to commit to monthly memberships. You can choose when you want to go so you still have that freedom. Some do cater to startups and are solely for monthly members so it’s always a good idea to check the company’s website or call to see if they offer day passes.

If you're in San Francisco and are looking for affordable day passes, try one of these:

Some may argue that the cost of these day passes don't justify the benefit. For me it does. I enjoy not having to worry about a crazy person coming in and trying to snatch my backpack. The noise levels are decent since most companies have either silent areas and noise policies. And best of all, I know there will be space for me!

Where are some of your favorite coworking spaces?