pdb

March 10th, 2010

I’m working on a feature for a project that I’m getting ready to open source. (more to come on it being open sourced when it happens) I’ve never taken the time to try and use pdb to debug a python program. I fell into a situation that seemed plausible to try it.

Found this post and was quite delighted to be able to dive right into debugging my app. Also of worth to note, the post references this link which once you have the basics of using pdb expands a little on what else you can do.

<3 pdb


Dvorak

March 8th, 2010

At work we got talking about Dvorak a little while back. I’ve been picking through this tutorial as I get time and really enjoying it. Just google Dvorak to read up on what so different about it. The main point I like is that people claim it reduces stress on your wrists. I figure with how much I’m on a computer it’s worth a try. I haven’t found any scientific evidence that it actually helps. Maybe I’ll get to the point of using it full time one day and have my own claim.

You can reconfigure your keyboard to use this layout regardless of it’s labelling. I’ve got my fedora and mac configured so I can swap between qwerty and dvorak very easily. There’s plenty of info on google on how to set this up. Once it’s setup on a mac just select your layout from the keyboard notification icon near the date/time on your menu bar. On fedora I use L-shift+Caps-Lock and it switches in and out of dvorak. I assume you can do it on windows too, but I don’t have a windows machine to try it on.

Still on lesson 17 in the tutorial so I can’t really do anything with it other than the tutorial yet… but I’m sure I’ll post a blog post in dvorak when I get to that level :)

ABCD: A Basic Course in Dvorak :: http://gigliwood.com/abcd/


Loki Update

March 1st, 2010

I started a project a while ago that was managing buildbots. It was a cli application that used sqlalchemy and func to manage buildbots across multiple machines. After some experience at work with build systems I realized that this setup was far to complex to expect someone to setup and use and it was fairly tied to a fedora/redhat infrastructure.

Well, I’ve started over. The new application is based on django and for now only installs bots on a single machine. I have plans to support a distributed configuration in the future. For now I just needed a decent interface to get some bots up and running fast.

I also have recorded a screencast to so a simple quick start. The screencast assumes you have some basic buildbot knowledge.

You can get more information, docs, the screencast and the code at https://fedorahosted.org/loki


Psalms

January 15th, 2010

Just a couple thoughts to chew on from this morning.

16 For you will not delight in sacrifice, or I would give it;
you will not be pleased with a burnt offering.
17The sacrifices of God are a broken spirit;
a broken and contrite heart, O God, you will not despise.

Psalm 51:16-17 (ESV)

4 Blessed is the one you choose and bring near,
to dwell in your courts!
We shall be satisfied with the goodness of your house,
the holiness of your temple!

Psalm 65:4 (ESV)


Back in Time to Dec 14th

January 3rd, 2010

I’ve been having trouble with on particular flash drive while trying to make my dad a Fedora Live USB sitck. Tonight briefly tried to fiddle with it to try and figure out what I was doing wrong. Not paying attention I fdisked my laptop drive and wiped out my drive partition. Kudos to Back In Time. I had a snapshot from december 14th of all my data. Most of anything I hadent backedup was pushed to a code repo elsewhere, so I just reinstalled. A few additional packages, email, VPN and kerb configs later I was back into a dec 14th state.

Back up you’re data!


The reason for the reason for the season

December 27th, 2009

I’ve been reflecting this past week about Christ’s birth and how this time of the year “the reason for the season” often references Luke chapter 2. Last weekend I spent time in this passage and Romans 3:10-18, John 3:16 and Matthew 7:21-23. These last three versus are the ones God seemed to press on me at the time to depict our sin, need for a saviour, God’s Love, the provision he sent and the requirement to know and follow him for salvation. In this New Testament era this gospel presentation seems like a great explanation of the reason for the reason for the season. Though, today Romans 11 was taught at church and I’ve also been preparing for leading worship at youth group at the January youth group meeting where Romans 12:1-2 will be taught. These passages seemed to open up a gospel message into some theology to chew on.

In college the phrase “what’s the therefore there for?” was burned into my brain for all eternity. Whenever I read Romans 12:1 that phrase pops into my head. Though, I hardly ever take the time to go back to Romans 11 and remind myself of it. It was nice to have just been taught on Romans 11 this morning as I was meditating on Romans 12:1 in preparation for the youth group meeting.

Enter the therefore, helping us understand God’s mercy.

25 Lest you be wise in your own sight, I want you to understand this mystery, brothers: a partial hardening has come upon Israel, until the fullness of the Gentiles has come in. 26And in this way all Israel will be saved, as it is written,
“The Deliverer will come from Zion,
he will banish ungodliness from Jacob”;

27“and this will be my covenant with them when I take away their sins.”28As regards the gospel, they are enemies of God for your sake. But as regards election, they are beloved for the sake of their forefathers. 29For the gifts and the calling of God are irrevocable. 30For just as you were at one time disobedient to God but now have received mercy because of their disobedience, 31so they too have now been disobedient in order that by the mercy shown to you they also may now receive mercy. 32For God has consigned all to disobedience, that he may have mercy on all.

33Oh, the depth of the riches and wisdom and knowledge of God! How unsearchable are his judgements and how inscrutable his ways!

34“For who has known the mind of the Lord,
or who has been his counselor?”
35
“Or who has given a gift to him
that he might be repaid?”

36
For from him and through him and to him are all things. To him be glory forever. Amen.

Romans 11:25-36 (ESV)

I think the meat of where we can understand the mercy 12:1 is referencing is in versus 27-32. Israel was disobedient and enemies of God so that we could receive mercy, that is, Christ’s sacrifice for our sins. Now by the mercy shown to us, because of their disobedience, they too can receive mercy for their disobedience. Christ is the reason for the season. The reason he came was just not just to save sinners. The reason he came was so that God could have mercy on all (Rom 11:32).

I often get wrapped up in my sinful self-centred-ness. God is quick to remind me that his plan is much bigger than my simple mind can comprehend. After reminding me this, again, a response to this understanding has been so eloquently placed just following the text at the end of chapter 11 with an appeal to begin chapter 12:

1 I appeal to you therefore, brothers, by the mercies of God, to present your bodies as a living sacrifice, holy and acceptable to God, which is your spiritual worship. 2 Do not be conformed to this world, but be transformed by the renewal of your mind, that by testing you may discern what is the will of God, what is good and acceptable and perfect.

Merry Christmas


Tobacco Road Marathon

December 15th, 2009

Tobacco Road Marathon is a new marathon in Cary, NC. I just signed up for the half marathon, it will be my first. Part of the route is on the American Tobacco Trail. It’s an old railway that has been re-purposed as a recreation trail in Wake and Chatham Counties in North Carolina.


Wordpress mu non-wildcard vhosts

December 4th, 2009

*** UPDATE ***
This hack is probably unnessesary, I found that wp-mu has a sites framework that is not exposed, there is a plugin that’s trying to accoplish the same thing I am. Just google ‘wordpress mu sites’
*******

I need to have multiple wordpress instances installed, but I want them each to have their own vhost, I also want an easy way to maintain them (upgrades and such). I thought wordpress mu could do this… but out of the box it only supports wildecards on a single domain. (blog1.example.com and blog2.example.com and blog3.example.com) Turns out you can change 2 lines (3 if you want to clean up a view cosmetically) and you seemingly can use wordpress-mu to host multiple domains. www.blog1.com and www.blog2.com and www.blog3.com

I’ve not deployed this yet… so use at your own risk. I’ll post again later with results after I’ve migrated a couple sites to it.

The problem: wp-mu assumes in vhost mode that all your blogs are of convention {something_here}.example.com. It does this by concatenating the domain you configure at install time onto the name of any new wordpress site you setup.

The solution: tell it not to append your installed time configured domain when you setup a new site. No special magic seems to happen with a new wordpress site’s configured domain after install time.

To show how this works this we’ll setup an example.com instance of wordpress mu and replace the wildcard magic so that not-example.com is hosted by the same code base.
1. download and and install wp-mu just as they tell you to, use example.com (set a hosts record to point example.com to your localhost) You’ll now have a fresh new wp-mu blog at example.com.
2. patch the files to remove the wildcard vhost magic
a. This change will remove the hardcoded base domain and will assume the domain name you’re accessing wordpress with is the current domain. Without amking this dynamic the authentication would fail on some or all of the configured sites.

wp-config.php
@@ -38,7 +38,7 @@
-define(‘DOMAIN_CURRENT_SITE’, ‘example.com’);
+define(‘DOMAIN_CURRENT_SITE’, getenv(‘HTTP_HOST’));

b. This is the concatenation magic that we want to prevent from happening. It undoes the “force append install-time configured domain” or in our example case, don’t force .example.com on the back of my new blog.

wp-admin/wpmu-edit.php
@@ -147,7 +147,7 @@
if( constant(‘VHOST’) == ‘yes’ ) {
-                       $newdomain = $domain.”.”.$current_site->domain;
+                       $newdomain = $domain;

c. This last one is optional. It’s just removes the domain name below the test box on the form for a new blog. This is a pure cosmetic change.

wp-admin/wpmu-blogs.php
@@ -582,7 +582,7 @@
<?php if ( constant( “VHOST” ) == ‘yes’ ) { ?>
-                                                       <input name=”blog[domain]” type=”text” title=”<?php _e(‘Domain’) ?>”/>.<?php echo $current_site->domain;?>
+                                                       <input name=”blog[domain]” type=”text” title=”<?php _e(‘Domain’) ?>”/>

3. Add a new wp site at not-example.com (add the hosts record that points to localhost again to test)
4. use the dashboard -> tools -> export to get an xml dump of a single instance blog that you can import into a wp-mu managed blog.

Like I said I’ve not actually deployed this yet, but authentication in and out of the two domains dashboard and frontend seem happy. I’ll be sure to update this post with any other issues I come across. let me know if you try it and if it works!


Expanding a xen disk image’s space

August 12th, 2009

I documented this a while back and never posted it. Had to use it again today so I figured it would be fun to post it.

Compiled these steps using these urls:

http://www.mail-archive.com/centos@centos.org/msg08928.html

http://www.howtoforge.com/linux_resizing_ext3_partitions_p2

1. use dd to create a 1 GB file

[root@virtserver os]# cd /var/lib/xen/images/os
[root@virtserver os]# dd if=/dev/zero of=Tempfile bs=1024 count=1000000

3.  backup your disk image

[root@virtserver os]# cp somehost.example.com-disk0 somehost.example.com-disk0.bkup

4.  append the tmp file to virtual image file

cat Tempfile >> somehost.example.com-disk0

5. attach to the disk image

[root@virtserver os]# modprobe xenblk
[root@virtserver os]# pwd
/var/lib/xen/images/os
[root@virtserver os]# xm block-attach 0 ‘file:/var/lib/xen/images/os/somehost.example.com-disk0′ xvda w

if you try and mount a file that doesn’t exist you’ll get output like this:

Error: Device 51712 (vbd) could not be connected.
File /var/lib/xen/images/os/notreal.example.com-disk0 is read-only, and so I will not
mount it read-write in a guest domain.
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode>

Create a new virtual block device.

if you copy and paste you may have to fix your single quotes. when I copy and pasted this I got a weird ascii error.

6. fsck

[root@virtserver os]# e2fsck -f /dev/xvda1
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/boot: 42/524288 files (2.4% non-contiguous), 28805/524112 blocks

[root@virtserver os]# e2fsck -f /dev/xvda2
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/: 43523/2097152 files (0.9% non-contiguous), 487769/2096482 blocks

7. Strip out the ext3 fournal

[root@virtserver os]# tune2fs -O^has_journal /dev/xvda1
tune2fs 1.39 (29-May-2006)

[root@virtserver os]# tune2fs -O^has_journal /dev/xvda2
tune2fs 1.39 (29-May-2006)

8. delete and re-add the last partition on the disk using the new end cylinder

[root@virtserveros]# fdisk /dev/xvda

The number of cylinders for this disk is set to 1156.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/xvda: 9514 MB, 9514450944 bytes
255 heads, 63 sectors/track, 1156 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1         261     2096451   83  Linux
/dev/xvda2             262         783     4192965   83  Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk /dev/xvda: 9514 MB, 9514450944 bytes
255 heads, 63 sectors/track, 1156 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1         261     2096451   83  Linux

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (262-1156, default 262):
Using default value 262
Last cylinder or +size or +sizeM or +sizeK (262-1156, default 1156):
Using default value 1156

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

8. fsck and recreate the ext3 journals

[root@virtserver os]# e2fsck /dev/xvda2
e2fsck 1.39 (29-May-2006)
/: clean, 62190/1048576 files, 860683/1048241 blocks

[root@virtserver os]# tune2fs -j /dev/xvda2
tune2fs 1.39 (29-May-2006)
Creating journal inode: done
This filesystem will be automatically checked every -1 mounts or
0 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@virtserver os]# tune2fs -j /dev/xvda1
tune2fs 1.39 (29-May-2006)
Creating journal inode: done
This filesystem will be automatically checked every -1 mounts or
0 days, whichever comes first.  Use tune2fs -c or -i to override.

9. Resize the filesystem

[root@virtserver os]# resize2fs -f /dev/xvda2
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/xvda2 to 1797271 (4k) blocks.
The filesystem on /dev/xvda2 is now 1797271 blocks long.

10. detach the disk image and get on with your day with more space

[root@virtserver os]# xm block-detach 0 xvda


Google found JADDOG

August 7th, 2009

I was working on something for work that involved python and kerberos again. Very generic search looking for the docs I used last time I was implementing similar functionality. Something seemed familiar about the last result on the second page:

JaddogGoogle

I don’t feel so much like and island in nowhere land any more.