Install ImageMagick for image conversion:
brew install imagemagick
Install tesseract for OCR:
brew install tesseract --all-languages
Or install without --all-languages and install them manually as needed.
| # [pivital-story-id]-[feature-name] | |
| # All lowercase. Spaces replaced with dashes | |
| 94198518-cs-block-bugs |
| class MigrateHstoreToJson < ActiveRecord::Migration | |
| def up | |
| rename_column :posts, :data, :data_hstore | |
| add_column :posts, :data, :jsonb, default: {}, null: false, index: { using: 'gin' } | |
| execute 'UPDATE "posts" SET "data" = json_object(hstore_to_matrix("data_hstore"))::jsonb' | |
| remove_column :posts, :data_hstore | |
| end | |
| def down | |
| rename_column :posts, :data, :data_jsonb |
| #app/inputs/collection_check_boxes_input.rb | |
| class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput | |
| def item_wrapper_class | |
| "checkbox-inline" | |
| end | |
| end |
| # http://stackoverflow.com/questions/14972253/simpleform-default-input-class | |
| # https://github.com/plataformatec/simple_form/issues/316 | |
| inputs = %w[ | |
| CollectionSelectInput | |
| DateTimeInput | |
| FileInput | |
| GroupedCollectionSelectInput | |
| NumericInput | |
| PasswordInput |
| # Add Action button on the top navigation menu. Useful for resource with nested resources | |
| action_item :only => :show do | |
| link_to('Show Users', admin_group_users_path(resource)) | |
| end | |
| # Custom show page with children items | |
| show do |
| <textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea> | |
| ... | |
| <textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea> | |
| ... | |
| <script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script> | |
| <script> | |
| // Hook up ACE editor to all textareas with data-editor attribute | |
| $(function () { |
| / A simplistic way of loading and rendering HAML partials (header.haml, footer.haml, nav.haml... you name it) without Rails | |
| / Useful when using tools like LiveReload http://livereload.com/ | |
| / but don't want to configure a web server just to use PHP include/require constructs (discussion http://help.livereload.com/discussions/questions/22-haml-partials) | |
| / It could be improved/simplified using a helper http://stackoverflow.com/questions/5436769/partial-haml-templating-in-ruby-without-rails/5436973#5436973 | |
| / Check out the Jade version https://gist.github.com/2593727 | |
| %html | |
| %body | |
| %header | |
| = Haml::Engine.new(File.read('/path/to/your/partial.haml')).render |
| #!/usr/bin/env ruby | |
| require 'active_record' | |
| ActiveRecord::Base.establish_connection( | |
| :adapter => 'sqlite3', | |
| :database => ':memory:' | |
| ) | |
| ActiveRecord::Schema.define do |
| require 'action_dispatch/middleware/static' | |
| module Middleware | |
| class FileHandler < ActionDispatch::FileHandler | |
| def initialize(root, assets_path, cache_control) | |
| @assets_path = assets_path.chomp('/') + '/' | |
| super(root, cache_control) | |
| end | |
| def match?(path) |
Install ImageMagick for image conversion:
brew install imagemagick
Install tesseract for OCR:
brew install tesseract --all-languages
Or install without --all-languages and install them manually as needed.