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 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.
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.
Ever use jQuery and think the
.trigger() APIs are nice? Here is a small class you can use when writing CoffeeScript to quickly implement the observer pattern in your own objects.
For more involved scenarios, consider using a library like RxJS.
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.
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:
Heres a small script from Ben Hoskings which is immensely useful. It lists all the branches in your git project ordered by when you last worked on them. It also highlights branches which have not yet been merged into your current branch, which is super useful when looking to prune some branches.
I'm switching things up this time. This post has nothing to do with code, and everything to do with an awesome gadget. Today my nest learning thermostat came!
If you're unfamiliar with the nest, it is a replacement for your programmable thermostat that learns your habits and programs itself, among other things like monitoring energy usage to help save you money. If that isn't cool enough, it is wi-fi enabled which means it auto-updates itself, I can set the schedule from a website, and I can control the temperature in the house from anywhere in the world. Is it lame to get so excited about a thermostat? Probably, but who cares, this thing is fucking cool. Check it out.
I spend a lot of time using the command line, and I find these features particularly useful. This might be old news to some, but they are still immensely helpful. (Also, these are extremely hard to google for, so hopefully this will save you time in more ways than one!) I tried to include as many examples as I could to make these easy to understand.