Wednesday, July 6, 2011

Generate a controlled random number in matlab

The main idea here is to generate a random number knowing the minimum and maximum limits, also the size.
The command to do it is
randi([imin,imax],[m,n])
where :
imin: is the minimum number
imax: is the maximum number
m: is the rows in the array (which determine the result size)
n : is the columns in the array (which determine the result size)

a useful application for this, is when you want to generate random numbering in Hex.
at this point you can choose, the above function and then use the dec2hex

Tuesday, June 7, 2011

Remove weekend days from list of days MS access

One of the things that I faced, was how to remove the weekend dates from a list of days.
The solution was simple.
use the function:
DatePart 
This function is fully listed in the following link:
http://www.techonthenet.com/access/functions/date/datepart.php

What I did is the following to remove Sunday and Saturday.
the DatePart returns a number between 1(Sunday)-7 (Saturday)
so I did:
where DatePart("w",(DayColumnInDays.MM/DD/YYYY))<=6 And DatePart("w",(DayColumnInDays.MM/DD/YYYY))>1

This is how I removed the weekends

Wednesday, June 1, 2011

Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (latin1_general_ci,IMPLICIT)

This is a very common problem that you might run in at all times.
To over come it, do the following:
1- Open MySQL Query browser
2- Go to the first table you are facing a problem with.
3- right click and hit "Edit Table" OR hit (F2) for a short cut
4- click on the variable you have a problem with from the "Column Name"
5- Go to "Column Details" Tab
6- On the far right you will see the "Column Collate:" switch it to the default value you want (either swedish or general)
7- Do the same with the Other table
And that is it

Tuesday, May 31, 2011

unknown object in backup file

One of the biggest problems that dazzled me for a while was receiving this error message from Mysql while trying to restore my backup file. The file was only 3GB of size yet it failed and at different locations. After a long search online I found the answer, and I believe it is worth mentioning it.
do the following steps:
1- the main cause is the max_allowed_packet
2- use the mysql system tray monitor
3- run mysql query browser
4- type
show variables like 'max_allowed_packet'
5- you will notice that the size is low
6- change the size by typing
set global max_allowed_packet= 500*1024*1024;
7- you can increase the 500 number to larger or smaller, the important thing is to make it bigger than what you saw in step 4
8- now run mysql administrator
9- go to startup variables on the left
10- go to advanced networking tab
go to advanced
click on Data / Memory size
click on Max. Packet size and put the same number we put up their
and that is it