view · edit · sidebar · attach · print · history


<< | Index | >>


  • re-installed imagemagick, rmagick
    • I had to install imagemacik with png use flag.
  • upadated daily cost calcuration.
    • improved daily cost for size units of mg,g,ml
    • learned about Package and Dose class.
  • I has problem that my local returns very slow response via Apache.
    • I cann access DataObject and cache via bin/admin fine. (It takes to search 'inderal' via Apache)
    • updated DB with update-script. (same result..)
    • updated currency-1.0.0 to currency-1.0.1 (The converter are changed google query to finance api)
      query became much faster !!




  • to fix problem request response via Apache.
  • to check imagemagick version.

Problem Imagemagick on my local machine

steps by fix problems

My imagemagick (and settings) on were not installed, correctly.

1. updated

Last night, I installed(upgraded) following libraries,
to take a screenshot with import/animate commands.

  • imagemagick ( ->
  • rmagick (2.12.2 -> 2.13.2)

2. backed

Then, I could not restart odddbd (No Error, oddbd didn't respond)
(It seemed that my Postgres SQL also didn't)

Next, I tried downgrade to previous version.

  • imagemagick ( ->
  • rmagick (2.12.2 -> 2.13.2)

3. denegate error

After reboot, these error caused in this URL.
(this was my state by last night.)

This page has png image.

error in SBSM::Session#to_html: /de/gcc/ddd_chart/for/31706033_Inderal_40_mg_Tageskostenvergleich.png
no decode delegate for this image format `/tmp/magick-RBdLEIWG-00000001' @ error/constitute.c/ReadImage/532: `(null)'
/usr/local/lib/ruby/gems/1.9.1/gems/gruff-0.3.6/lib/gruff/base.rb:1088:in `get_type_metrics'
/usr/local/lib/ruby/gems/1.9.1/gems/gruff-0.3.6/lib/gruff/base.rb:1088:in `calculate_caps_height'
/var/www/ `setup_graph_measurements'
/usr/local/lib/ruby/gems/1.9.1/gems/gruff-0.3.6/lib/gruff/base.rb:532:in `setup_drawing'
/usr/local/lib/ruby/gems/1.9.1/gems/gruff-0.3.6/lib/gruff/base.rb:508:in `draw'
/var/www/ `draw'
/usr/local/lib/ruby/gems/1.9.1/gems/gruff-0.3.6/lib/gruff/base.rb:493:in `to_blob'
/var/www/ `to_html'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/state.rb:179:in `to_html'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:446:in `to_html'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:170:in `block in drb_process'
<internal:prelude>:10:in `synchronize'
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.4/lib/sbsm/session.rb:168:in `drb_process'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/usr/local/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'

4. font for ghostscript.

Zeno-san suggested and taught me that font path of ghostscript are need for

$ cd /usr/share/fonts/default
$ sudo ln -s /usr/share/fonts/urw-fonts/ ghostscript

5. USE flag for imagemagick.

before emerge imagemagick, to make sure USE flag "png", "jpg"

USE="...jpeg png"

6. finaly

  • Both versions(, of Imagemagick functions fine.
  • To re-install Rmagick ,after installed Imagemagick,
  • To check compile options of Imagemagick. (In this case, I needed png flag.)

fix pulver. TK (daily cost of soluble powder)

updated calculation (daily_cost)


  • Zithromax soluble powder (reg: 51352, pack: 017)

access via bin/admin

ch.oddb> registration('51352')
-> #<ODDB::Registration:0xcf39600>
ch.oddb> registration('51352').package('017')
-> #<ODDB::Package:0xf536d44>
ch.oddb> registration('51352').package('017').ddd_price
-> 1680000.00

I checked with p-debug.

Zithromax (reg:51352, pack:017) pulVer.

"ddd_galforms = (?i-mx:tabletten?)"
"galenic_group = Lösbar zur Einnahme"
"factor = 1.0"
"ddose = 0.3 g"
"mdose = 200 mg"
"price = 16.80"
"size = 15 ml"
ddose (Package#ddd)
the amount of active_agent required for one day
mdose (Package#dose)
the amount of active_agent included in one unit of package
size (Packeage#size)
total amount of package

price / (( size / mdose) / ddose) / factor

Tagesdosis 0.3 g Publikumspreis 16.80 CHF
Stärke	200 mg	Packungsgrösse	15 ml
Berechnung	( 0.3 g / 200 mg ) x ( 16.80 / 15 ml ) = 6.72 CHF / Tag

I added Dose#to_g (to gram) method.

  • g --> g (just return Dose#to_i)
ch.oddb> registration('57524').package('002').dose
-> 2 g
ch.oddb> registration('57524').package('002').dose.to_i
-> 2
ch.oddb> registration('57524').package('002').dose.to_g
-> 2
  • mg --> g (return to_f as g)
ch.oddb> registration('51352').package('017').dose
-> 200 mg
ch.oddb> registration('51352').package('017').dose.to_i
-> 200
ch.oddb> registration('51352').package('017').dose.to_g
-> 0.019999999999999997


Dose#size has following units (as String).

  • Tabletten(s)
  • Sachet(s)
  • ml, mg, g

My prerious fix has another problem for Sachet(s).
Then, I improved like this.

@@ddd_grmforms = /[mg|g|ml]/iu
  def ddd_price
       if size.to_s.match(@@ddd_grmforms) 
         (price / ((size / mdose.to_g).to_f / ddose.to_f)) / factor
         (price / ((size * mdose).to_f / ddose.to_f)) / factor

Daily cost of Solubre powder(pulver.) and Glanulat()


needed handling unit of 'ml/mg'.

Fix ddd for Keppra and Granulat

fix slow search

  • search inderal via Apache # => 3 miutes
  • search Zithromax via Apache # => 6 minutes

Zeno-san suggested and teached me that old currencyd has slow converter.
I found updates to fix this problem in Masa-san's log.

Slow response were caused by query of currency converter.

 module Currency
   @rates = {}
   @mutex =
   def Currency.extract_rate(html)
-    if(match = /1\s+[^<>=]+=\s+(\d+\.\d+)/.match(html))
+    if(match = /\<span class=bld\>(\d+\.\d+) \w+\<\/span\>/.match(html))
   def Currency.get_html(origin, target)
     Net::HTTP.start('') { |session|
-      session.get("/search?q=1+#{origin.upcase}+in+#{target.upcase}").body
+      session.get("/finance/converter?a=1&from=#{origin.upcase}&to=#{target.upcase}").body
   def Currency.rate(origin, target)

Google Finance Converter

I uninstalled ycurrency-1.0.0 from gem18 (ycurrencyd, too)
then installed ycurrency-1.0.1 via gem19

$ sudo gem19 uninstall ycurrency
$ sudo -i gem install ycurrency

search query became much faster, fine !


view · edit · sidebar · attach · print · history
Page last modified on March 01, 2012, at 08:34 PM