<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Justin</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/" />
    <link rel="self" type="application/atom+xml" href="http://www.secnix.com/blog/justin/atom.xml" />
    <id>tag:www.secnix.com,2008-08-18:/blog/justin//1</id>
    <updated>2010-10-04T11:02:30Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.2-en</generator>

<entry>
    <title>HTC Desire / Android</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2010/10/htc-desire-android.html" />
    <id>tag:www.secnix.com,2010:/blog/justin//1.15</id>

    <published>2010-10-04T10:34:21Z</published>
    <updated>2010-10-04T11:02:30Z</updated>

    <summary>Ok, so it&apos;s been a looong time since I wrote a blog entry. Shocking. Nevertheless, I&apos;m still kicking. A couple months back, I decided to finally try something different than Blackberry. My biggest reason for doing so was 1) all...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Mobile" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[Ok, so it's been a looong time since I wrote a blog entry. Shocking. Nevertheless, I'm still kicking. A couple months back, I decided to finally try something different than Blackberry. My biggest reason for doing so was 1) all the fuss about Android and 2) RIM consolidating their full size Blackberries with the Curve models. <br /><br />I (still) had the Blackberry Bold 9000, and loved it's reliability, VERY EFFICIENT data usage, push services, multimedia capabilities, App store, and full size keyboard. I went to the US for a couple weeks, and during that time, I had disabled superfluous stuff like mailing lists and the weather applet, etc. I had real-time access to my email and gtalk/bb messengers to keep in touch. After the two weeks roaming in the US, I had used only £5 in data roaming. Stunning. <br /><br />But, after being offered and trying a Blackberry Bold 9700, I was revolted at the tight keyboard and discovered a lot of disgruntled users upset about the same thing. Obviously, it is clear that consolidating product offerings is a wise business decision in this competing market, but the BB 9000 was the pinnacle of RIM's achievements in the mobile communications for professionals sphere. Without doubt it is clearly the reigning king.<br /><br />So, with reluctance, I decided to dive in and see what all the fuss about Android was about. I wasn't ready to offload £400+ on the Nexus One, so I opted for the pretty much identical spec-wise HTC Desire. My carrier offered it to me on renewal -- of course -- for free.<br /><br />I received the phone promptly, and surprisingly, it was unlocked and unbranded. It ran Android 2.1 and of course HTC Sense UI. I was fairly pleased with the phone, but battery life was absolutely abominable. When you cannot make it through a normal day without charging your phone, it's simply a show stopper. I discovered the Power Control widget and promptly installed it. This widget allows you to disable services like sync, bluetooth, GPS, etc on demand. <br /><br />I noticed a great jump in battery life; however, I was anything but pleased. After about one week, I noticed the bottom half of the screen was a slightly different tint than the top of the screen. I had a couple friends confirm this; so, I contacted my carrier who happily replaced it very quickly. After receiving the new phone, I noticed it was no carrier branded, but still unlocked. I absolutely despise branded phones, so I looked at rooting the device and replacing it with a stock image. <br /><br />During my research, I noticed there were many unofficial ROMs available. One of the key attractions was removing the Sense UI (even though I do like Sense) and greatly increased battery life. xda-developers.com is an online playground with a vast amount of information. It does require patience and a lot of filtering to get to what you want, but it was well worth it. I will write about the actual process later, but suffice to say, I successfully rooted my phone and put an unofficial ROM (Richard Trip's DeFrost) on the Desire and have noticed not only finer granularity of control over the phone (such as a vastly expanded power control widget), but the stock UI and Cyanogen mod offer more flexibility while being quite unobtrusive.<br /><br />I've been following the DeFrost releases for over a month now, and while Android doesn't match the Blackberry as a communications device, I am overall happier now with better battery life, centralized contacts from Google, and more flexibility over the device. &nbsp; &nbsp; <br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Python Variable Naming Gotcha</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2009/07/python-variable-scope-gotcha.html" />
    <id>tag:www.secnix.com,2009:/blog/justin//1.9</id>

    <published>2009-07-27T21:18:13Z</published>
    <updated>2009-07-27T21:53:15Z</updated>

    <summary>Last fall, I had an interview that turned out to be challenging. While I did quite well on most of it, there was one question I simply could not answer. The question was this -- given the following code, what...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Python" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[Last fall, I had an interview that turned out to be challenging. While I did quite well on most of it, there was one question I simply could not answer. The question was this -- given the following code, what can you see as being a possible issue:

<pre class="code">
def append_list(x=[]):
    x.append(1)
    return x
</pre>

I -- like many other people -- couldn't see anything wrong with this. I simply assumed the default parameter would be used in lieu of calling with an actual value. However, examine the following snippet. func1 is the aforementioned function. func2 is the proper definition:

<pre class="code">
#!/usr/bin/env python

def func1(x=[]):
    x.append(1)
    return 'x = %15s, id(x) = %s' % (x, id(x))

def func2(x=None):
    if x is None:
        x = []
    x.append(1)
    return 'x = %15s, id(x) = %s' % (x, id(x))

for f in (func1, func2):
    print '%s %s' % (f.__name__, f())
    print f.__name__, f()
    print f.__name__, f()
    print f.__name__, f([2])
    print f.__name__, f()
    print
</pre>

The above snippet will produce something like the following. Have a close look: 

<pre class="code">
$ ./gotcha.py 
func1 x =             [1], id(x) = 3084437356
func1 x =          [1, 1], id(x) = 3084437356
func1 x =       [1, 1, 1], id(x) = 3084437356
func1 x =          [2, 1], id(x) = 3084466828
func1 x =    [1, 1, 1, 1], id(x) = 3084437356

func2 x =             [1], id(x) = 3084466828
func2 x =             [1], id(x) = 3084466828
func2 x =             [1], id(x) = 3084466828
func2 x =          [2, 1], id(x) = 3084466828
func2 x =             [1], id(x) = 3084466828
</pre>

As you can see, func1's output is completely unexpected (well maybe not depending on who you are). The problem here has nothing to do with variable scope as I originally assumed. It's actually because I didn't understand Python variables and how they have some fundamental differences to other language implementations.

<a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#default-parameter-values">This page</a> has some very good explanations for several Python idioms. In fact, that link pretty much explains this behavior. ]]>
        
    </content>
</entry>

<entry>
    <title>Fun With Mac and &apos;say&apos;</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2009/07/fun-with-mac-and-say.html" />
    <id>tag:www.secnix.com,2009:/blog/justin//1.14</id>

    <published>2009-07-10T22:38:21Z</published>
    <updated>2009-07-10T22:51:11Z</updated>

    <summary>This is officially what happens when a geek gets bored. A friend of mine was over tonight, and he showed me the &apos;say&apos; utility on Mac OSX. Well, you can imagine where this went. Say no more:#/usr/bin/env python from htmlentitydefs...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Apple" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Python" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[This is officially what happens when a geek gets bored. A friend of mine was over tonight, and he showed me the 'say' utility on Mac OSX. Well, you can imagine where this went. Say no more:<br /><br /><pre class="code">#/usr/bin/env python

from htmlentitydefs import name2codepoint as n2cp
import re
import urllib2
import os
import time
import string

class HTMLDecode(object):
    '''http://snippets.dzone.com/posts/show/4569
       There is absolutely no reason for this to be in a class. I just put it in one.
    '''
    __slots__ = ['substitute_entity','dcdhtmlent']
    def substitute_entity(self, match):
        ent = match.group(3)
        if match.group(1) == "#":
            if match.group(2) == '':
                return unichr(int(ent))
            elif match.group(2) == 'x':
                return unichr(int('0x'+ent, 16))
        else:
            cp = n2cp.get(ent)
            if cp:
                return unichr(cp)
            else:
                return match.group()

    def dcdhtmlent(self, string):
        entity_re = re.compile(r'&amp;(#?)(x?)(\w+);')
        return entity_re.subn(self.substitute_entity, string)[0]

class SpeakFarkHeadlines(object):
    '''This is what happens when you are bored and/or easily amused.'''
    __slots__ = ['headlines','speak']
    def __init__(self):
        self.headlines = []
        dcdr = HTMLDecode()
        response = urllib2.urlopen('http://www.fark.com')
        headline_re = re.compile(r'&lt;span\sclass="headline"&gt;(.*?)&lt;/span&gt;'<span\sclass="headline">)
        while True:
            try:
                search = re.search(headline_re, dcdr.dcdhtmlent(response.next().encode('UTF-8')))
                if search:
                    self.headlines.append(search.group(1))
            except StopIteration:
                break

    def speak(self):
        for entry in self.headlines:
            print entry         # Below is nasty hack for shell string scanning and quotes
            os.popen('say \'%s\'' % string.replace(entry, '\'', ''))
            time.sleep(5)

app = SpeakFarkHeadlines()
app.speak()
</span\sclass="headline"></pre>

<br />Now just sit back and have a good chuckle.]]>
        
    </content>
</entry>

<entry>
    <title>HP Photosmart C4585 and Linux</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2009/05/hp-photosmart-c4585-and-linux.html" />
    <id>tag:www.secnix.com,2009:/blog/justin//1.13</id>

    <published>2009-05-04T15:14:09Z</published>
    <updated>2009-05-04T16:26:07Z</updated>

    <summary>I hope I don&apos;t end up hating myself for this, but I have bought a new HP printer. I think it&apos;s been just over four years now since I actually had a printer at home. But, I figured I could...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Linux" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[I hope I don't end up hating myself for this, but I have bought a new HP printer. I think it's been just over four years now since I actually had a printer at home. But, I figured I could use a decent scanner/copier/printer at the casa. Now, the primary objective was as always best value for money followed by functionality, since my requirements are very little for the printing world. <br /><br />I must admit, I didn't do much preliminary investigation; because, I thought I could handle this quite well on my own based on experience. I mean, it just needs to be cheap and have good support for the Mac and at least I should be able to print from Linux as well. Everyone knows the primary cash cow for 'inkjet' type printers are the cartridges, anyway. Also, I wanted to avoid HP, because HP customer service is quite daunting. Just like BT, there is no face to HP really.

<br /><br />Well, enter Curry's. The Curry's on Ealing Broadway is just across from an Argos; so, I thought this would be a decent place to start in the retail world. Curry's didn't have the widest selection, albeit decent though. They carried Epson, Canon, Kodak and HP printers and all-in-one scanner/copier/printers. The particular one that caught my eye was the Canon Pixma MP 580. This model does not include WiFi or duplexing but does have a higher resolution and bluetooth. For the price of £88, it's not too bad.

<br /><br />They did not have the MP 620, however. That particular model includes WiFi and auto duplexing. But, Argos did for £146. I wasn't ready to spend that kind of money on a printer though; so, I turned back to Curry's and had a look at the HP C4585 which does have WiFi. Both the Canon and HP support Mac, and I figured the Linux drivers would be available for printing at least because of Cups. So, I went ahead and took the £68 on-sale HP. I went across to Argos and got a much better deal on the ink and headed home.
<br /><br />Installation on Mac was a snap, and I won't cover that here. Instead, after I had the printer setup , I wanted to at least be able to print from Linux, and using gnome's printer configuration made that a snap. It auto-discovered the printer on the network and default selected HPLIP driver. However, I was curious about the scanner and status functionality. So, I google'd HPLIP and came across <a href="http://hplipopensource.com/hplip-web/models/photosmart/photosmart_c4500_series.html">this</a> which indicates there is a GUI that does support scanning and status, e.g. ink levels. <br /><br />I searched the Jaunty package cache 'apt-cache search hplip' and found the appropriate package and then installed it 'sudo apt-get install hplip-gui' which installed an HPLIP Fax utility under Applications &gt; Office and an HPLIP Toolbox under System &gt; Preferences. For the record, I have not tried the Fax utility, but the HPLIP Toolbox works very good for scanning and checking status such as ink levels. The options to align print heads, calibrate, and clean the heads are also available. 

So, it looks like I actually got more than I bargained for on this purchase. ]]>
        
    </content>
</entry>

<entry>
    <title>Conficker and Submarines</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2009/04/conficker-and-submarines.html" />
    <id>tag:www.secnix.com,2009:/blog/justin//1.12</id>

    <published>2009-04-14T10:49:31Z</published>
    <updated>2009-04-14T11:15:01Z</updated>

    <summary>From Wikipedia:&quot;The UK MoD reported that some of its major systems and desktops were infected. The worm has spread across administrative offices, NavyStar/N* desktops aboard various Royal Navy warships and Royal Navy submarines...&quot;I have to ask myself, WHY?!?!?!?!?! Imagine you...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Random" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[From Wikipedia:<br /><br /><blockquote>"The UK MoD reported that some of its major systems and desktops were infected. The worm has spread across administrative offices, <i>NavyStar/N*</i> desktops aboard various Royal Navy warships and Royal Navy submarines..."<br /></blockquote>I have to ask myself, WHY?!?!?!?!?! <br /><br />Imagine you are a weapons operator on board one of her majesties finest submarines, the alarm comes over the general announcement circuit followed by "man battle stations torpedo", and at launch time there is a problem because the launch console cannot resolve the DNS query for the weapons launch console -- all because of Conficker! <br /><br />This may sound like an unrealistic scenario, but I'm not so sure that it is. As a matter of fact, I think it's a very realistic scenario. Why, because you cannot stop oblivious people from clicking on things in MSN like, "Hey dude, how's tricks? Check out these pills! They helped me get lucky this weekend, ROFL LULZ!!!1!!!11!!11. Click here to check them out."<br /><br />You cannot stop the same oblivious people from saving something on a USB stick from the same now infected computer and bringing that down to the boat no matter how hard you try. Why? Because these guys are gonna bring down pics of their naked girlfriends (or boyfriends) and letters from mum and anything else whathaveya.<br /><br />In turn, you cannot stop the same people from finding SOME WAY to get those files on to the network. Yes, it may be a long shot that it ends up on the same VLAN or air-gapped network for weapons systems, but it only takes one nub to do it and then someone is gonna look stupid -- as if they don't already.<br /><br />This follows the disturbing news from last year of the Royal Navy to up and use M$ Windows Battle Star Galactica Edition on warships (including submarines). I don't know what committee of half baked morons decided to approve something like this, but obviously there is a whole chain of people that were sleeping while this decision was made, or their input was simply ignored. Most likely it was the former.<br /><br />Submarines require the utmost in quality. Some things, like people's lives and national security, require more attention than other things. I wouldn't step foot on any submarine that relies on code probably written by a bunch of .NET software developers that have not the first clue how an operating system assigns memory or how those processes are scheduled -- not to mention a base operating system from a company with wreckless security and quality nighmare of a record.<br /><br />"Emergency blow!"<br /><br />"Shit Captain, the BCP just blue screened!" <br /><br />Godspeed to you sailors.&nbsp; <br /><br />&nbsp; <br />]]>
        
    </content>
</entry>

<entry>
    <title>Best UK Broadband</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2009/04/best-uk-broadband.html" />
    <id>tag:www.secnix.com,2009:/blog/justin//1.11</id>

    <published>2009-04-08T19:21:40Z</published>
    <updated>2009-04-08T20:21:10Z</updated>

    <summary>Choosing a broadband company is not a choice to be taken lightly. Consider that for the next several years, you will most likely not change it. Why? Simple, it&apos;s cheap, unobtrusive and something you come to take for granite. However,...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[Choosing a broadband company is not a choice to be taken lightly. Consider that for the next several years, you will most likely not change it. Why? Simple, it's cheap, unobtrusive and something you come to take for granite. However, your choice of Internet service provider is one of the most important choices you have in utilities. When it comes to gas, electric, water, etc., you have very little choice. But, there are a plethora of options when it comes to the Internet.<br /><br />Every day you surf the web, talk to friends and family, purchase things you want, pay bills and send emails perhaps for business or intimate personal details. But, interestingly enough, is your privacy being kept? Does your service provider care enough about you, the customer, to balk at intrusive governments (the UK ranking at the top) or the fortune seekers looking to profit off your every day life? <br /><br />Unbeknown to most users, the amount of personal information the average person generates online is of considerable value to governments and revenue seekers. For something that costs so little, the social impacts are the most of any other comparable choice, and this is perhaps even more true than any other generation that has lived before. I only say this because in the UK, the largest service providers are turning to a company that has its roots in the lowest of the low human fortune-seeking dwellers. <br /><br />This is only compounded by the fact the UK has brought forth and passed legislation that enforce various social networking sites and other Internet service providers to keep your personal data for some specific amount of time. Right now that happens to be 12 months. But, where does it end? For providers like BT and Virgin Media (the UKs largest providers by far), they have decided to partner with a company known as Phorm.<br /><br />Phorm has its roots in the bottom feeding world of spyware. It was formerly known as 121media, but has tried to transform itself into a legitimate company, promising millions in ad-generating revenue to ISPs worldwide. If you are a subscriber to Virgin Media, Talk Talk or BT Internet, I have one phrase for you -- switch now! <br /><br />These companies are actively using Phorm technology to eavsdrop on your every day web traffic and make that information available to targeted web advertisers among other things. They attempt to gloss over these privacy-invasive acts by saying it protects you from phishing and other malicious activity on the Internet. But, this is very laughable coming from a company that invented itself on activities considered outright shocking at best. A case was even brought forth to the US FTC against 121media.<br /><br />I'll save the details and let you do some reading:<br /><br />http://en.wikipedia.org/wiki/Phorm<br /><br />The excuse "I have nothing to hide" is frivolous and lazy at best. While it is very easy for one to use this excuse, it is a violation of your responsibility as an honest citizen of this planet to condemn and protest activities of major organizations that infringe on basic human rights. The UK government is already well underway -- indeed a primary backer of EU initiatives in this realm -- to take away your privacy and force ISPs to log all data, including emails. <br /><br />Just one other thing to put this in persepective -- the Russian Federation -- one of the more "European" countries to take a giant eye roll on human rights, hasn't even gone so far as to enforce legislation of this type. And, ISPs do not engage in this behaviour, either. <br /><br />The last point I have to make is with customer service. As an American, I expect the utmost in customer service. When I have a £ to spend, someone better deserve it. Someone (or company) better make me feel special. They need to make me feel like they deserve my £. I can say that most large providers I have come into contact with -- the largest offender being BT -- that they don't give one single shit about your business.<br /><br />In fact, companies like BT are in a situation where they simply don't have to care about you. Case in point, in a city like London, I made an appointment for a house move two weeks in advance. On the day of the appointment, I called and asked where they were. The lady told me they had knocked on the door and no one answered. Now, I know that was complete bullshit, but they refused to do anything about it. But, what can you do? BT Opengroup owns it all. Monopoly lock, stock and two smoking barrels -- but I digress.<br /><br />After I finally got my BT line in place, I called BE Unlimited, my ISP, to do the house move. They told me it would be done in five business days (because of BT Opengroup union laziness). On the fourth business day, they emailed me to let me know the local exchange work had been done -- quite the surprise, actually, when dealing with BT extended lunch engineers. But, when I got home, alas there was no Internet. I called Be, and they told me it would actually be done the next business day. <br /><br />But, since I had a DSL light on my router, I knew they could do better. So, I "challenged" them to get my DSL working. After two minutes, the engineer came back on the line and told me to go ahead and switch to dynamic IP and it would work for now. Voila, excellent customer service. That's what I call bending over backward to make me feel special.<br /><br />But, to my first point, Be has made it clear that they have no intentions of working with companies like Phorm. As a matter of fact, when I have asked them about it, instead of getting the usual "I don't know", I get a very affirmative, "we have no plans to work with companies like Phorm or any kind of targeted advertising."<br /><br />That's very reassuring. Personally, I think Be takes their broadband seriously. I have had the best in customer service, and I always get someone that knows what they are talking about. It simply works, but they give in to the more technically advanced of us out there. I know this sounds like a paid advert for Be, but to be honest with you, I'm just a user that takes my customer service and privacy seriously. <br /><br />One last note, Be told me that what I should have done in retrospect is call and ask for a SIM code when I did the BT line move. In turn, you would then call and provide them this information, and you wouldn't have to wait an extra week for your broadband. Class. &nbsp; <br /><br /><br />]]>
        
    </content>
</entry>

<entry>
    <title>Editing Oracle&apos;s spfile with vi</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2009/03/editing-oracles-spfile-with-vi.html" />
    <id>tag:www.secnix.com,2009:/blog/justin//1.10</id>

    <published>2009-03-27T11:34:10Z</published>
    <updated>2009-03-27T16:41:05Z</updated>

    <summary>The fact I would even post this suggests that I am not an Oracle DBA. Shamefully, I attended the Oracle Administrator I course a couple years ago but am no better off because I just can&apos;t find the time. Anyway,...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Random" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[The fact I would even post this suggests that I am not an Oracle DBA. Shamefully, I attended the Oracle Administrator I course a couple years ago but am no better off because I just can't find the time. Anyway, I find myself having to fiddle with Oracle on and off beyond the basic startup, shutdown and writing scripts to replace my DBA. Yes, I must admit, I don't micromanage, I just automate it &gt;:-}

<br /><br />I wrote some scripts some time ago to do various things such as setting Oracle's db_file_name_convert and log_file_name_convert in a larger project that used Oracle's RMAN to automatically duplicate databases. Some time later, we added another database to the cluster. This exploited a "bug" in the code (mine, yes) which set the first parameter to db_file_name_convert empty. So, the bad entry in the spfile looked like 'db_file_name_convert = '', '/path/to/db'.

Just to save some time, I will recreate what happened:<br /><br /><pre class="code">SQL&gt; alter system set db_file_name_convert = '', '/opt/ora-three/DEVEL3' scope=spfile sid='*';

System altered.

SQL&gt; shutdown abort
ORACLE instance shut down.
SQL&gt; startup
ORA-01078: failure in processing system parameters
LRM-00117: syntax error at ',' at the start of input
SQL&gt; 
</pre>

<br />For some of us, you're in trouble. Why? Because looking up those error codes reveals very little information. After digging around for a while on Google, there were hints to something foul in the spfile. I opened up the spfile and noticed that erroneous line db_file_name_convert.<br /><br />From previous experience, you cannot edit the spfile with a tool like vim because it is a binary file and vim somehow fouls this. I thought I'd be clever and do it with sed. But, alas, this did not work, either.<br /><br />

<pre class="code">ORA-27046: file size is not a multiple of logical block size
Additional information: 1
</pre>

<br />The easiest way to fix this is simply use good ol' strings to make a pfile from the spfile and recreate the spfile. Apparently, besides the binary padding, the spfile is the same as the pfile. Maybe some Oracle DBAs will have something to say about this:<br /><br />

<pre class="code">$ strings spfileDEVEL3.ora &gt; pfile.ora
</pre>

<br />Now, edit this file with your favorite text editor and fix the erroneous line because a pfile is a plain ol' text file. After that, recreate the spfile from this pfile and start Oracle.<br /><br />

<pre class="code">SQL&gt; create spfile from pfile='/opt/ora-three/pfile.ora';

File created.

SQL&gt; startup nomount
ORACLE instance started.

Total System Global Area  788529152 bytes
Fixed Size		    2076008 bytes
Variable Size		  230687384 bytes
Database Buffers	  549453824 bytes
Redo Buffers		    6311936 bytes
SQL&gt; 
</pre>]]>
        
    </content>
</entry>

<entry>
    <title>My new iMac</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2009/02/my-new-imac.html" />
    <id>tag:www.secnix.com,2009:/blog/justin//1.8</id>

    <published>2009-02-09T09:46:50Z</published>
    <updated>2009-02-09T09:56:14Z</updated>

    <summary>Well folks, after six long years of pulling out my credit card only to have that little something inside me pull away, I finally did it -- yes I got an Apple computer. And, what do I think about it?...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Apple" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[Well folks, after six long years of pulling out my credit card only to have that little something inside me pull away, I finally did it -- yes I got an Apple computer. And, what do I think about it? Well, I can't believe I didn't do it six years ago! <br /><br />I decided on the 20" iMac. It took a whole 30 minutes and I was drowning in the abyss of elegant computing. The UI is absolutely fantastic, applications just work, bluetooth just works, and it's really so simple anyone can make their way around within a short amount of time. Now, one of the niftiest features is Ctrl-Cmd-D while hovering over a word in a Cocoa application -- instant dictionary. Or, how about Cmd-Shift-D, insant search for your files, applications or whatever else you need to find.<br /><br />I installed VirtualBox and immediately put Linux Mint in a VM, and Cmd-F, voila, now I'm full screen in Linux Mint! Anyway, these are just a couple of the cool features I've tripped across. I opened up a terminal to pleasantly find the BSD userland around me. All the familiarity was there -- Perl, Python, Bash, and on and on. <br /><br />I look forward to discovering all the little niceties Apple has put into OSX and continue using all the open source tools I have been using over the last 12 years. One thing of interest is PyCocoa application development. Apparently, XCode supports this right out of the box.<br /><br />What else should I be looking for...<br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Dynamic Bash Variable Names</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2008/10/dynamic-bash-variable-names.html" />
    <id>tag:www.secnix.com,2008:/blog/justin//1.7</id>

    <published>2008-10-28T21:05:59Z</published>
    <updated>2008-10-28T21:35:03Z</updated>

    <summary>I found myself in the middle of a rather large Bash project a little while back. Basically, I had defined several file paths in variable names and needed to access that information dynamically. The scenario is this: a value would...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[<p>I found myself in the middle of a rather large Bash project a little while back. Basically, I had defined several file paths in variable names and needed to access that information dynamically.
</p>
<p> The scenario is this: a value would be supplied by the user, and I had to pull out some hard-wired information based on this value. So, suppose you were writting a script that referenced file types arranged by extenstions and was selected by the user at run time. This would be easily solvable in the following:
</p>
<pre class="code">
#!/usr/bin/env bash

# List of variables maybe in some other file
JPG_FILE_PATH="/opt/path/one"
DOC_FILE_PATH="/opt/path/two"
MP3_FILE_PATH="/opt/path/three"
XLS_FILE_PATH="/opt/path/four"

get_file_path() {
    local ID=${1-''}
    # Sets FILE_PATH to the desired value. If not exist then null.
    FILE_PATH=$(eval "echo \${$(echo ${ID}_FILE_PATH)"-''})
}

get_file_path "MP3" 
echo $FILE_PATH

$ ./test_pre.sh
/opt/path/three
</pre>

<p>The above snippet -- admittedly a bit humorous -- is very useful in several situations. I happened to use it in creating a shell library of functions and paths that are used by others in the easy creation of scripts around Oracle RDBMS.
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Red Hat Certified Engineer</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2008/09/red-hat-certified-engineer.html" />
    <id>tag:www.secnix.com,2008:/blog/justin//1.6</id>

    <published>2008-09-20T07:18:35Z</published>
    <updated>2008-09-20T07:55:30Z</updated>

    <summary>I took some time to sit in the RH300 this week. Basically, it is a five day course with exam for those with previous RHCE certifications or others with significant experience with RHEL. Its ultimate goal is preparing students for...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[I took some time to sit in the <a href="http://www.redhat.com/courses/rh300_rhce_rapid_track_course_and_rhce_exam/">RH300</a> this week. Basically, it is a five day course with exam for those with previous RHCE certifications or others with significant experience with RHEL. Its ultimate goal is preparing students for the RHCE exam on the fifth day of the course.<br /><br />My experience -- and other's mileage will vary depending on the instructor -- was quite good. This was not the typical slideshow-break-slideshow-lunch with boring labs layout many of us have been exposed to from other vendors. It was quite intense with enough lecture, demonstration and labs to last two weeks -- packed into four days. <br /><br />We were engaged from 0900 to 1730 every day with short lunches. Looking at the <a href="http://www.redhat.com/certification/rhce/prep_guide/">RHCE prep guide</a> it is easily understandable as there is a tremendous amount of information to cover in such a short period of time. The instructor in my case was knowledgeable and provided thorough examples all throughout the course.<br /><br />The labs are well planned, and the infrastructure Red Hat has designed for the classroom labs just works. The only problem we had was the first day when we discovered the workstations we were using had a broken ACPI implementation. For some reason we performed this course in a different venue than originally planned, so that was the only minor setback.<br /><br />Unfortunately, I am unable to share the exam experience, but I will say that it is one of the more challenging things I have done in such a short period of time, and I am glad that I did it. Generally, I frown upon industry certifications and courses as I'm a firm believer that vendors should provide ample documentation and you can go it alone. I have relied on this most of my career. After all, most certifications are purely marketing and money gimmicks. But, Red Hat definitely shows that some training is worth the money and their certifications are notable.<br /><br />So, I'm an RHCE now. And, I definitely enjoyed those beers Friday night! <br />]]>
        
    </content>
</entry>

<entry>
    <title>Sensible Link Management in Movable Type</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2008/08/sensible-link-management-in-movable-type.html" />
    <id>tag:www.secnix.com,2008:/blog/justin//1.5</id>

    <published>2008-08-27T11:09:17Z</published>
    <updated>2008-08-27T12:25:57Z</updated>

    <summary>Please note the following has only been tested on version four of the software!After I had installed my Movable Type blog software, I was quickly coming up to speed on some basics necessary to publish an aesthetically-pleasing and comfortably-navigated blog....</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[Please note the following has only been tested on version four of the software!<br /><br />After I had installed my Movable Type blog software, I was quickly coming up to speed on some basics necessary to publish an aesthetically-pleasing and comfortably-navigated blog. However, I quickly noticed a feature that is not readily available: customizeable link management.<br /><br />One must pose the question why this feature is not part of the standard build. But, thanks to the guys and gals in #movabletype on freenode, I was pointed to a plugin called LinkRoller. The author of the software, "arvind", pushed me in the right direction, and thanks to the modular design of Movable Type, I was up and running quickly.<br /><br />If you want the ability to customize your links within your blog, this is what you need. First, <a href="http://plugins.movalog.com/link-roller/">download</a> the software and follow the <a href="http://plugins.movalog.com/link-roller/install/">installation instructions</a>. Installation for me was a breeze, and I encountered no issues. The brief video on the installer page will quickly demonstrate how to create links. At this point, you should go ahead and create a link such as <span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.secnix.com/blog/justin/assets_c/2008/08/link_example_manage_assets.html" onclick="window.open('http://www.secnix.com/blog/justin/assets_c/2008/08/link_example_manage_assets.html','popup','width=642,height=401,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">this one</a></span>&nbsp;following the video provided on the download page. Use a sensible tag and description fields. This will be demonstrated shortly.<br /><br />
Now you must somehow display your links on your blog. To do this, you need to create a widget and then choose where to display it. Navigate to Design &gt; Widgets in the control panel.&nbsp; Select "Create widget template" from "Widget Templates" and enter "LinkRoller" in the top form field. Next, choose one of the following examples:<br /><br />If you simply want all of your links displayed in one menu (not sorted), copy and paste the following code in code form field: <br /><br />
<pre class="code">&lt;div class="widget-linkroll widget"&gt;
    &lt;h3 class="widget-header"&gt;Interesting Links&lt;/h3&gt;
    &lt;div class="widget-content"&gt;
    &lt;MTLinks&gt;
    &lt;MTLinksHeader&gt;
    &lt;ul&gt;
        &lt;/MTLinksHeader&gt;
            &lt;li&gt;&lt;a href="&lt;$MTLinkURL$&gt;"&gt;&lt;$MTLinkName$&gt;: &lt;$MTLinkDescription$&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;MTLinksFooter&gt;
    &lt;/ul&gt;
    &lt;/MTLinksFooter&gt;
    &lt;/MTLinks&gt;
    &lt;/div&gt;
    
&lt;/div&gt;
</pre>


<br />This is good, but not necessarily satisfying or flexible enough for some. Naturally, I, <a href="http://plugins.movalog.com/forums/viewtopic.php?id=794">along with others</a>, wanted a mechanism to classify the link entries in accordance with tags. Thanks to one clever poster this can be done as follows:<br /><br /> 
<pre class="code">&lt;div class="widget-linkroll widget"&gt;
&lt;h3 class="widget-header"&gt;Interesting Links&lt;/h3&gt;
  &lt;div class="widget-content"&gt;
    &lt;mt:Tags type="asset" sort_by="name"&gt;
      &lt;ul class="widget-list"&gt;
      &lt;li&gt;&lt;h4&gt;&lt;mt:TagName&gt;&lt;/h4&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;MTSetVarBlock name="linktag"&gt;&lt;mt:TagName /&gt;&lt;/MTSetVarBlock&gt;
      &lt;ul class="widget-list"&gt;
        &lt;mt:Assets type="link" tag="$linktag"&gt;
          &lt;li&gt;&lt;a href="&lt;mt:AssetURL&gt;"&gt;&lt;mt:AssetLabel escape="html"&gt;: &lt;mt:AssetDescription&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;/mt:Assets&gt;
      &lt;/ul&gt;
    &lt;/mt:Tags&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre><div><br />After choosing one of the two options -- or rolling your own -- click save and return back to the widgets page. Before publishing your blog so you can see your links, the final step is to place the widget in your selected widget set. Under "Widget Sets", select your layout and <span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.secnix.com/blog/justin/assets_c/2008/08/add_link_roller_widget_to_set.html" onclick="window.open('http://www.secnix.com/blog/justin/assets_c/2008/08/add_link_roller_widget_to_set.html','popup','width=850,height=747,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">drag your newly created widget</a></span> from "Available Widget" to "Installed Widgets". Once you have pressed "Save Changes" and the system finishes the update, you can now publish your blog.<br /><br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="link_roller_widget.gif" src="http://www.secnix.com/blog/justin/2008/08/27/link_roller_widget.gif" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" width="196" height="276" /></span><br />Happy linking!<br /></div><div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>Google Street View In My Neighborhood</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2008/08/google-street-view-in-my-neighborhood.html" />
    <id>tag:www.secnix.com,2008:/blog/justin//1.4</id>

    <published>2008-08-26T08:52:46Z</published>
    <updated>2008-08-26T12:29:25Z</updated>

    <summary>On the way to work this morning -- and just outside my flat -- I spotted the Google street view car. Seems this one was a little Vauxhall with an even bigger panoramic camera array mounted prominently on the roof....</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Random" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[On the way to work this morning -- and just outside my flat -- I spotted the Google street view car. Seems this one was a little Vauxhall with an even bigger panoramic camera array mounted prominently on the roof. The image below I snapped with my mobile camera while I was walking, so it's not the perfect photo. However, you can still make out the Google logo on the door:<br /><br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="google_streeet_view2.jpg" src="http://www.secnix.com/blog/justin/2008/08/26/google_streeet_view2.jpg" class="mt-image-center" style="margin: 0pt auto 20px; text-align: center; display: block;" width="695" height="536" /></span><br />Sightings of Google's <a href="http://www.youtube.com/watch?v=O4OJcnwTRiA">controversial</a> vehicles are <a href="http://blogs.guardian.co.uk/digitalcontent/2008/07/the_google_street_view_car_spo.html">nothing new</a>. On its début in London, it was <a href="http://technology.timesonline.co.uk/tol/news/tech_and_web/article1870995.ece">widely publicized</a> with one being <a href="http://www.telegraph.co.uk/news/2475792/Google-Street-View-car-pulled-over-by-police-for-driving-in-bus-lane.html">stopped by the police</a>. I for one welcome our enterprising overlords -- it's far more comfortable than the real "big brother's" never-ending installation of video surveillance on every street and in every tube station. Some day when you have nothing better to do, spend time cruising the virtual Google street view, it's amusing what you can find frozen in time.<br /><div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>2008 Olympics</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2008/08/2008-olympics.html" />
    <id>tag:www.secnix.com,2008:/blog/justin//1.3</id>

    <published>2008-08-24T21:49:21Z</published>
    <updated>2008-08-24T22:35:14Z</updated>

    <summary>Well, what a games this has been! Beijing put on quite the show, and the facilities were first rate, too. I&apos;m starting to wish I was actually there. Never mind the fake buildings and lip syncing nine year old (which...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[Well, what a games this has been! Beijing put on quite the show, and the facilities were first rate, too. I'm starting to wish I was actually there. Never mind the <a href="http://blog.wired.com/business/2008/08/beijings-brand.html">fake buildings</a> and <a href="http://www.latimes.com/sports/olympics/la-fg-lipsync13-2008aug13,0,5944370.story">lip syncing nine year old</a> (which by the way I think is down right pathetic and sorry) -- all kinds of records were broken and there was a few surprises from the good ol' USA.<br /><br />A while back I was in Kazan, Russia. While hanging out one night in the super club <a href="http://www.state51.ru/">51st State</a>, I ran into two rather tall American guys. Both were 6'8" plus. While sharing a few drinks, they told me how they were playing volleyball for a Russian team in Kazan, but would be heading to Beijing to play for the USA men's team. <br /><br />To be honest, I didn't give it much thought other than I thought it was cool. I did however promise them I would watch them play. Well, a few months past, and I completely forgot about it. However, while watching the final gold medal match, I suddenly remembered about these two guys. I recognized both of them. One is <a href="http://sports.yahoo.com/olympics/beijing/usa/Lloy+Ball/220145;_ylt=AhvxNVU.OXiEbvvwhNaa69A1o5N4">Lloy Ball</a> (I believe the team captain) and <a href="http://sports.yahoo.com/olympics/beijing/usa/Clayton+Stanley/244428;_ylt=AmPWvcgfZrfBMYwajdtRjBc1o5N4">Clayton Stanley</a> (super spiker). <br /><br />It was quite the thrill to see <a href="http://www.zenit-kazan.com/eng/media/photo/?year=2008&amp;rzd=29&amp;id=582">these two guys</a> help take out the defending champions Brazil.&nbsp; Lloy is apparently a four time Olympian and a distinguished veteran of the sport and was one of the star players throughout the match. Clayton scored 20 points in the match and ended up with the Gold medal match point winning spike!<br /><br />Bravo guys! What a match! I hope I run across you two again. I wouldn't mind buying you guys a drink.<br /><br />Cheers! <br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Master Boot Record Oops</title>
    <link rel="alternate" type="text/html" href="http://www.secnix.com/blog/justin/2008/08/master-boot-record-oops.html" />
    <id>tag:www.secnix.com,2008:/blog/justin//1.2</id>

    <published>2008-08-21T14:53:59Z</published>
    <updated>2008-08-26T12:29:51Z</updated>

    <summary>One of my colleagues has a laptop that dual boots with Windows XP (R) and Ubuntu (Hardy Heron). He received a new laptop and wanted to move the partitions from the old hard drive to the new laptop&apos;s hard drive.The...</summary>
    <author>
        <name>Justin</name>
        
    </author>
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.secnix.com/blog/justin/">
        <![CDATA[<p>One of my colleagues has a laptop that dual boots with Windows XP
(R) and Ubuntu (Hardy Heron). He received a new laptop and wanted to
move the partitions from the old hard drive to the new laptop's hard
drive.<br /><br />The data migration went well, and the laptop would boot
straight into Windows, so we needed to install grub back to the master
boot record (MBR). Naturally, we booted off the Hardy CD, and I figured
we'd just reinstall Grub to the MBR straight from the Grub menu.<br /><br />Now, this is quite straightforward. You simply boot from a livecd, mount the root and/or boot partition(s), chroot and drop to the grub shell. Finally, do something like:</p>
<pre class="code">grub&gt; root (hd0,0)
root (hd0,0)

or

grub&gt; find /boot/grub/stage1
find /boot/grub/stage1
 (hd0,0)
grub&gt; setup (hd0)
</pre>
<p>However, we received:</p>
<pre class="code">
grub&gt; find /boot/grub/stage1
Error 15: File not found
</pre>
<p>Well, that's not good! I considered trying</p>
<pre class="code">
# dd if=/boot/grub/stage1 of=/dev/sda count=1
</pre>
<p>but didn't have the courage to do it and looking back on it now it wouldn't have worked anyway. So instead I ignorantly copied the MBR from the other disk as it was supposed to be a clone and applied it to the new disk using dd of course.</p><p>The outcome WAS NOT PRETTY! Grub could not find any partition. In short, the file allocation tables were all wrong. Not to worry, we just loaded up Winternals ERD and ran a lengthy scan on the disk. I figured the $2345245 software would surely bail us out of this mess. Wrong!<br /></p><p>The solution was <a href="http://www.cgsecurity.org/wiki/TestDisk">this gem of an open source beauty</a>. I loaded this on a USB stick, booted off the Heron livecd, and ran the binary it ships with. Within minutes it found the correct partitions and we were able to restore the MBR with the correct file allocation tables.</p><p>However, we were just back to square one and needed to install Grub to the MBR. We figured out that what done us over in the first place was the fact the Ubuntu partition was not the active partition. Easily fixable:</p>
<pre class="code">
# fdisk /dev/sda 
... 
Command (m for help): a 
Partition number(1-5): 2 
... 
</pre>
<p>At this point we were able to boot back into the livecd and run grub correctly. Lesson learned -- just because you've done something numerous times that should be straightforward -- backup!</p>]]>
        <![CDATA[<br />]]>
    </content>
</entry>

</feed>

