I hereby claim:
- I am jonathandean on github.
- I am jondean (https://keybase.io/jondean) on keybase.
- I have a public key whose fingerprint is 434D 26AD 85A0 8482 E228 DC75 1ECE DE72 83BD EDA6
To claim this, I am signing this object:
| Description: | |
| Make ViewComponent previews for Lookbook | |
| Example: | |
| bin/rails generate component_preview my_new_component | |
| This will create: | |
| spec/components/previews/my_new_component_preview.rb | |
| spec/components/previews/my_new_component_preview/default.html.erb |
| module UrlHelpers | |
| def domain(url) | |
| unless url =~ /^http(s)?:\/\// | |
| url = "https://#{url}" | |
| end | |
| uri = URI.parse(url) | |
| uri.host&.gsub(/^(www|m)\./, '') | |
| rescue => e | |
| puts "WARNING: failed to retrieve domain from URL #{url}: #{e.message}" | |
| nil |
| class ApplicationRecord < ActiveRecord::Base | |
| # ... | |
| def self.dump_all_fixtures | |
| self.all.map(&:dump_fixture) | |
| end | |
| def dump_fixture | |
| fixture_file = "#{Rails.root}/spec/fixtures/#{self.class.table_name}.yml" | |
| File.open(fixture_file, "a+") do |f| | |
| f.puts({ "#{self.class.table_name.singularize}_#{id}" => attributes.reject{|key| %w(id created_at updated_at).include?(key)} }. |
I hereby claim:
To claim this, I am signing this object:
I needed to reinstall my postgres gem after upgrading to OS X Mavericks. I used homebrew to install postgres.
Find the path to your postgres config with
brew info postgres
And look for something like: postgres -D /usr/local/var/postgres # serve that database
Now use the --with-pg-config option to point to that directory and use gem install directly instead of bundler for just this one:
| NameSpace = NameSpace or {} | |
| NameSpace.ClassName = (options) -> | |
| # default options | |
| defaultOpts = -> | |
| defaultOpts:: = | |
| some_option: "some value", | |
| another_option: "another value" | |
| # private vars |
| require 'net/http' | |
| Net::HTTP.start('www.example.com') { |http| | |
| resp = http.get('/url/to/file.ext') | |
| open('/path/to/local/file.ext', "wb") { |file| | |
| file.write(resp.body) | |
| } | |
| } |