I've been working on an app that asks for the user's zip code as part of an application process. I thought it would be pretty nice if I could leverage my old angular geolocation service and layer in some geocoding. After browsing around I found a way to do this using the Google Maps geocoder service.
This code will use the brower's geolocation to determine your latitude/longitude and pass that into the google maps geocode api. The geocoder will return a whole bunch of other details such as your city, state, address, etc - but this code only cares about your zip code right now.
Something to keep in mind is that I'm not including a google maps API key in this example, and I'm not certain what the limitations are, so this isn't exactly production ready.Continue Reading
If you're a rails developer you've probably tackled forms which update multiple models and have their own custom validations and/or business logic involved. I'm talking about forms like Signup which may need to create a few other models after the User has successfully been saved.
I've recently had to build a signup form which would create or organization, then create a new postgres schema for the organization, then build the administrative user model and also capture payment. Doing this with simple
after_create calls would most likely wreak havoc later in life so I've split this out into a separate
If you need to customize the field name for ActiveRecord validation messages, I wrote this quick little
include that allows you to remap column names.
For example, if you have a
User with a
name field and you didn't like the default "Name cannot be blank." message, and instead wanted "Your name cannot be blank" you can include this module and use
rename_fields :name => 'Your Name' to rename the column.
Here is a small service I wrote which will use the openweathermap.com weather service in angular.Continue Reading
Here is a small piece of code that can be dropped into an angular project and used to get the users geolocation through the browser.
The first few times I tried it I was hung up on the scope not updating, but
$rootScope.$apply seemed to get around that. Here is a JSFiddle to see how this works.
I wrote a small node app that watermarks images as an inside joke between friends, and I learned some pretty neat tricks along the way. The app will take a URL to an image and overlay a gigantic hand over it. On the useful scale, it is hovering at around a 3 (someone must have a use for this somewhere, right?) but it took a lot of Googling to make this work.
One of the big challenges for this was that I wanted to host it on heroku, and being a read-only filesystem I had to process all the images without touching the filesystem. Finding out how to do this in node was surprisingly difficult at the time.Continue Reading
If you ever found apps like Divvy or SizeUp lacking, you should check out slate window manager. It is a free, open-source window manager for OSX that is very customizable.
A huge bonus of Slate is that it allows you to setup window layouts - specific places for specific windows. This is great for different scenarios: working, dealing with email, chatting, etc. Just setup a different layout and toggle between them when switching tasks for added productivity. The up-front cost kind of sucks, but it can be worth it.
One of the things I was struggling with was creating basic window layouts with it, and I devised a bootstrap-like grid "framework" for it. What it does is try to create a generic 12x12 grid on the screen, so you can push and pull app windows into specific coordinants, similar to how a CSS framework would do it.
The framework really just sets up some slate aliases that let you set window dimensions in a more human-friendly way. The aliases break down into 4 main categories:
When using these with slate's move command you can quickly and easily setup a window arrangement that suits your needs.Continue Reading
I was writing an API in rails a while back and as I started to write the client I noticed that, while using Devise's TokenAuthenticatable strategy, there was no other way to pass the token in besides the
This was a little odd since you would expect something like a token to be able to be passed in through the Authorization headers. I ended up writing a custom devise strategy that will now allow you to pass your user's token in via the Authorization header.Continue Reading
I don't mean to imply that git pulling and merging is painful, because it isn't. I just wanted to showcase a pretty nice gem called git-smart. You can install it using
gem install git-smart.
What this gem does is pretty simple, it attempts to do the "right" thing depending on the situation. I'll run through a few of the commands:Continue Reading