Start with:
subl ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Ruby/Ruby.sublime-build
Copy and paste this, replacing the contents of that file with this:
{
"env":{
"PATH":"${HOME}/.rvm/bin:${PATH}"
Start with:
subl ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Ruby/Ruby.sublime-build
Copy and paste this, replacing the contents of that file with this:
{
"env":{
"PATH":"${HOME}/.rvm/bin:${PATH}"
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>jQuery Practice</title> | |
</head> | |
<body> | |
<div id="content"> | |
<div class="entry"> | |
<h1>You Won't Believe What Happens When You Click This Link</h1> | |
<a href="#">Click me!</a> |
" Two best solutions from the discussion here http://stackoverflow.com/questions/356126/how-can-you-automatically-remove-trailing-whitespace-in-vim | |
" Automatically strip white space on save in VIM. | |
fun! <SID>StripTrailingWhitespaces() | |
let l = line(".") | |
let c = col(".") | |
%s/\s\+$//e | |
call cursor(l, c) | |
endfun |
If you want to see all commits on all branches that aren't pushed yet, you might be looking for something like this:
git log --branches --not --remotes
And if you only want to see the most recent commit on each branch, and the branch names, this:
git log --branches --not --remotes --simplify-by-decoration --decorate --oneline
From here http://stackoverflow.com/questions/2016901/viewing-unpushed-git-commits#answer-3338774
I would recommend dropping your test database, then re-create it and migrate:
bundle exec rake db:drop RAILS_ENV=test
bundle exec rake db:create RAILS_ENV=test
bundle exec rake db:schema:load RAILS_ENV=test
Shorter:
Using traits in FactoryGirl for things like tags on other models, and so forth.
FactoryGirl.define do
factory :post do
title 'New post'
end
trait :with_comments do
after :create do |post|
If you are taking user input for name and email, then unless you very carefully validate or escape the name and email, you can end up with an invalid From header by simply concatenating strings. Here is a safe way:
require 'mail'
address = Mail::Address.new email # ex: "john@example.com"
address.display_name = name # ex: "John Doe"
# Set the From or Reply-To header to the following:
address.format # returns "John Doe <john@example.com>"
# Elixir solution for http://www.codewars.com/kata/dont-drink-the-water | |
defmodule Liquids do | |
@density %{ ?H => 1.36, ?W => 1.00, ?A => 0.87, ?O => 0.8 } | |
def separate_liquids([]), do: [] | |
def separate_liquids([h|_] = glass) when is_list(h) and length(h) > 0 do | |
List.flatten(glass) |> Enum.sort_by(&(@density[&1])) |> Enum.chunk(length(h)) | |
end | |
end |
(by @andrestaltz)
So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.
Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:
Rx.Observable.prototype.flatMapLatest(selector, [thisArg])
Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
""" | |
An IPython magic function to pretty-print objects with syntax highlighting. | |
Updated to also pretty print the object's __dict__ if it's available. | |
See, "Defining your own magics": | |
http://ipython.org/ipython-doc/stable/interactive/reference.html#defining-your-own-magics | |
For more on Pygments: | |
http://pygments.org/docs/quickstart/ | |
Usage |