Skip to content

Instantly share code, notes, and snippets.

adam may
andrew reid
antoin campbell
asia lindsay
chris bradshaw
chris mcguigan
cindy kim
daniel wise
david flaherty
derek mueller
** (Mix) Could not start application hello_world_phoenix: HelloWorldPhoenix.start(:normal, []) returned an error: shutdown: failed to start child: HelloWorldPhoenix.Repo
** (EXIT) shutdown: failed to start child: Ecto.Adapters.Postgres
** (EXIT) an exception was raised:
** (RuntimeError) could not find Ecto.Adapters.Postgres.Connection.
Please verify you have added :postgrex as a dependency:
{:postgrex, ">= 0.0.0"}
And remember to recompile Ecto afterwards by cleaning the current build:
require 'pry'
module DefineMulti
def method_missing(original_caller, *args)
the_method = "_#{args.length}_#{original_caller}".to_sym
unless self.methods.include?(the_method)
raise NoMethodError, "Undefined method '#{original_caller}' with arity #{args.size}"
end
public_send(the_method, *args)
end
class Cocktail < ActiveRecord::Base
has_many :proportions
has_many :ingredients, through: :proportions
def self.new_from_book(recipe)
troublesome = ["Jules Bergeron, Trader Vic’s Bartenders Guide, 1972","George Kappeler, Modern American Drinks, 1895"]
if troublesome.include?(recipe.last)
recipe.last.prepend("-")
end
defmodule Paralindrome do
def are_palindromes?(list) do
parent_process = self
Enum.map(list, fn (word) ->
spawn(fn ->
send parent_process, {self, word, is_palindrome?(word) }
end)
end)
|> Enum.each fn (process_id) ->
receive do
class Drink
attr_reader :name, :description, :ingredients
def initialize(name, description)
@name = name
@description = description
@ingredients = []
end
def add_ingredient(ingredient)
@ingredients << ingredient
Shirt.create name: "Blending In",
artist: "ramyb",
image_url: "http://d3gqasl9vmjfd8.cloudfront.net/cc755b4f-9f0e-4441-9fbe-eea6cc240d79.png",
url: "http://shirt.woot.com/offers/blending-in"
Shirt.create name: "Casual Friday",
artist: "Blair Sayer",
image_url: "http://d3gqasl9vmjfd8.cloudfront.net/bfbe1921-d2b4-4142-ac3e-f6fe25cb44ff.png",
url: "http://shirt.woot.com/offers/casual-friday"
require 'socket' # Get sockets from stdlib
require 'pry'
server = TCPServer.open(9292) # Socket to listen on port 9292
puts "Server is running on port 9292"
loop { # Servers run forever
client = server.accept # Wait for a client to connect
puts client.recv(1000000)
client.puts "Go check the console!"
client.close # Disconnect from the client
William Hartnell
Patrick Troughton
Jon Pertwee
Tom Baker
Peter Davison
Colin Baker
Sylvester McCoy
Paul McGann
Christopher Eccleston
David Tennant
require 'pry'
students = File.readlines('students')
# students.each do |student|
# puts "#{student.chomp} is a member of The Flatiron School"
# end
#
students.each do |student|
if student.start_with?('S')
puts student.strip