This file contains hidden or 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
| module Paperclip | |
| class Attachment | |
| class UploadedPath | |
| attr_reader :original_filename, :content_type, :size, :path | |
| def initialize(uploaded_file) | |
| @original_filename = uploaded_file["name"].downcase | |
| @content_type = uploaded_file["content_type"].to_s.strip | |
| @file_size = uploaded_file["size"].to_i | |
| @path = uploaded_file["path"] |
This file contains hidden or 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
| def move_to_s3 | |
| temp_path = attachment.path | |
| temp_file = attachment.to_file # Paperclips way of getting a File object for the attachment | |
| # Save it as a regular attachment | |
| # this will save to S3 | |
| s3_upload = Upload.find(id) # Same db record but we need the S3 version | |
| s3_upload.attachment = temp_file # reset the file - it will assume its a new file | |
| s3_upload.save! # Paperclip will upload the file on save |
This file contains hidden or 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
| # ---------------------------------------------- | |
| # Class for Youtube (youtube.com) | |
| # http://www.youtube.com/watch?v=25AsfkriHQc | |
| # ---------------------------------------------- | |
| class VgVimeo | |
| def initialize(url=nil, options={}) | |
| # general settings |
This file contains hidden or 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
| // togglea values de inputs | |
| InputValueHelper = $.klass({ | |
| initialize: function(){ | |
| this.initial_value = $(this.element).val() | |
| }, | |
| onblur: function(){ | |
| if($(this.element).val() == '') { | |
| $(this.element).val(this.initial_value); | |
| } |
This file contains hidden or 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 'net/pop' | |
| module Mailman | |
| class Receiver | |
| # Receives messages using POP3, and passes them to a {MessageProcessor}. | |
| class POP3 | |
| # @return [Net::POP3] the POP3 connection | |
| attr_reader :connection |
This file contains hidden or 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
| ##### controllers | |
| @time_chart = HighChart.new('chart_tag') do |f| | |
| f.chart({:zoomType =>'x', :defaultSeriesType => 'spline'}) | |
| f.title(:text => 'Flower Market') | |
| f.x_axis({:type =>'datetime'}) | |
| f.y_axis({:title => 'flowers'}) | |
| chart_begin_js = "Date.UTC(#{@last_x_days[0].year}, #{@last_x_days[0].month-1}, #{@last_x_days[0].day})" | |
| f.series(:name => 'violets', :data => generate_numbers(number), :pointInterval => 24*3600*1000) | |
| f.series(:name => 'sunflowers', :data => generate_numbers(number), :pointInterval => 24*3600*1000) | |
| end |
This file contains hidden or 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
| ENV["PATH"] = "/opt/ruby/bin:#{ENV['PATH']}" | |
| ENV["RAILS_ENV"] = "production" | |
| ENV["QUEUE"] = "*" | |
| Bluepill.application("nichelator") do |app| | |
| app.working_dir = "/var/apps/nichelator/current" | |
| app.uid = "app" | |
| app.gid = "app" | |
| 2.times do |i| | |
| app.process("resque-#{i}") do |process| |
This file contains hidden or 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
| Uploadizr = $.klass({ | |
| initialize: function(submiter , path ){ | |
| //console.log("picker!! " +submiter+" "+$(this.element).attr("token")+" "+path); | |
| var current_id = ""; | |
| var token = $(this.element).attr("token") | |
| var uploader = new plupload.Uploader({ | |
| runtimes : "html5", | |
| browse_button : $(this.element).attr("id"), | |
| max_file_size : '10mb', | |
| url : path, |
This file contains hidden or 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
| # comment out "deploy/assets" in your capfile, we are doing this locally | |
| namespace :noumad do | |
| desc "Compress assets in a local file" | |
| task :compress_assets do | |
| run_locally("rm -rf public/assets/*") | |
| run_locally("bundle exec rake assets:precompile") | |
| run_locally("touch assets.tgz && rm assets.tgz") |