Wednesday, June 29, 2011

I have officially moved this blog to http://www.davemineer.com

No matter what blog software I use in the future this should be the URL pointing to that blog. Please update your aggregator. Does anybody even follow this lame blog?

Friday, May 27, 2011

How do I add a user on ubuntu 11.04?

Long time ago I got a dell mini 9 inch and the kids kind of like it but the keys are really small, so is the screen so there wasn't a lot of love.  Then we lost the power adapter and it sat idle for a long time.  Probably 6 months.  I found a replacement power cord on ebay for about $7 and now we can use it again.

it came with XP but that was running slow so I installed ubuntu on it to try and make it more interesting.  I think it worked.  I kind of have fun with it.  Just a toy so far and really it will probably be that way for ever cause it is so small.

Back to the point.  I want it to work right when I logon which means I want some stuff saved as part of my user profile, but I don't want the kids getting on to my stuff either.

We added one user from the command line. My son actually did that, good job buddy! I found an article that shows how to do it via the gui interface:

http://www.liberiangeek.net/2011/03/addremove-users-ubuntu-11-04-natty-narwhal/

To summarize: 
System Settings, System, Users and Groups

IIS Manager Error: The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

 

I am trying to set up a local dev environment again.  Have tried apache, mysql and everything over the years, this time I am using IIS (Have also done that before) and MSSQL because our main DB is in MSSQL.  I am having trouble installing coldfusion so I reboot and when it comes back up I try and start my web server but I get the error above.  A netstat -ao tells me what is using what ports but the PID doesn't match anything in task manager, but from google search I see that skype defaults to port 80 if you let it.  Shut down skype (only for a second cause I use it all the time) and my websites start up now.

 

Skype has option under Tools/Options/Advanced/Connection "Use port 80 and 443 as alternatives for incoming connections.  Unchecked that and all should be well. Will see if I have any problems with skype.  Another option is to start your webserver before you start skype which is probably what would happen if you let your webserver start automatically.  I don't do that cause I don't always use it and don't want it hoggin resources on my dev machine.  I use a batch script to start up what I need for my dev environment and the webserver is part of that.

 

Skype Version (5.3.0.111)

Monday, May 23, 2011

Database Maintenance - Previous Thursday, Current Week, Last day of week.

We keep bumping into some bad field values from the old database.  These usually aren't an issue in our new database but since we use the old one for some stuff it is important to keep it clean throughout.  Each one of our records has 3 fields which correlate it to a specific publication of our newsletter.  The first day of our publishing week, the week, and the last day of our publishing week.  Some of our records were missing these values and I went in search of finding a way to bulk update.  The biggest challenge was getting the beginning day of the week. We work on a Thursday - Wednesday week.  The reasons for this are another blog post.  Anyway to find the previous thursday of any week I used the following:

update table
set beg =
    CASE
        WHEN DATEPART(dw,date) in (5,6,7) THEN dateadd(dd,5-DATEPART(dw,date),date)
        ELSE  dateadd(dd,1-(DATEPART(dw,date)+3),date)
    END
    WHERE beg is null
Basically, what happens is that it checks the day of the week and if it is 5,6, or 7, (that means Thursd, Fri, or Saturday) then it substracts 5 - that number.  So if thursday would be 5-5 = 0 and datadd 0 would stay thursday(5). otherwise take the day and subtract from 1.  This will always be a negative number which works with the datadd to get you back to the previous thursday.  So, if it is a tuesday, that would be a 3. So 3+3 =6 and 1-6 = -5, so Tuesday - 5 days = mon,sun,sat,fri,thurs TADA! back to the previous thursday.

If there be an easier way, let me know.


I mentioned that I also had to get the end date and the week.

For the end date I simply updated the end = dateadd(dd,6,beg) where end is null

Don't get tricked into thinking that is a 7, it is a 6. That's always been a problem for me since there are 7 days in the week. but you add by 6 to get to where you need to be, I promise.

The week was simply a datepart(ww,end)-1.  Why -1, just how it has always been for us.  Calendar week 1 is sometimes very short, I think even 1 day if it is a saturday or something.  Go learn about that, I just know for us we area always at sql(week) - 1 for our current week.

Friday, May 06, 2011

jQuery autoselect

Today I wanted to use the jQuery autoselect feature to add an autoselect to an input field on a web page.  I have heard alot about jQuery but until yesterday I really hadn't done anything with it. (how horrible is that)  Yesterday I used it for the simple task of updating a text field with the value of a select dropdown field. Simple, this is all it took:

$("#jid").change(function(){
   $("#city").val($("#jid option:selected").text());
});

Where jid is the select dropdown and city is the text input I wanted the text from the dropdown to be copied to.

The autocomplete was a little more complicated, but not much.  I use the following as the basis for this project and pretty much just copied it and adapted it to my site:

http://www.coldfusionjedi.com/index.cfm/2010/4/12/Playing-with-jQuery-UIs-Autocomplete-Control

jQuery does make things easy.  I use a cfc as in the 2nd to last example on above to return dynamic results. 

Wednesday, April 27, 2011

Find and Fix Scientific Notation values in a field

Many years ago during some importing or upgrading to a bigger better database one of my fields was converting longer numerical values to scientific notation.  This quit happening but I still had alot of those values in a text field in my database. Originally that field was numeric, but we converted it to text because there were often times when letters were added to the values we receive.

After not being able to find a isScientificNotation() function I found the values like this:

select myfield, LTRIM(str(cast(my field as real))), * from mytable

This worked great and made it easy to write an update statement like so:

update mytable
set myfield = LTRIM(str(cast(myfield as real)))
where myfield like '%e+%'

No more scientific notation in my field. Cool. Should have fixed this years ago, or not let it happen in the first place.

Dave

Friday, July 30, 2010

Railo on mac

I have had a great time at CFUNITED this year.  One of the things that has been a hot topic, which I haven't really caught wind of until today, is the battle between Adobe and the CFML open source alternatives, mainly Railo and Open BD.  I will save that topic for another post.  But that, along with the fact that I have been wanting to do it anyway, prompted me to give Railo a run.

I am mac challenged.  I spend 95% of my time on a PC.  The only time I seriously use my mac is when I travel, and at home in the evening, so maybe I only spend 80% of my time on a PC.  So I can't handle any advanced stuff on a mac.

Railo provides a version that you don't have to install.  That is good for me.  It is called "Railo Express (Jetty)".  It worked just as expected.  I dropped in my apps folder after unzipping the archive and double clicked on "Start" and there you go.  I pointed my browser to http://localhost:8888/ and up came a screen prompting me for a new password.  After selecting one I was presented with the admin interface for railo.

I snooped around the admin interface for a minute, but then I wanted to just see a regular page.  I opened up the index.cfm file in the railo directory (under applications for me, it had a weird name that represented the relase number and everything) under webroot and noticed there was a cflocation:

<cflocation url="railo-context/admin.cfm" addtoken="no">

I commented that out and then I was able to use that page like any other cfm page and add cfml to it however I want.

Pretty nice that railo makes it so easy to get started with CFML.  I have a hard time articulating my thoughts on stuff, like the adobe vs open source battle, but being able to start coding in CFML so easily seems like a good thing for our community.

Monday, May 10, 2010

Coldfusion 9 orm where in clause

I was trying to do a where in clause using coldfusion 9 orm and it just didn't work. I know pretty fast when something is over my head. A quick search revealed this thread: http://groups.google.com/group/cf-orm-dev/browse_thread/thread/19dc48732d58fca0/f47f3d4ef2e75aab?lnk=raot&fwc=1 in the cf9 orm mailing list. This thread discusses the exact issue I was wondering about. At the end, Barney Boisvert gives an example of how to do this (you have to click on "show Text" in the Bob Sivlerberg Post)

Since I can't figure out how to post code to this STUPID blog, you will have to visit the link.

I also had another issue, I wanted to still use offset and maxrows.  That was easy enough even though I tried to make it hard, and you can see that solution in my post to the same group: http://groups.google.com/group/cf-orm-dev/browse_thread/thread/ab1f8badf28dfbb5?hl=en