Skip to content

Instantly share code, notes, and snippets.

@mankind
mankind / Gemfile
Created May 8, 2011 15:15 — forked from beathyate/Gemfile
Cloudmailin Rails 3 Mongoid CarrierWave GridFS
source :rubygems
gem 'rails', '3.0.3'
gem 'mongo', '1.1.5'
gem 'bson', '1.1.5'
gem 'bson_ext', '1.1.5'
gem 'mongoid', '2.0.0.beta.20'
gem 'carrierwave'
@mankind
mankind / message_thread.rb
Created May 28, 2011 17:22 — forked from MichaelTorfs/message_thread.rb
non guessable url with md5 generator
def md5hash
md5 = Digest::MD5.hexdigest(self.id.to_s + self.initial_sender_email + MD5_SECRET)
logger.info "DEBUG: md5 = " + md5
return self.id.to_s + "-" + md5
end
def check_md5(md5_to_check)
md5 = Digest::MD5.hexdigest(self.id.to_s + self.initial_sender_email + MD5_SECRET)
if md5 == md5_to_check
return true
@mankind
mankind / rails_3_1_beta_1_changes.md
Created June 2, 2011 14:35 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

@mankind
mankind / mongo_replication.rb
Created June 6, 2011 18:52
Sets up replication based on node[:mongodb][:repl_set]
# Install the MongoDB gem
%w{ mongo bson_ext }.each do |mongo_gem|
gem_install = gem_package mongo_gem do
action :nothing
end
gem_install.run_action(:install)
end
Gem.clear_paths
require 'mongo'
@mankind
mankind / ImageUploader
Created August 17, 2011 12:07 — forked from ahamid/ImageUploader
CarrierWave mixed content upload processing
require 'carrierwave/processing/mini_magick'
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
IMAGE_EXTENSIONS = %w(jpg jpeg gif png)
DOCUMENT_EXTENSIONS = %w(exe pdf doc docm xls)
def store_dir
"files/#{model.id}"
@mankind
mankind / soft_delete.rb
Created October 5, 2013 08:46 — forked from brianjlandau/soft_delete.rb
This is a soft delete mixin for ActiveRecord 3.x. All you need to do is add a `deleted_at` column to the ActiveRecord models you mix this into.
module SoftDelete
extend ActiveSupport::Concern
included do
define_model_callbacks :soft_delete
define_model_callbacks :recover
default_scope where(:deleted_at => nil)
class_eval do
class << self
alias_method :with_deleted, :unscoped
Loading development environment (Rails 4.0.0)
2.0.0-p247 :001 > Date.today
=> Thu, 26 Sep 2013
2.0.0-p247 :002 > Date.tomorrow
=> Thu, 26 Sep 2013
@mankind
mankind / oai_export_doc.md
Created August 9, 2019 14:24 — forked from ashikajith/oai_export_doc.md
OAI Export Feature

OAI Export

For OAI we are using the BlackLightOaiProvider gem (https://github.com/projectblacklight/blacklight_oai_provider) which harvest the data automatically once it is configured in the catalog controller. We have divided into two phases.

We do have an ENV variable which acts as a switch to enable this feature .

ENABLE_OAI_METADATA: 'true'

RIF Doc

For Rif template all the fileds have unique codes and we represent eah codes to the corresponding value. Following are the steps we follow to generate the report

  • Fetch the corresponding work from the controller CitationExportsController (app/controllers/ubiquity/citation_exports_controller.rb) and process the fetched record to render in RIF fromat.
  • A Controller Concern is added to handle the processing of data in Rif format (app/controllers/concerns/ubiquity/citations_export_concern.rb)

Basically we have a hash which consist of code and the fields that needs to map. Please find the hash below

@mankind
mankind / mask_s3_url.md
Created August 9, 2019 14:24 — forked from ashikajith/mask_s3_url.md
Masking S3 URL

S3 Masking URL

For masking the url we created a seperate routes, controller to fetch the record and generate the url for the download file.

  app/controllers/ubiquity/fail_uploads_controller.rb
  
  def download_file
    params[:fileset_id]
    uuid = params[:uuid]
 s3_file_set_url = Ubiquity::ImporterClient.get_s3_url uuid