A ZSH theme optimized for people who use:
- Solarized
- Git
- Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)
For Mac users, I highly recommend iTerm 2 + Solarized Dark
| #!/bin/sh | |
| ### | |
| # SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
| # For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
| ### | |
| # Alot of these configs have been taken from the various places | |
| # on the web, most from here | |
| # https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.
A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.
You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.
class Article < ActiveRecord::Base#Restaurants near 1871
Help curate this list. start filling out the data and links about each place and add places!
##Cheap
| module Forwardable | |
| FORWARDABLE_VERSION = "1.1.0" | |
| @debug = nil | |
| class << self | |
| attr_accessor :debug | |
| end | |
| # Takes a hash as its argument. The key is a symbol or an array of | |
| # symbols. These symbols correspond to method names. The value is |
| class UIView | |
| def top | |
| frame.origin.y | |
| end | |
| def left | |
| frame.origin.x | |
| end | |
| def height | |
| frame.size.height | |
| end |
| #!/usr/bin/env ruby | |
| # Determines the coordinates (latitude and longitude) of the places or | |
| # addresses passed as arguments (either on the command line or via stdin) | |
| # and prints the results. | |
| # This script requires the Ruby Geocoder gem by Alex Reisner | |
| # (http://www.rubygeocoder.com). | |
| # To install the gem, run this command from a Terminal session: | |
| # |
| # MODEL | |
| class Case < ActiveRecord::Base | |
| include Eventable | |
| has_many :tasks | |
| concerning :Assignment do | |
| def assign_to(new_owner:, details:) | |
| transaction do |
| Motion::Project::App.setup do |app| | |
| app.info_plist['API_BASE_URL'] = ENV['API_BASE_URL'] || 'http://api.myserver.com' | |
| end | |
| task :cucumber => [:stub, :'build:simulator', :'calabash:run'] | |
| task :stub do | |
| ENV['API_BASE_URL'] = 'http://stub.example.com' | |
| end | |