Need to split big SQL dump into separate databases?

I do. So I’ve written small bash script to do so. I think it’s self explanatory and does it’s job well :)

#!/bin/bash

if [[ $# -lt 1 ]]; then
  echo "Usage: $0 filename"
  exit 1
fi

FILE=$1
echo "Spliting "$FILE""

# default filename for sql headers
dbname=header

cat $FILE | while read line; do
 # echo $line
  if [[ $line =~ ^USE\ \`([^\`]*)\`\; ]]; then
    dbname=${BASH_REMATCH[1]}
    echo "Found db '$dbname'"
  fi
  echo $line >> $dbname.sql
done

I do NOT have CREATE DATABASE in sql file, thus set to USE..

Change image in UIImageView – RubyMotion

I needed to change image in my UIImageView, but simply setting new image using myImageView.setImage didn’t work. There’s simple workaround

@button = UIView.alloc.initWithFrame(frame)
buttonImage = UIImageView.alloc.initWithFrame(@button.bounds)
buttonImage.setTag(1) # set any number you want
buttonImage.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
@button.addSubview buttonImage

and now set the image

self.button.viewWithTag(1).setImage(UIImage.imageNamed('answer_bar_white.png').resizableImageWithCapInsets(UIEdgeInsetsMake(18, 18, 18, 18)))

you can remove resizableImageWithCapInsets – I’m using square images to make UIImageView of any size.