Disable Upstart Scripts in Ubuntu

Posted by Tres 14/11/2011 at 23h30

chkconfig [SERVICE] off giving

The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'rsyslog' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'screen-cleanup' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'udev' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'dmesg' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth-stop' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth-splash' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'console-setup' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'network-interface' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.

Use sudo update-rc.d [SERVICE] disable instead.

Add Border to UIView Elements

Posted by Tres 22/07/2011 at 20h35

Adding a border to a UIView in iOS is easy:

(UIViewElement).layer.borderColor = [UIColor redColor].CGColor;

(UIViewElement).layer.borderWidth = 2;


   scoreViewHeading.layer.borderColor = [UIColor redColor].CGColor;
    scoreViewHeading.layer.borderWidth = 2;

Import CSV Into SQLite

Posted by Tres 12/07/2011 at 06h48

Got CSV to import into a database (Core Data purposes, maybe?):

sqlite> .mode csv
sqlite> .import ./file.csv dbname
sqlite3> .output dbname.sql
sqlite3> .dump tableName

Make Disk Images Quickly With qemu-img

Posted by Tres 26/05/2011 at 17h22

Tired of waiting for dd write disk images?

Try this instead:

qemu-img create -f raw /path/to/disk.img 6G

Where 6G is – you guessed it – 6 GB of disk image.

Remap Control and Caps Lock in Linux

Posted by Tres 21/05/2011 at 09h25

Lots of solutions out there using X tools.

no X:

sudo loadkeys
keymaps 0-15
keycode 58 = Control
keycode 29 = Caps_Lock
^d

After typing loadkeys there’s no feedback. Just type in the three lines & you’ll be good to go.

Hide Status Bar

Posted by Tres 14/03/2011 at 08h12

Hiding Status Bar in every View Controller and View still won’t get the job done. Just add the following to your App Delegate’s )application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions method:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

XCode 4 Says "The selected run destination is not valid for this action."

Posted by Tres 13/03/2011 at 02h01

Apple has removed the ability to define iPad only when creating a project in XCode 4. When building an ipad only app with XCode 4, you might get the error

The selected run destination is not valid for this action.

This could happen for any number of misconfiguration issues on the project or target. If you’re planning on building an iPad only app, make sure that Targeted Device Family is set to iPad.

blacklist package on debian

Posted by Tres 04/03/2011 at 23h36

Don’t want something updated or messed with when using Debian/Ubuntu

echo "[package-name] hold" | sudo dpkg --set-selections

Installing Postgres as RPM in CentOS gives "PG_VERSION is missing"

Posted by Tres 03/01/2011 at 12h00

So the RPM doesn’t quite finish the job.

initdb /var/lib/pgsql/data

If you get complaints about the directory already existing, well move the directory or remove it.

Casting Object Types In Rails

Posted by Tres 28/12/2010 at 11h08

too easy:

my_object = Object.last
my_object.becomes(NewObjectType)

Two caveats:

    1) this doesn’t actually change the object type. It’s a change in memory, but any saves or updates to the record will write back to the database as the original object type.
    2) The other caveat is that this should only be used in duck typing where you want a child class to appear to be a parent class. So boy.becomes(Dad) works, but cat.becomes(Dog) will likely cause problems.

Putting this here because google queries for stuff like “rails cast object” weren’t very helpful.

"Cipher is not a module" Error From Ruby on CentOS 64

Posted by Tres 13/12/2010 at 21h33

This error seems to come up for a number of different reasons relating to library confusion on the backside of Ruby.

I’ve built a 1.8.7 64 bit Ruby RPM that I’m currently using on a bunch of CentOS boxes. There’s no i386 libs in there. This means that every time I want to install my Ruby RPM, Yum wants to find the i386 counterpart. Finding none there, it simply grabs the nearest possible thing – some ancient 1.8.6.xxx thing from some other repo & proceeds to mangle everything.

So if you’re seeing something like this:

cipher.rb:22: Cipher is not a module (TypeError)

when you try running anything that requires openssl, then you might check to see whether yum has mangled your ruby packages with differing versions.

rpm -qa | grep ruby
ruby-1.8.7.302-3
rubygem-nokogiri-1.3.1-1.el5
ruby-libs-1.8.7.302-3
ruby-libs-1.8.5-5.el5_4.8
ruby-rdoc-1.8.7.302-3
ruby-devel-1.8.7.302-3
ruby-devel-1.8.5-5.el5_4.8
rubygems-1.3.6-1
ruby-irb-1.8.7.302-3
ruby-ri-1.8.7.302-3
ruby-augeas-0.3.0-1.el5

Remove the offending packages & things should be good to go.

To fix on a more permanent basis, just make sure yum doesn’t throw i386 cruft on the box. Add the following to your /etc/yum.conf

exclude = *.i386

Puppet Reports Time Offset As SSL Cert Issue

Posted by Tres 07/12/2010 at 20h05

err: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Turns out that running ntpdate gets this issue resolved.

This only becomes an issue when the client has its clock set to sometime in the future (say UTC) and the OS is configured so that future date is interpreted as local time. The puppetmaster sees a cert that can not possibly be valid and reports it as a certificate issue.

Perfectly sensible, but it’s a pain to figure out.

Puppet Certificate Issues After Host Rebuild

Posted by Tres 07/12/2010 at 18h26

So you’re trying to re-add a host that was rebuilt and Puppet is saying:

err: Could not request certificate: Retrieved certificate does not match private key; please remove certificate from server and regenerate it with the current key

So you go to the puppetmaster and run:

puppetca -c <hostname>

But that’s only half the battle.

You’ll also need to remove

/var/lib/puppet/ssl/certs/<hostname>.pem 

on the client before running puppetd again.

Puppet Reference

Posted by Tres 23/11/2010 at 00h26

Set Up A Gem Repo

Posted by Tres 31/10/2010 at 20h03

Making a gem repo is pretty painless.

1) You’ll need the builder gem.

gem install builder

2) Create the repo file layout. You’ll need to set up a folder called gems in a directory served by your web server.

cd /path/to/webdir
mkdir gems

3) Move your gem files into the gems directory you just created.

mv my.gem gems

4) Generate the repo resource files:

gem generate_index -d /path/to/webdir/

Note that we’re in the directory above the gems directory created in step 2.