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 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.
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
| #/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 )) |
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 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 |
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
| 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. |
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
| # Do 'gem install redcarpet' | |
| # Usage: | |
| # ruby test.rb > test.html | |
| # | |
| require 'slim' | |
| s = File::open('markdown.html.slim').read() | |
UPDATE a fork of this gist has been used as a starting point for a community-maintained "awesome" list: machine-learning-with-ruby Please look here for the most up-to-date info!
- liblinear-ruby: Ruby interface to LIBLINEAR using SWIG
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 slow(&block) | |
| block.call | |
| end | |
| def slow | |
| Proc.new.call | |
| end | |
| - The below one is 5 times faster then above, in execution |
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 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 |