http://lucene.apache.org/solr/
Sunspot - Sunspot is a Ruby library for interaction with the Solr search engine.
def get_last_modified(dir) | |
# make sure the files to be checked are in the provided directory | |
files = Dir.new(dir).select { |file| file!= '.' && file!='..' } | |
# make sure the file has been written to | |
return nil if (files.size < 1) | |
# create an array of all the files | |
files = files.collect { |file| File.join(dir , file) } |
http://lucene.apache.org/solr/
Sunspot - Sunspot is a Ruby library for interaction with the Solr search engine.
#/usr/bin/bash | |
# extract images from pdf at first-hand | |
#prefix=pict | |
#echo extract images from "$1" | |
#pdfimages -j "$1" $prefix | |
# IMAGES ARE SAVED SECVENTIALLY AS IMAGE AND THE NEXT IS A MASK IMAGE !!!! | |
declare -a files=($(ls *.ppm *.pbm)) | |
mask= | |
image= | |
for (( i = 0; i < ${#files[*]}; i = i + 2 )) |
class PurchaseApprover | |
# Implements the chain of responsibility pattern. Does not know anything | |
# about the approval process, merely whether the current handler can approve | |
# the request, or must pass it to a successor. | |
attr_reader :successor | |
def initialize successor | |
@successor = successor | |
end |
The idea here is that I have a single User login that can eventually be tied to multiple Companies via the Role. | |
You signup via Devise on the custom /register route and fillout the Company information etc. The custom registration controller creates the Role during the user creation and sets a few other attributes. | |
It all worked but now it's broken and I have no idea what I did to break it. | |
When I try to create a new user / company the additional user fields (name_first & name_last) always fail validation regardless if they are in fact valid. The nested Company fields do not validate at all. If I enter the email and password field only the form works but only creates the User record. | |
To me it seems like the custom registration controller is not being processed at all. |
# Do 'gem install redcarpet' | |
# Usage: | |
# ruby test.rb > test.html | |
# | |
require 'slim' | |
s = File::open('markdown.html.slim').read() | |
================================= | |
def slow(&block) | |
block.call | |
end | |
def slow | |
Proc.new.call | |
end | |
- The below one is 5 times faster then above, in execution |
def self.uniq! queue_name | |
seen_already = Set.new | |
Sidekiq::Queue.new(queue_name).each { |job| | |
key = { job.klass => job.args } | |
key.in?(seen_already) ? job.delete : seen_already << key | |
} | |
end |
The goal: Upload several files (virtually big files) to a Rails application without compromising the user experience.
jQuery File Upload + Nginx + Rails (Carrierwave) + Sidekiq