Running MacOS X on Windows

by Nathan 1. March 2010 08:03

 

Using VMWare 7 you can easily run MacOS X Snow Leopard within windows.

 

 

 

Follow this site and you will be able to succesfully run MacOS within your windows box.

http://www.ihackintosh.com/2009/12/install-snow-leopard-in-vmware-7-windows-edition/

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Windows

Attempted to access an unloaded AppDomain

by Nathan 1. March 2010 07:55
Problem occured when running application in debug mode, have resolved by restarting Visual Studio 2005.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

URL Rewriting apache mod_rewrite

by Nathan 24. February 2010 07:54

 

You have to make sure  you have AllowOverride in your httpd.conf for mod_rewrite to work.

To make the rewrite active for a website you have to change the .htaccess file

An example of the content would be:

Options +Indexes
Options +FollowSymlinks
RewriteEngine on
#RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L] 

This script converts all requests to a .html file to a .php file. So it appears as a HTML file to the end user.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

PHP

Convert Invalid Date Formats MySQL

by Nathan 17. February 2010 10:42

 

I have started work on a existing database where the DOB field has not been setup correctly and is a varchar which has allowed many invalid date formats:

I have been in the process of converting a lot of dates to the format dd/mm/yyyy

This i just a verbose of my queries I have used in the process:

 


-- Change DateFormat - to /

UPDATE user SET DOB = REPLACE(DOB,'-','/')
WHERE DOB NOT REGEXP
'(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][1-9]|3[0-1])/([1-3][0-9]{3,3})'
AND DOB NOT LIKE '%/%' AND DOB LIKE '%-%'
AND LENGTH(DOB) = 10


-- Change DDMMYYYY DateFormat to DD/MM/YYYY

UPDATE user SET DOB = CONCAT(SUBSTRING(DOB,1,2),'/',SUBSTRING(DOB,3,2),'/',SUBSTRING(DOB,5,4))
WHERE DOB NOT REGEXP
'(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][1-9]|3[0-1])/([1-3][0-9]{3,3})'
AND DOB NOT LIKE '%/%' AND DOB NOT LIKE '%-%'
AND DOB NOT LIKE '%.%' AND DOB NOT LIKE '% %'
AND LENGTH(DOB) = 8



-- Finding Invalid Date Formats

SELECT * FROM user WHERE DOB NOT REGEXP
'(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'


-- Finding Invalid Date Formats that don't conform to dd/mm/yyyy

SELECT * FROM user
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND LENGTH(DOB) <> 10
AND DOB NOT REGEXP '2?/'


--- converted ddmmyyyy to dd/mm/yyyy

UPDATE user SET DOB = CONCAT(SUBSTRING(DOB,1,2),'/',SUBSTRING(DOB,3,2),'/',SUBSTRING(DOB,5,4))
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND LENGTH(DOB) <> 10
AND DOB NOT REGEXP '2?/'
AND DOB REGEXP '[0-9]{8}'


SELECT * FROM user
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND LENGTH(DOB) <> 10
AND DOB NOT REGEXP '2?[/]'




--- converted ddmmyy to dd/mm/19yy

UPDATE user SET DOB = CONCAT(SUBSTRING(DOB,1,2),'/',SUBSTRING(DOB,3,2),'/','19',SUBSTRING(DOB,5,2))
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND LENGTH(DOB) <> 10
AND DOB NOT REGEXP '2?/'
AND DOB REGEXP '[0-9]{6}'


--- finding dates with alpha's

SELECT * FROM user
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND DOB REGEXP '[A-Z]{1}'

----

removing invalid chars

UPDATE user
SET DOB = REPLACE(DOB,' ',''), DOB =REPLACE(DOB,'.',''), DOB = REPLACE(DOB,',','')
,DOB = REPLACE(DOB,'`',''), DOB =REPLACE(DOB,'//','/'), DOB = REPLACE(DOB,',','')
, DOB = REPLACE(DOB,'O','0')



-- Finding Valid Date Formats

SELECT * FROM user WHERE DOB REGEXP
'(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'


-- convert dd/mm/yy assuming dob is in the 1900s

UPDATE user SET DOB = CONCAT(SUBSTRING(DOB,1,2),'/',SUBSTRING(DOB,4,2),'/','19',SUBSTRING(DOB,7,2)) 
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND DOB LIKE '%/%'
AND LENGTH(DOB) = 8

-- remove DOB with . at the end

UPDATE user SET DOB = SUBSTRING(DOB,1,10)
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND DOB LIKE '%.%'
AND DOB NOT LIKE '%/%'
AND DOB LIKE '%.'


--- replacing DOB's with '.' to '/'

UPDATE user SET DOB = REPLACE(DOB,'.','/')
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND DOB LIKE '%.%'
AND DOB NOT LIKE '%/%'
AND DOB REGEXP '^[0-9]'



----


UPDATE user
SET DOB = REPLACE(UPPER(DOB),'JANUARY','01'),
 DOB = REPLACE(UPPER(DOB),'FEBURARY','02'),
 DOB = REPLACE(UPPER(DOB),'MARCH','03'),
 DOB = REPLACE(UPPER(DOB),'APRIL','04'),
 DOB = REPLACE(UPPER(DOB),'MAY','05'),
 DOB = REPLACE(UPPER(DOB),'JUNE','06'),
 DOB = REPLACE(UPPER(DOB),'JULY','07'),
 DOB = REPLACE(UPPER(DOB),'AUGUST','08'),
 DOB = REPLACE(UPPER(DOB),'SEPTEMBER','09'),
 DOB = REPLACE(UPPER(DOB),'OCTOBER','10'),
 DOB = REPLACE(UPPER(DOB),'NOVEMBER','11'),
 DOB = REPLACE(UPPER(DOB),'DECEMBER','12')

------------
UPDATE user
SET DOB = REPLACE(UPPER(DOB),'JAN','01'),
 DOB = REPLACE(UPPER(DOB),'FEB','02'),
 DOB = REPLACE(UPPER(DOB),'MAR','03'),
 DOB = REPLACE(UPPER(DOB),'APR','04'),
 DOB = REPLACE(UPPER(DOB),'MAY','05'),
 DOB = REPLACE(UPPER(DOB),'JUN','06'),
 DOB = REPLACE(UPPER(DOB),'JUL','07'),
 DOB = REPLACE(UPPER(DOB),'AUG','08'),
 DOB = REPLACE(UPPER(DOB),'SEP','09'),
 DOB = REPLACE(UPPER(DOB),'OCT','10'),
 DOB = REPLACE(UPPER(DOB),'NOV','11'),
 DOB = REPLACE(UPPER(DOB),'DEC','12')

----------


UPDATE user SET DOB = REPLACE(DOB,'ST','')
,DOB = REPLACE(DOB,'ND','')
,DOB = REPLACE(DOB,'RD','')
,DOB = REPLACE(DOB,'TH','')


------------

SELECT * FROM user
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND DOB NOT REGEXP '2?/'


-------
-- only display dates with 6 numbers ie ddmmyy

select * from user
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND LENGTH(DOB) <> 10
AND DOB NOT REGEXP '2?/'
AND DOB REGEXP '[0-9]{6}'
 

-- swapping dates from mm/dd/yyyy to dd/mm/yyyy

UPDATE user SET DOB = CONCAT(SUBSTRING(DOB,4,2),'/',SUBSTRING(DOB,1,2),'/',SUBSTRING(DOB,7,4))
WHERE DOB NOT REGEXP '(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)'
AND DOB REGEXP '3?[/]'
AND LENGTH(DOB) = 10
 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

SQL

Prevent Cache of SWF Files and Xml Content in Flash

by Nathan 19. August 2009 09:17

 

If you like the flash player to expire the content of the SWF file add the following line between your <HEAD></HEAD>  tags

<META HTTP-EQUIV="Expires" CONTENT="Mon, 04 Dec 1999 21:29:02 GMT">
for more information check out: 
http://kb2.adobe.com/cps/147/tn_14743.html 

 

To prevent flash caching xml data, you can use the cache manager extension. It basically adds a timestamp to the querystring so it looks like a unique request.

 

You can download this from here:

http://www.communitymx.com/content/article.cfm?cid=827ea

Once you install the extension the usage is quite simple:

xml.load(CacheManager.uncacheURL(XmlFileLocation));

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Flash

Debugging in Flash using Trace

by Nathan 30. July 2009 09:51

 

Sometimes you will need to debug your flash application when its running live, for example if you are using server side scripts that are giving an Xml Response etc.

There is a way to output this information to a text, so you can have trace("Testing Response:" + myVariable); etc

 

1. You have to uninstall the original flash player you hav

2. Download the Debugger Version of Flash (You can get this on the Adobe Website)

3. For Windows XP add a file called mm.cfg to your X:\Documents and Settings\(UserName)

Inside the file add the following lines:

MaxWarnings=0
ErrorReportingEnable=1
TraceOutputFileEnable=1

4. You will then be able to find the output in the file  X:\Documents and Settings\(UserName)\Application Data\Macromedi\Flash Player\Logos\flashlog.txt

I usually run this in a program like textpad so it will bring up the file changes automatically.

 

NOTE: To stop the output you can go to publish preferences and select omit trace actions (This will stop people reading your trace information)

 

It is also possible to out the data using External Interface calls to Javascript, I will write more on this soon.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Calculating Elapsed Time ActionScript

by Nathan 27. July 2009 09:58

 

function calculateTimeElapsed(startTime:Date,endTime:Date) {
    
    var sHours = startTime.getHours();
    var sMinutes = startTime.getMinutes();
     var sSeconds = startTime.getSeconds();
    var sMilliSeconds = startTime.getMilliseconds();

    var eHours = endTime.getHours();
    var eMinutes = endTime.getMinutes();
     var eSeconds = endTime.getSeconds();
    var eMilliSeconds = endTime.getMilliseconds();
    
    var sTimeSpan = (sHours*3600*1000) + (sMinutes*60*1000) + (sSeconds*1000) + (sMilliSeconds);
    var eTimeSpan = (eHours*3600*1000) + (eMinutes*60*1000) + (eSeconds*1000) + (eMilliSeconds);
    return eTimeSpan - sTimeSpan;
    
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Flash

Dynamically Creating Movie Clips in Flash

by Nathan 16. July 2009 05:19

var myText:TextField;

for (var i:Number = 1; i<6; i++) {
        this["clip"+i] = new MovieClip();
        this["clip"+i].graphics.beginFill(0xFFFF00);
        this["clip"+i].graphics.drawCircle(40, 40, 40);
        this["clip"+i].x=i*80;
        myText=new TextField;
        myText.width=250;
        myText.height=250;
        myText.text="clip" +i;
        myText.x=10;
        myText.y=20;
        this["clip"+i].addChild(myText);
        addChild(this["clip"+i]);
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Flash

Clearing All Textbox Programatically in ASP.NET Web Form

by Nathan 15. July 2009 11:04

There are multiple ways of doing this ie using JavaScript, but this is the server side solution.

You can adapt this method for several other solutions:

        foreach (Control c in this.Page.Controls)
        {                        
            if(c.GetType().FullName.Equals("System.Web.UI.HtmlControls.HtmlForm")) {
                foreach (Control cForm in c.Controls)
                {                        
                    if(cForm.GetType().Equals(typeof(TextBox))) {   
                        ((TextBox)(cForm)).Text = "";
                    }
                }
            }
        }

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

SQL UPDATE INNER JOIN

by Nathan 13. July 2009 06:41

 

If you want to update the data in a table by getting information from another table.  You can acheive this by using an update inner join query.

For example if i wanted to update the phone numbers in my table using a list of contacts from a secondary table, the UPDATE INNER JOIN Query would be like the one below:

UPDATE c
SET c.PhoneNumber = c2.PhoneNumber
FROM Contact AS c
INNER JOIN ContactTable2 c2 on c.Id = c2.Id
WHERE DateCreated > GETDATE()-60

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SQL

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

I am a Website Developer and Designer based in Sydney, Australia. I have experience in developing websites and applications using various languages including C#, VB, C++, Flash (ActionScript), SQL and Linux. You can see some of my projects at www.nathanbaker.com.au

Page List