Skip to content

Instantly share code, notes, and snippets.

View maxim's full-sized avatar
🙂
🌴

Max Chernyak maxim

🙂
🌴
View GitHub Profile
require 'rubygems'
require 'sinatra'
require 'tempfile'
class Jaxer
class << self
def json_to_png(json)
# producing tempfile
file = Tempfile.new('jaxer')
# command used to start thin
thin -s 1 -C thin/production_config.yml -R thin/config.ru start
# thin/config.ru
require 'lib/sinatra/lib/sinatra'
module HasAsset
def included base
base.class_eval do
before_create :add_asset
before_update :edit_asset
end
end
private
def edit_asset
Errno::EPIPE in Item typesController#update
Broken pipe
RAILS_ROOT: /Users/max/Sites/printio/products
Application Trace | Framework Trace | Full Trace
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:175:in `write'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:175:in `write0'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:151:in `write'
asset.put(:service_update, {
:object => Base64::encode64s(source_data),
:filename => "#{Digest::MD5.hexdigest(source_data)}.png",
:description => self.method(options[:description]).call })
module Beer
def drink
"gulp"
end
end
class Mug
include Beer
end
module Paperclipful
module UploadedFileExtensions
def to_xml(options = {})
options.reverse_merge! :indent => 2, :root => self.class.to_s.split('::').last.underscore
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent], :root => options[:root])
xml.instruct! unless options[:skip_instruct]
self.rewind
xml.tag!(options[:root], :type => :attachment) do
xml.original_path self.original_path
<% form_for setup_prototype(@prototype), :html => {:multipart => true} do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :title %><br />
<%= f.text_field :title %>
</p>
<p>
<%= image_tag @prototype.item_view.picture.url(:small) unless @prototype.new_record? %>
<%= f.label :item_view %><br />
<form action="/prototypes" class="new_prototype" enctype="multipart/form-data" id="new_prototype" method="post">
<div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="xIhGb/nKQfrrKzaJ/J2iQOrupN+81AfreutXOdIoNqY="></div>
<p>
<label for="prototype_title">Title</label><br />
<input id="prototype_title" name="prototype[title]" size="30" type="text">
</p>
<p>
{"commit"=>"Create", "action"=>"create", "authenticity_token"=>"xIhGb/nKQfrrKzaJ/J2iQOrupN+81AfreutXOdIoNqY=", "controller"=>"prototypes", "prototype"=>{"title"=>"", "surface_views_attributes"=>{"new_1"=>{"description"=>"asdf", "picture"=>#<File:/tmp/RackMultipart.83249.5>}, "new_2"=>{"picture"=>#<File:/tmp/RackMultipart.83249.6>}, "new_3"=>{"picture"=>nil}}, "item_view_attributes"=>{"picture"=>nil}}}