LZMA2 / xz are the hottest new compression
algorithms on the block. When I found out Katello would
have to decrypt certain data payloads compressed with xz, I was excited to work
on it.
I found the excellent ruby-xz package and
got to work. My little bit of code (not quite ready for a pull request yet,
otherwise I’d link it) would simply have to check a file on a remote server,
figure out if the file was newer than the last check, and if so decrypt it and
process it.
This gem makes it so simple! You need to require ‘open-uri’ to open URLs as
file streams first.
The data I’m parsing is JSON, so I can’t load the data in chunks. Random chunks
of decompressed data would not be valid JSON.
12345678
require 'open-uri'
require 'ruby-xz'
...
open(@url) do |f|
JSON.load(XZ.decompress_stream(f))
end
I’ve started working on some software to improve management of Pathfinder
character sheets. I play Pathfinder weekly, and
while the game is quite nice, managing your character is an enormous pain in
the ass. I constantly have to erase and rewrite stuff, people forget to bring
their sheets and nobody knows how to level up. Surprisingly, nobody has really
solved this problem with software. WOTC provides a pretty nice tool for
electronic character management for D&D 4e, but it is surprisingly lacking in
mobile support.
There isn’t even a section of the Pathfinder rulebook that explicitly states
how leveling up works. The rules can be inferred by understanding multiple
sections of the book, but surprisingly there is no flow chart or even simple
paragraph explanation. I hope to fix that! The first goal of Hero Sheets is to
make it simple to create and level up characters. A clear, wizard(hah!)-like
interface and the ability to print a nicely formatted PDF will be a great start
and should hopefully please players everywhere.
I plan on releasing the core rules module as an open source rubygem.
I’ve mostly been working on the sign up page + blog right now, to help generate
interest, but once the gem is a little more polished I’ll toss it up on github.
Even if Hero Sheets isn’t successful, maybe the community can make something
interesting!
ldap fluff provides an easy way for your ruby apps to query regular LDAP,
FreeIPA and Active Directory systems for authentication and authorization.
It’s currently being used in the Katello Project
to provide the auth system with authentication and group membership info
You can easily add ldap fluff to your system, especially if you’re already using devise
or something similar, to add additional auth backend support. Here’s how to get started:
1
gem install ldap_fluff
You need /etc/ldap_fluff.yml to configure your LDAP connection. An example is provided in
the source repo
Here’s an example to connect to my FreeIPA server, named AMERICA
The service_user doesn’t have to be admin (and probably shouldn’t be - but I’m
no LDAP admin), but just any user that has R/O access to user & group data
Note that the “is in groups?” method is an AND operation. These methods should
provide all you need to support read only authorization and authentication
based on LDAP and LDAP groups.
The trick is that unlike Heroku, the Openshift cron system is basically just
like regular linux cron. They do not execute (by default) in your application’s
environment. Thankfully, it’s very easy to set up your scripts to run this way.
ruby cron example
12345678
#!/usr/bin/env ruby# this script will default to DEVELOPMENT if you dont force itENV['RAILS_ENV']||='production'requireFile.expand_path("./config/environment",ENV['OPENSHIFT_REPO_DIR'])Rails.logger.debug'daily cron job!'MyHelper.do_something_daily('internet')
It should be pretty obvious where to put your script files based on when you want
them to run!