Monday, December 30, 2013

Simple Redmine deployment

Redmine is simpler to deploy than it might first appear. First, ignore you OSes rails etc. packages, other than the most basic:
yum install ruby
yum install ruby-devel
yum install rubygems
yum install gcc
yum install ImageMagick-devel
yum install sqlite-devel
Grab the most recent version of Redmine and install:
wget http://rubyforge.org/frs/download.php/77242/redmine-2.4.0.tar.gz
mv redmine-2.4.0.tar.gz /usr/local/src
cd /usr/local/src
gunzip redmine-2.4.0.tar.gz 
tar xvf redmine-2.4.0.tar 
cd redmine-2.4.0
cp config/database.yml.example config/database.yml
I just commented out the mysql connector in database.yml and uncommented production/sqlite3 as it's plenty fast enough for the simple projects I need to manage. Let bundler take care of installing the correct gems:
gem install bundler
bundle install
Create a secret token in configuration.yml, and migrate the db:
rake db:migrate RAILS_ENV="production"
cp config/configuration.yml.example config/configuration.yml
I wanted to use WEBrick and ssl, so retrieved this gist: https://gist.github.com/simi/1292552 and changed the port to 443. Generate a self-signed cert from the instructions at: http://www.sslshopper.com/article-how-to-create-and-install-an-apache-self-signed-certificate.html and put the generated file in their appropriate places, namely vendor/ssl/redmine.crt and vendor/ssl/redmine.key. For completeness, I created a /etc/init.d/webrick CentOS file:
#!/bin/bash
#
# chkconfig: 3 90 90
# description: run redmine WEBrick

### BEGIN INIT INFO
# Provides: webrick
# Required-Start: $network $local_fs
# Should-Start:
# Short-Description: run redmine WEBrick
# Description: run redmine WEBrick
### END INIT INFO

start() {
    /usr/local/src/redmine-2.4.0/script/rails server -e production -d
}

stop() {
    kill -KILL `cat /usr/local/src/redmine-2.4.0/tmp/pids/server.pid`
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status
    ;;
  restart|force-reload)
    stop
    start
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|force-reload}"
    exit 2
esac
"sudo chkconfig --add webrick" and "sudo server webrick start" kick things off in the right direction. Yeah, this is a little long, but I think a bit easier than other approaches.

Resetting iPhone restrictions password

I don't believe I ever set mine as it is something I wouldn't need to do, but my iPhone was convinced I did. Taking a look at the preferences showed that SBParentalControlsEnabled was YES, but there was no associated PIN:
This can the correct steps to resetting it: http://www.lafrutamordida.com/2013/10/restrictions-passcode-forgotten.html Thank you blogger, and wouldn't it be nice if Apple had a reasonable way to do this?

Sunday, December 22, 2013

"Rotating" files in Unix

I like to have a set of images on my desktop, and have used Geektool http://projects.tynsoe.org/en/geektool/ but because it's not open source and therefore I can't examine what appear to be bugs, I've switched to Nerdtool http://mutablecode.com/apps/nerdtool.html. I have a few directories that have multiple files that I want displayed in turn, but neither tool does this well. So I wrote the following bash script that takes a list of directories to "rotate" a ".current" link between. The files themselves aren't changed at all, and I set Nerdtool to update the display of that one file every ten minutes.
#! /bin/bash

# create a symbolic link named ".current" to the "next" file in a directory.
# keep track of the current file by use of a ".count" file.

for i in $*
do
    list=`ls -1 $i`
    total=`echo $list | wc -w`

    if [[ "$total" -eq "0" ]]; then continue; fi

    count=`cat $i/.count`

    # if this is the first time
    if [[ "$count" = "" ]]; then count=1; fi

    # if we'd wrap around, start again
    if [[ $count -gt $total ]]; then count=1; fi

    # make the count zero based to index the array
    zerobased=$((count-1))

    # bump and save count
    count=$((count+1))
    echo $count > $i/.count

    # turn words into array
    arr=($list)

    name=${arr[$zerobased]}
    rm -f $i/.current
    ln -s $name $i/.current
done

Thursday, December 12, 2013

Rainbow text in PowerPoint

I thought PowerPoint did this, but not on my Mac.  So I quickly created my own gradient using ROYGBI, adding 20% each time:

OS X and an HP DesignJet 1055CM

When adding this printer, use: http://www.openprinting.org/printer/HP/HP-DesignJet_1055CM as the driver -- the default PostScript driver does not work.