This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pg' | |
require 'pry' | |
conn = PG.connect(dbname: 'chinook') | |
binding.pry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pg' | |
require 'pry' | |
conn = PG.connect(dbname: 'chinook') | |
def add_artist(db_conn, name) | |
sql = <<-SQL | |
INSERT INTO artists (name) | |
VALUES ($1) RETURNING id | |
SQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pg' | |
require 'pry' | |
class Artist | |
CONN = PG.connect(dbname: 'chinook') | |
attr_accessor :id, :name | |
def self.new_from_row(row) | |
id = row["id"] | |
name = row["name"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
require 'pry' | |
class MyApp | |
def self.call(env) | |
request = Rack::Request.new(env) | |
if request.path == '/' | |
[200, {"Content-Type" => "text/html"}, ["<h1>You're at the root path!!!!</h1>"]] | |
else | |
[404, {"Content-Type" => "text/html"}, ["File Not Found"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert an animated video to gif | |
# Works best for videos with low color palettes like Dribbble shots | |
# | |
# @param $1 - video file name like `animation.mov` | |
# @param @optional $2 - resize parameter as widthxheight like `400x300` | |
# | |
# Example: vidtogif animation.mov 400x300 | |
# Requirements: ffmpeg and gifsicle. Can be downloaded via homebrew | |
# | |
# http://chrismessina.me/b/13913393/mov-to-gif |