Friday, November 5, 2010

How to setup a static ipaddress via the command line in linux

From time to time I need to do some manual network configuration via the command line in Linux.  At one time I would gasp at the thought, with the help of Google I have become very comfortable with command line activity.

Here is a great article from Cybercity.biz.  They go into a lot more detail.  I have put the info below that I used:

Howto: Ubuntu Linux convert DHCP network configuration to static IP configuration

Open network configuration file
$ sudo vi /etc/network/interfacesOR$ sudo nano /etc/network/interfaces
Find and remove dhcp entry:
iface eth0 inet dhcp
Append new network settings:
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Save and close the file. Restart the network:
$ sudo /etc/init.d/networking restart


Thursday, November 4, 2010

Ubuntu 10.10 Install was hanging on the startup screen

I was trying to reinstall Ubuntu 10.10 on my laptop today and it was freezing on the  "Preparing to install Ubuntu" screen.


Turns out it was my 2 USB drives that were plugged in were causing it to freeze.  Once I unplugged the drives, the install starting working. 

Wednesday, October 20, 2010

I lost DB.php, Where do I find it?

I was helping a colleague get a website back online after a server meltdown.  The database was not connecting and the page was complaining about a missing file:  DB.php.  I checked the backup and the files were not there.

Of course the first thing that came to mind is how did this website ever work if it needs that file...?

After some Googling and testing I found that  I needed to install the DB model from the PEAR Repo.

pear install DB

I ran that as root and I was in business.

Sunday, October 10, 2010

Coldfusion Form Validation for the Lazy Programmer

I love to program but I don't like to type.  I constantly look for ways to type less but accomplish more.  When I am not using CFWheels I end up having to type a whole lot more.

The other day I came up with this function:

<cfset not_required="billingform,address_2">
<cfloop collection="#form#" item="key">
<cfif not listFindNoCase(not_required,key) and trim(form[key]) is "">
 <cfset variables.e = variables.e & "<li>#ucase(replace(key,'_',' ','all'))# is a required field.</li>">
</cfif>
</cfloop>



The only thing I am not happy about is it doesn't show the error messages in any kind of order, which makes longer form errors look kind of weird, but I don't consider that to be too big of an issue because most of the time a user is only gonna be shown 1 or 2 error messages.

So what do you think?  How could this function be improved upon?

Friday, October 8, 2010

Caps First Title -- Capitalize the first letter of each item in a list

A while ago I needed to capitalize the first letter of every item in a list.  I created a handy dandy UDF in Coldfusion.

<!---
Capitalize the first letter of each item in a list.

@param str      List to parse. (Required)
@param delimiter      List delimiter. Defaults to a comma. (Optional)
@return Returns a string.
@author Randy Johnson (randy@cfconcepts.com)
@version 1, May 30, 2010
--->

<cffunction name="capFirstList" returntype="string" output="false">
<cfargument name="str" type="string" required="true" />
<cfargument name="delimiter" default="," required="false">

<cfset var newstr = "" />
<cfset var word = "" />
<cfset var separator = "" />

<cfloop index="word" list="#arguments.str#" delimiters="#arguments.delimiter#">
<cfset newstr = newstr & separator & UCase(left(word,1)) />
<cfif len(word) gt 1>
<cfset newstr = newstr & right(word,len(word)-1) />
</cfif>
<cfset separator = arguments.delimiter />
</cfloop>

<cfreturn newstr />


So what do you think?  How can I improve on this function?