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