Skip to content

Instantly share code, notes, and snippets.

View backwardm's full-sized avatar

Michael Davie backwardm

View GitHub Profile
@backwardm
backwardm / _form.html.erb
Created June 7, 2022 23:02 — forked from joseh-henrique/_form.html.erb
Upload image crop with Ruby and Rails, CarrierWave and Cropper.js
#app/views/businesses/_form.html.erb
<%= form_with(model: business, scope: :business, local: true, :html => {multipart: true}) do |form| %>
<div class="row">
<div class="col-md-12">
<%= form.file_field :logo_image, id: :business_logo_image %>
<%= form.label :logo_image, class: 'upload' do %>
<i class="material-icons">file_upload</i>
<span>Choose image</span>
@backwardm
backwardm / pdf_page_count.rb
Created July 28, 2015 22:32
Counting PDF pages with pdf-reader gem
require 'rubygems'
require 'pdf-reader'
Dir.glob("/Users/mike/Desktop/zip/**/*").each do |pdf|
next if pdf == '.' or pdf == '..' or pdf == '.DS_Store'
if File.file?(pdf)
reader = PDF::Reader.new(pdf)
puts (pdf + "," + reader.page_count.to_s)