IPMIView on a current Mac OS (10.13.4)

Yes, I know… Nobody does use IPMI any more… There are so many better solutions.

And yes: You are like me: You are stuck to IPMI due to various reasons but do not want to install a Windows VM for this crap?

Here’s my solution (you need to know how to use the Terminal.app):

  • Download IPMIView for Linux from SuperMicro (yeah, Google’s your friend… Thomas Krenn actually also provides a download link
  • Unzip/Tar it to a folder of your choice (IPMI_TAR_DIRECTORY)
  • brew install jenv (you have HomeBrew installed, don’t you?)
  • mkdir -p ~/.jenv/versions (I have no idea why the homebrew script doesn’t do this, but…
  • echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
  • echo 'eval "$(jenv init -)"' >> ~/.zshrc (change both accordingly if you make use of bash. See jenv-Website for details)
  • brew tap caskroom/versions; brew install java6
  • open a new terminal window, to get the jenv-environment in place
  • jenv add /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
  • cd IPMI_TAR_DIRECTORY
  • jenv local 1.6 (that’s now part of your IPMI-Dir)
  • cd ..; cd - (just to re-enter the directory)
  • java -jar IPMIView20.jar
  • have fun!

I have also installed an Automator-script (just a new workflow that performs a shell script) and saved it as an application. I moved this application into my Dock and now I’m happy.
If you also want to change Automator’s script icon, I recommend the small app Image2Icon (Mac App Store).

Rails Own Logger

I was in need of a logging mechanism that prints all log messages with a “severity” that equals or is higher of “INFO” to STDOUT (I’m using multilog for actual logging stuff).

As I wasn’t able to google a solution I came up with the following (not quite elaborated) code:

 

class OwnLogger < Logger

    include Severity
    SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY)

    def add(severity, message = nil, progname = nil, &block)
      time = Time.now
      if ENV['LOG_FROM_INFO_TO_STDOUT']
        if severity >= INFO
          msg = "#{$$}:#{SEV_LABEL[severity]}:" + time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % time.usec + ":"
          if message.nil?
            if block_given?
              message = yield
            else
              message = progname
              progname = @progname

            end
            msg += message.to_s
            puts msg
          end
        end
        super
      end

    end

So if you put the following lines in your /config/application.rb you’ll get what I got 🙂
config.logger = OwnLogger.new(File.dirname(__FILE__) + "/../log/#{ENV['PROCNAME']}#{Rails.env}.log")


AND (most important) you’ll still have the “normal” logfile containing all messages

Get the ID value of a serial column after insertation

Just took me 2 hours of Googling…

I found:
http://stackoverflow.com/questions/246983/informix-how-to-get-an-id-of-the-last-inserted-record

[…]The value of the last SERIAL insert is stored in the SQLCA record, as the second entry in the sqlerrd array. Brian’s answer is correct for ESQL/C, but you haven’t mentioned what language you’re using.
If you’re writing a stored procedure, the value can be found thus:
LET new_id = DBINFO(‚sqlca.sqlerrd1‘);
It can also be found in $sth->{ix_sqlerrd}[1] if using DBI
There are variants for other languages/interfaces, but I’m sure you’ll get the idea.
[…]

I got the idea and have created the following procedure (obsolete… Please see below)

CREATE PROCEDURE lastid ()
RETURNING integer;
DEFINE lastid integer;
LET lastid = DBINFO(‘sqlca.sqlerrd1’);
RETURN lastid;
END PROCEDURE

So to get the latest column you just use

select lastid() from table(set{1})

btw.: If you want to make use of this in Rails, I’d some success with:

class InformixConnect < ActiveRecord::Base
self.abstract_class = true
establish_connection :development_informix

def save
super
self.id = self.connection.select_value(“select lastid() from table(set{1})”)
end

end

so a model like

class Customer < InformixConnect

end

would be able to connect to Informix and to get correct values from the DB without the
usage of sequences!

ERROR
Unfortunately the stuff above (overwriting the save method) does not work for some reasons.

I have patched

class InformixAdapter < AbstractAdapter

def prefetch_primary_key?(table_name = nil)
false
end
….

def insert(sql, name= nil, pk= nil, id_value= nil, sequence_name = nil)
execute(sql)
select_value(“select lastid() from table(set{1})”)
end
…..

 

 

This works!

HEUREKA

Found another solution that works also with serial8 columns:
INFORMIX


CREATE PROCEDURE lastid_both ()
RETURNING integer;
DEFINE lastid_1 integer;
DEFINE lastid_8 integer;
LET lastid_1,lastid_8 = DBINFO('sqlca.sqlerrd1'),DBINFO('serial8');
IF lastid_1 == 0 THEN
return lastid_8;
END IF
RETURN lastid_1;
END PROCEDURE

Ruby/Rails


class InformixConnect &lt; ActiveRecord::Base

def save(*args)
ret=nil
if new_record?
ret = super
pk = self.class.primary_key.to_s
tn = self.class.table_name.to_s
self.send("#{pk}=",
self.class.find_by_sql("select lastid_both() as serialid from table(set{1})").first.serialid)
Rails.logger.info("Informix received the following serial-id: #{self.id}")

else
ret = super
end
ret
end

Fix broken application icons in Mac OS X Snow Leopard

So it happened again:

Most of my application icons were broken, i.e. only visible in a very low resolution.

After googling a bit I found the following discussion:
http://discussions.apple.com/thread.jspa?threadID=2142401

mdi’s suggestion did the trick for me: http://discussions.apple.com/message.jspa?messageID=10296267#10296267

What I did:

  • open Terminal.app (If you never did… : Try „spotlight-search“ –> Terminal)
  • enter cd /private/var/folders
  • enter sudo find . -name “com.apple.QuickLook.thumbnailcache”|xargs sudo rm -rf

                (you will have to enter your password)

  • Restart Finder.app using „Apple-Menu–> „quit immediately (It’s „Sofort Beenden“ in German. Dunno the english term) or press
  • command+option+escape“. Chose „Finder restart“.
  • Be happy 🙂

OK, to be honest I had to restart to be really happy 😐

NoMethodError: undefined method `empty?’ for 8:Fixnum

Argh…
This f…ine error message above has been thrown during a

records = Model.find(:first).

Guess why:

I made use of a legacy table that contained the attribute „type“. I just had to add a

self.inheritance_column=’itype’

into my model and now everything’s OK.

Rails: Do you consider this as friendly error messages?

Kinderhilfe.de defaced

Oh Mann. Jetzt haben tatsächlich irgendwelche Schwachköpfe die Seite
der Kinderhilfe.de “verändert”. Auch wenn der Verein Kritik in der
Presse einstecken musste, ist das noch lange kein Grund rechtswidrig
deren Webseite umzugestalten. Mal abgesehen davon, dass das für die
Petitionsgegner nur Wasser auf die Mühlen ist.
Wirklich blöde Aktion, die noch Nachwirkungen haben wird.
Nur kurz wg. unterwegs

Tobias