While searching for a mobile browser detection code, I came across this site: http://detectmobilebrowsers.com/
This site generates the code for popular browsers to detect using the USER AGENT of the browser used. It's free to use, and donation to keep the site alive is pretty much appreciated by the author.
This is another useful website, that is simple to use, but takes a while to dissect the code. You pretty much need to brush up on your regular expression to understand the code and what it compares. But if you are not worried about the code behind the detection, by all means, just paste the code to your site and set the redirection page.
Website Development & Programming related to front-end and back-end. Tech news: on gadgets, technology for the web and other things I think will be of use to people to be on the know.
Wednesday, December 26, 2012
Thursday, October 25, 2012
Minimum & Maximum Year in MS SQL
You guys remembered the millennium bug, in year 2000? It's where some people fear, the computers will crash, and planes will also crash when in flight, because of the bug on the year, where the computers only allow until year 2000. Well I didn't believe it, and wasn't affected by that scare.
But, there is such things as limits I supposed.
In MS SQL 2000 & 2005, they have the following limits:
This was fixed in MS SQL 2008, where they have the following limits to the dates:
If we ever reached that year 10000, then they will probably panic again like the millennium bug scare. Or people will be cyborgs with numbers on their names and probably fear they will be affected by the limit.
But, there is such things as limits I supposed.
In MS SQL 2000 & 2005, they have the following limits:
- minimum date of 1753-01-01 00:00:00.000
- maximum date of 9999-12-31 23:59:59.999
This was fixed in MS SQL 2008, where they have the following limits to the dates:
- Minimum date: 0001-01-01 00:00:00.000
- Maximum date: 9999-12-31 23:59:59.999
If we ever reached that year 10000, then they will probably panic again like the millennium bug scare. Or people will be cyborgs with numbers on their names and probably fear they will be affected by the limit.
Friday, September 7, 2012
Solution when submit method throws "object doesn't support this property or method" error.
Thank God, for the internet and Google. I was able to solve this problem right away. Somehow if you use the code: document.formname.submit() in javascript you will get an error when you named another object as 'submit'.
I was able to change the other objects name and everything was fine. On my case the object in conflict is the submit button, that usually by default named as 'submit'. I only change it and everything worked perfectly.
I saw the solution on the first result google gave me on the list. The link to the solution is here: http://it.toolbox.com/wiki/index.php/Why_does_form_submit_method_throws_%22object_doesn't_support_this_property_or_method%22_error%3F
I was able to change the other objects name and everything was fine. On my case the object in conflict is the submit button, that usually by default named as 'submit'. I only change it and everything worked perfectly.
I saw the solution on the first result google gave me on the list. The link to the solution is here: http://it.toolbox.com/wiki/index.php/Why_does_form_submit_method_throws_%22object_doesn't_support_this_property_or_method%22_error%3F
Monday, September 3, 2012
Shrinking a transaction log file in MSSQL 2008
This is always a problem with MS SQL, the log file usually grows bigger than the data file itself. Sure, it is very important in recovery. But do you really need it, if you have full back-up? You will only need the log file to restore a deferential back-up.
Before in MS SQL 2000 and 2005, I use the following query (before MS SQL 2008):
BACKUP LOG DBname WITH TRUNCATE_ONLY
And that did the trick, but 'TRUNCATE_ONLY' is not recognized by MS SQL 2008 anymore.
You can use 'ALTER DATABASE' and setting the recovery to 'SIMPLE' then do the shrinking, otherwise by just using the 'DBCC SHRINKFILE(DBname_Log, 1)' query, there won't be any effect.
After you do the shrinking, return the recovery back to full, as such: 'SET RECOVERY FULL'.
This is only one of the solutions found on the web, there could be others involving running your own stored procedures. But I prefer a simple few line approach. Solution was found here: http://msdn.microsoft.com/en-us/library/ms189493.aspx
Here is the solution I used to shrink my log file on a MS SQL 2008.
ALTER DATABASE dbname
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (dbname_log, 1)
GO
ALTER DATABASE dbname
SET RECOVERY FULL;
GO
what happened here is a shrinking of a log file to a specific target size. This sample code was found in the solution link I provided above from a Microsoft website as Example B.
Others, suggest you backup the log file first before you shrink it. But a 300MB backup took me a long time, what if it is 5GB of log file?
Anyways, if you prefer to back it up first, you could add this code before you alter the database recovery:
BACKUP LOG dbname TO DISK = N'D:\dbname_log.bak'
GO
Before in MS SQL 2000 and 2005, I use the following query (before MS SQL 2008):
DBCC SHRINKFILE(DBname_Log, 1)
And that did the trick, but 'TRUNCATE_ONLY' is not recognized by MS SQL 2008 anymore.
You can use 'ALTER DATABASE' and setting the recovery to 'SIMPLE' then do the shrinking, otherwise by just using the 'DBCC SHRINKFILE(DBname_Log, 1)' query, there won't be any effect.
After you do the shrinking, return the recovery back to full, as such: 'SET RECOVERY FULL'.
This is only one of the solutions found on the web, there could be others involving running your own stored procedures. But I prefer a simple few line approach. Solution was found here: http://msdn.microsoft.com/en-us/library/ms189493.aspx
Here is the solution I used to shrink my log file on a MS SQL 2008.
ALTER DATABASE dbname
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (dbname_log, 1)
GO
ALTER DATABASE dbname
SET RECOVERY FULL;
GO
what happened here is a shrinking of a log file to a specific target size. This sample code was found in the solution link I provided above from a Microsoft website as Example B.
Others, suggest you backup the log file first before you shrink it. But a 300MB backup took me a long time, what if it is 5GB of log file?
Anyways, if you prefer to back it up first, you could add this code before you alter the database recovery:
BACKUP LOG dbname TO DISK = N'D:\dbname_log.bak'
GO
You may also, run this to view the database info:
EXEC sp_helpfile
It will show the logical name, fieldid, filename(path), filegroup, size, maxsize, growth, and usage.
Hope you found your solution here. Till next time.
Thursday, July 12, 2012
window.onload problem on external javascript with lower versions of IE
I was happily developing a new application, and have been very happy with the results. Then as I was in the middle of implementation, (good thing it was still early stages) I realized that IE browsers versions 5-7 acts abnormally on the window.onload from an external javascript. Although, my application works on all current browsers, this still shows as a dilemma to me because, the websites I am going to use my application on have visitors that will use mostly old versions of IE, based on Google Analytics data. The only way I can sleep at night knowing my application behaves as it should, is to find a solution for this problem or not implement my application at all.
I keep getting an error of "Invalid Pointer", which could be due to the fact that script somehow ran before all the objects and elements have completely loaded. After a exhausting search, I was able to find the solution in an easy to understand blog by Dean Edwards at his site: http://dean.edwards.name/weblog/2005/09/busted/ and http://dean.edwards.name/weblog/2006/06/again/ .
The solution on my specific problem was to have my external page loaded after all objects and elements are finish on the main page. One of the solution presented was to have defer on the <script> tag. According to him, this only works on external files, which pretty much the solution on my problem. Here is how it would look:
<script defer type="text/javascript" src="external.js"></script>
Ok, so I placed that on my website. Still an error occured, I have no choice, but to just have my functions in an external file, while I do the window.onload on the main page.
After placing the window.onload on the main page, this time the error is on the browser not recognizing the object. So part of the solution is for IE to detect, if everything is ready. Answer is still in Deans blog, but a lot different for my case since, I want to use an external file and detect if all is ready, before I run the function. My own solution is to have the following script, based on his example:
document.onreadystatechange = function() {
if (this.readyState == "complete") {
somefunction();
}};
I just replaced his script object with document object, for me to see that document has all been loaded. This only works on IE according to some websites, but when I placed it to run on other browser was detected, it still performs as it should.
So, the whole solution for me was to detect in PHP, the browser and version to run this work around:
<script defer type="text/javascript" src="external.js"></script>
<?php
if(isset($_SERVER['HTTP_USER_AGENT']) && ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') !== false) || (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) || (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false)))
{
?>
document.onreadystatechange = function() { if (this.readyState == "complete") {
somefunction();
}};
<?php
}
else
{
?>
I keep getting an error of "Invalid Pointer", which could be due to the fact that script somehow ran before all the objects and elements have completely loaded. After a exhausting search, I was able to find the solution in an easy to understand blog by Dean Edwards at his site: http://dean.edwards.name/weblog/2005/09/busted/ and http://dean.edwards.name/weblog/2006/06/again/ .
The solution on my specific problem was to have my external page loaded after all objects and elements are finish on the main page. One of the solution presented was to have defer on the <script> tag. According to him, this only works on external files, which pretty much the solution on my problem. Here is how it would look:
<script defer type="text/javascript" src="external.js"></script>
Ok, so I placed that on my website. Still an error occured, I have no choice, but to just have my functions in an external file, while I do the window.onload on the main page.
After placing the window.onload on the main page, this time the error is on the browser not recognizing the object. So part of the solution is for IE to detect, if everything is ready. Answer is still in Deans blog, but a lot different for my case since, I want to use an external file and detect if all is ready, before I run the function. My own solution is to have the following script, based on his example:
document.onreadystatechange = function() {
if (this.readyState == "complete") {
somefunction();
}};
I just replaced his script object with document object, for me to see that document has all been loaded. This only works on IE according to some websites, but when I placed it to run on other browser was detected, it still performs as it should.
So, the whole solution for me was to detect in PHP, the browser and version to run this work around:
<script defer type="text/javascript" src="external.js"></script>
<?php
if(isset($_SERVER['HTTP_USER_AGENT']) && ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') !== false) || (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) || (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false)))
{
?>
document.onreadystatechange = function() { if (this.readyState == "complete") {
somefunction();
}};
<?php
}
else
{
?>
<!-- Other Browsers Script -->
<?php
}
?>
The following is the source for the onreadystatechange: http://help.dottoro.com/ljerfwdm.php
Tuesday, July 3, 2012
Installing MS SQL 2008 Management Studio
I'm making this post, since I have seem to have solved my installation problem with MS SQL 2008 Management Studio installer. And I want to share, the proven way in solving it. Somehow, solved anyway. I don't know what exactly the problem with the installer, but when you try to install it, it gives the following message:
SQL Server Setup failure.
------------------------------
SQL Server Setup has encountered the following error:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created..
I looked for a solution thru google, and this is the most funny and unbelievable work around I found, but it works. Here is the link: http://stackoverflow.com/questions/1677435/invoke-or-begininvoke-cannot-be-called-on-a-control-until-the-window-handle-has
I don't know what happened, but after minimizing all windows and focusing only on the installation dialog, it somehow let me thru the installation process. I clicked back and forth the main installation window and the modal status window and somehow, I was able to successfully install my Management Studio 2008.
Reason that I installed the Management Studio 2008, was due to the fact that I cannot manage my data with editable results if I'm accessing MS SQL 2008, thru Management Studio 2005. It is stated in some forums, that you can use higher versions of Management Studio, but cannot use lower versions to fully use the latest MS SQL version. It does make sense to me, backwards compatibility only.
Here is the link to the MS SQL 2008 Management Studio Express installer: http://www.microsoft.com/en-us/download/details.aspx?id=7593
It states, express version, but I haven't notice any difference with the one included with the Enterprise edition installer. By the way, they both have bugs during installation, that is why I resorted in installing an express edition, even though I have an enterprise installer of MS SQL 2008.
You may have to install the SP 1 (service pack 1) of MS SQL 2008 after installation of Management Studio 2008. As indicated, during or initial install of Management Studio.
SQL Server Setup failure.
------------------------------
SQL Server Setup has encountered the following error:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created..
I looked for a solution thru google, and this is the most funny and unbelievable work around I found, but it works. Here is the link: http://stackoverflow.com/questions/1677435/invoke-or-begininvoke-cannot-be-called-on-a-control-until-the-window-handle-has
I don't know what happened, but after minimizing all windows and focusing only on the installation dialog, it somehow let me thru the installation process. I clicked back and forth the main installation window and the modal status window and somehow, I was able to successfully install my Management Studio 2008.
Reason that I installed the Management Studio 2008, was due to the fact that I cannot manage my data with editable results if I'm accessing MS SQL 2008, thru Management Studio 2005. It is stated in some forums, that you can use higher versions of Management Studio, but cannot use lower versions to fully use the latest MS SQL version. It does make sense to me, backwards compatibility only.
Here is the link to the MS SQL 2008 Management Studio Express installer: http://www.microsoft.com/en-us/download/details.aspx?id=7593
It states, express version, but I haven't notice any difference with the one included with the Enterprise edition installer. By the way, they both have bugs during installation, that is why I resorted in installing an express edition, even though I have an enterprise installer of MS SQL 2008.
You may have to install the SP 1 (service pack 1) of MS SQL 2008 after installation of Management Studio 2008. As indicated, during or initial install of Management Studio.
Saturday, June 30, 2012
How to make Bootable USB Windows 7 installer
OK, currently, my old laptop is broken. It has a broken hard disk, broken DVD-drive, and the battery does not charge as it used to do. So, good thing, I was able to buy a new laptop after an agonizing week without a computer at home. But now, after a few months, I need my old laptop to work again. In order for me to test some stuff, without getting my new laptop destroyed or disrupting my current set-up.
I just bought a hard disk replacement, I was thinking the dvd-drive may still be in working condition. It was kinda working before, and kinda read DVD-discs. I was ready to re-install my windows 7, but as expected the drive was really not usable. It won't boot my installation disc for windows 7.
So, I search for a way to boot, other from a DVD-drive. I was familiar of USB booting, but my previous attempts were just a sorry excuse for an IT person such as myself. I may have not found a good site for my problem. But now, with the use of my new laptop. I was able to search this very nice solution, using your own windows 7 and windows 7 installation disk. The solution can be found on this website: http://www.intowindows.com/bootable-usb/
I saw someone suggest in a forum to just copy the windows 7 installation disk on a USB. But it was not that simple, in fact, I tried twice before I followed the instructions from the website given above. I tried, the short-cut or reversed the procedure. It didn't work, because the computer does not recognize the USB as bootable. You have to follow, it step by step and just change the drive letter and number related to your own drive.
Ok, in case, the site link I gave is off-line. Here are the steps given:
I just bought a hard disk replacement, I was thinking the dvd-drive may still be in working condition. It was kinda working before, and kinda read DVD-discs. I was ready to re-install my windows 7, but as expected the drive was really not usable. It won't boot my installation disc for windows 7.
So, I search for a way to boot, other from a DVD-drive. I was familiar of USB booting, but my previous attempts were just a sorry excuse for an IT person such as myself. I may have not found a good site for my problem. But now, with the use of my new laptop. I was able to search this very nice solution, using your own windows 7 and windows 7 installation disk. The solution can be found on this website: http://www.intowindows.com/bootable-usb/
I saw someone suggest in a forum to just copy the windows 7 installation disk on a USB. But it was not that simple, in fact, I tried twice before I followed the instructions from the website given above. I tried, the short-cut or reversed the procedure. It didn't work, because the computer does not recognize the USB as bootable. You have to follow, it step by step and just change the drive letter and number related to your own drive.
Ok, in case, the site link I gave is off-line. Here are the steps given:
1. Insert your USB flash drive, make sure it has enough space to fit all files from the windows 7 installation disc. I used a 8 GB drive, just to be sure.
2. Navigate to Start > All programs >Accessories > right click on Command Prompt and select run as administrator. I tried running it directly from search box as cmd, but it could not have been set as administrator.
3. When the Command Prompt opens, enter the following command:
DISKPART and hit enter.
LIST DISK and hit enter.
Once you enter the LIST DISK command, it will show the disk number of your USB drive. If you have a single drive with single partition, your USB drive disk no is Disk 1. But you have to check the size on the list, just to be sure you are not formatting another drive other than the USB you have.
4. In this step you need to enter all the below commands one by one and hit enter. As these commands are self explanatory, you can easily guess what these commands do.
SELECT DISK 1 (Replace DISK 1 with your disk number, if it isn't DISK 1)
CLEAN
CREATE PARTITION PRIMARY
SELECT PARTITION 1
ACTIVE
FORMAT FS=NTFS
(Format process may take few minutes)
ASSIGN
EXIT
If previously your USB is assigned as drive "F", after assign, it's probably drive "G" now. Also, there was a time an error saying it cannot make changes, but it did, I think it was between CLEAN and CREATE PARTITION PRIMARY. I just continued with the steps even with the error, and I was able to make a bootable disc.
Don’t close the command prompt as we need to execute one more command at the next step. Just minimize it.
5. Insert your Windows DVD in the optical drive and note down the drive letter of the optical drive and USB media. I use “D” as my optical (DVD) drive letter and “G” as my USB drive letter.
6. Go back to command prompt and execute the following commands:
D:CD BOOT and hit enter. Where “D” is your DVD drive letter.
CD BOOT and hit enter to see the below message.
BOOTSECT.EXE /NT60 G:
7. Copy Windows DVD contents to USB.
You are done with your bootable USB. You can now use this bootable USB as bootable DVD on any computer that comes with USB boot feature (most of the current motherboards support this feature).
Note that this bootable USB guide will not work if you are trying to make a bootable USB on XP computer.
Side Note: I just copied the instruction contents, and added some of my thoughts and my experience when I made my own USB bootable disc. This is, just in case the original source of the solution is down, or taken off-line.
Thursday, June 7, 2012
HTML list item adjusting margin space
During one of our developments to use list element to display items, we encountered a list that has a problem on spacing between items.
I looked for an answer thru google and here is the best that I can come up with based on the problem:
li {
margin-top: -1em;
}
They were actually asking for a solution to increase their space between list items. Which was the opposite of what I wanted, which was to decrease the space between items.
This answer was obvious after searching for about 5 mins.
Here are the sites I drawn my solutions from:
http://bytes.com/topic/html-css/answers/98755-how-increase-vertical-spacing-between-ul-ol-items
http://stackoverflow.com/questions/347404/ie-adds-extra-top-margin-to-every-li-element
I looked for an answer thru google and here is the best that I can come up with based on the problem:
li {
margin-top: -1em;
}
They were actually asking for a solution to increase their space between list items. Which was the opposite of what I wanted, which was to decrease the space between items.
This answer was obvious after searching for about 5 mins.
Here are the sites I drawn my solutions from:
http://bytes.com/topic/html-css/answers/98755-how-increase-vertical-spacing-between-ul-ol-items
http://stackoverflow.com/questions/347404/ie-adds-extra-top-margin-to-every-li-element
Tuesday, June 5, 2012
Quirks mode in IE browser
It has been a problem for developers to have all browsers display their content as they intended it to be. But, often, challenges are the different browser rendering, and different versions of the browsers doing something else.
The Quirks mode was made for the browser to render a specific page that it thinks isn't created for current html standard. Often, this is to accommodate the old webpages that have not been updated to current new standard of the W3C specifications.
If you have been trying to create a webpage and the browser often resort to rendering it in Quirks Mode, it is better if you specify the doc type. It isn't the best solution, but it will tell the browser to present the document or webpage the way you want it to be.
Use the following code on the very top of your page to have it render correctly as you intended it to be:
The sources, I used to have the solution are on the following websites:
http://hsivonen.iki.fi/doctype/
The Quirks mode was made for the browser to render a specific page that it thinks isn't created for current html standard. Often, this is to accommodate the old webpages that have not been updated to current new standard of the W3C specifications.
If you have been trying to create a webpage and the browser often resort to rendering it in Quirks Mode, it is better if you specify the doc type. It isn't the best solution, but it will tell the browser to present the document or webpage the way you want it to be.
Use the following code on the very top of your page to have it render correctly as you intended it to be:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">The sources, I used to have the solution are on the following websites:
http://hsivonen.iki.fi/doctype/
http://www.quirksmode.org/css/quirksmode.html
Friday, June 1, 2012
How to Delete a Windows Service
Has it happened to you? You were trying to install a software, and there was an option for it to retry once it fails, but it instead failed again once you click retry. And worst, it created a duplicate service with a suffix _1, making it difficult even if you uninstall it.
Even if you probably uninstall it, the other service will remain. A way to remove a service is by using windows registry. It's relatively easy, if you know what is a service, you probably know what a windows registry is.
To remove the service on a server do the following:
1. Run Regedit
2. Find the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"
3. Find the service you want to delete, it has the same name as shown in the services list. Just right click and select delete on the service you want to remove.
Until next time.
Solution was found in this site: http://www.performiq.com.au/kb/index.php/Delete_a_Windows_Service
Even if you probably uninstall it, the other service will remain. A way to remove a service is by using windows registry. It's relatively easy, if you know what is a service, you probably know what a windows registry is.
To remove the service on a server do the following:
1. Run Regedit
2. Find the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"
3. Find the service you want to delete, it has the same name as shown in the services list. Just right click and select delete on the service you want to remove.
Until next time.
Solution was found in this site: http://www.performiq.com.au/kb/index.php/Delete_a_Windows_Service
Tuesday, April 3, 2012
MS SQL 2005: Configure a User to Create and Manage SQL Server Agent Jobs
I was looking for a way to assign a role for a user to create and execute jobs that account created, and I found a way thru the MSDN library online. Link can be found here, which the article shows how to add a role for a user that can manage the ms sql agent only.
Here is a copy of the article, in case the site goes down or the link has been changed:
This topic describes how to configure a user to create or execute Microsoft SQL Server Agent jobs.
--------------------------------------------------------------------------------------------------------
Before You Begin:
Security
To configure a user to create or execute Microsoft SQL Server Agent jobs, you must first add an existing SQL Server login or msdb role to one of the following SQL Server Agent fixed database roles in the msdb database: SQLAgentUserRole, SQLAgentReaderRole, or SQLAgentOperatorRole.
By default, members of these database roles can create their own job steps that run as themselves. If these non-administrative users want to run jobs that execute other job step types (for example, SSIS packages), they will need to have access to a proxy account. All members of the sysadmin fixed server role have permission to create, modify, and delete proxy accounts. For more information about the permissions that are associated with these SQL Server Agent fixed database roles, see SQL Server Agent Fixed Database Roles.
Permissions
By default, members of these database roles can create their own job steps that run as themselves. If these non-administrative users want to run jobs that execute other job step types (for example, SSIS packages), they will need to have access to a proxy account. All members of the sysadmin fixed server role have permission to create, modify, and delete proxy accounts. For more information about the permissions that are associated with these SQL Server Agent fixed database roles, see SQL Server Agent Fixed Database Roles.
Permissions
For detailed information, see Implement SQL Server Agent Security.
-------------------------------------------------------------------------------------------------------
*Now to the fun part, the actual act of configuring the user rights:
Using SQL Server Management Studio:
*I only reached until step 5, and never bothered with configuring a proxy account.
After the initial installation of SQL Server, only the System Administrator (sysadmin) role has access to view, modify, create, and execute SQL Server Agent jobs. The Agent node in SQL Object Explorer is available only to users who are assigned the System Administrator role. To grant a user access to SQL Server Agent, you must add the user to one of the two new database roles in the msdb database.
By default, in the new release of SQL Server Agent, only sysadmins can create job steps of the following types:
To grant users other than sysadmins the right to create a job step for types other than Transact-SQL, a sysadmin must create at least one proxy account for the user. This proxy account is simply a credential with a friendly name.
Credentials must be created before Agent proxy accounts can be created. To create a credential, use the following script:
To add a proxy account, use the following script:
-------------------------------------------------------------------------------------------------------
*Now to the fun part, the actual act of configuring the user rights:
Using SQL Server Management Studio:
To add a SQL login or msdb role to a SQL Server Agent fixed database role
- In Object Explorer, expand a server.
- Expand Security, and then expand Logins.
- Right-click the login you wish to add to a SQL Server Agent fixed database role, and select Properties.
- On the User Mapping page of the Login Properties dialog box, select the row containing msdb.
- Under Database role membership for: msdb, check the appropriate SQL Server Agent fixed database role.
*I only reached until step 5, and never bothered with configuring a proxy account.
To configure a proxy account to create and manage SQL Server Agent job steps
- In Object Explorer, expand a server.
- Expand SQL Server Agent.
- Right-click Proxies and select New Proxy.
- On the General page of the New Proxy Account dialog, specify the proxy name, credential name, and description for the new proxy. Note that you must create a credential first before creating a SQL Server Agent proxy. For more information about creating a credential, see Create a Credential and CREATE CREDENTIAL (Transact-SQL).
- Check the appropriate subsystems for this proxy.
- On the Principals page, add or remove logins or roles to grant or remove access to the proxy account.
After the initial installation of SQL Server, only the System Administrator (sysadmin) role has access to view, modify, create, and execute SQL Server Agent jobs. The Agent node in SQL Object Explorer is available only to users who are assigned the System Administrator role. To grant a user access to SQL Server Agent, you must add the user to one of the two new database roles in the msdb database.
New Roles in the msdb Database
SQL Server Agent in SQL Server 2005 adds three new roles to the msdb database:- SQLAgentUserRole Users added to the SQLAgentUserRole role will have the same SQL Server Agent experience as they had in SQL Server 2000. These users can create jobs and manage only jobs that they created.
- SQLAgentReaderRole Users added to the SQLAgentReaderRole role will have the same privledges as those in the SQLAgentUserRole with the addition of the ability to enumerate and view the history of all jobs..
- SQLAgentOperatorRole Users added to the SQLAgentOperator role will have the same privledges as those in the SQLAgentReaderRole with the addition of the ability to execute local jobs that they do not own.
Multiple Proxy Accounts
In SQL Server 2000, when a user wanted to execute a SQL Server Integration Services (SSIS) package as a job step, the sysadmin had to enable the SQL Server Agent proxy account. After the account was enabled, any SQL Server Agent user could create job steps for certain subsystems, such as CmdExec, and run them by using this account. In SQL Server 2005, SQL Server Agent addresses this security concern by using multiple proxy accounts.By default, in the new release of SQL Server Agent, only sysadmins can create job steps of the following types:
- Active Scripting
- SQL Server Integration Services Package
- Analysis Command
- Analysis Query
- All replication subsystems
To grant users other than sysadmins the right to create a job step for types other than Transact-SQL, a sysadmin must create at least one proxy account for the user. This proxy account is simply a credential with a friendly name.
Credentials must be created before Agent proxy accounts can be created. To create a credential, use the following script:
CREATE CREDENTIAL [MyCredential] WITH IDENTITY = '<domain>\<user>', secret = '<password>'Note: Although the example stated in this paper use T-SQL to create credentials and proxy accounts, SQL Server Management Studio provides a series of dialogs to aid in the creation of these objects.
To add a proxy account, use the following script:
Sp_add_proxy @proxy_name='My Proxy', @credential_name='MyCredential'
Thursday, March 8, 2012
Passing values or reference example in PHP
Note: The code and principles are not mine, I only reposted them from php.net website.
I like this example, very easy to follow on passing reference and value:
<?php
//The two are meant to be the same
$a = "Clark Kent"; //a==Clark Kent
$b = &$a; //The two will now share the same fate.
$b="Superman"; // $a=="Superman" too.
echo $a;
echo $a="Clark Kent"; // $b=="Clark Kent" too.
unset($b); // $b divorced from $a$b="Bizarro";
echo $a; // $a=="Clark Kent" still, since $b is a free agent pointer now.
//The two are NOT meant to be the same.
$c="King";
$d="Pretender to the Throne";
echo $c."\n"; // $c=="King"
echo $d."\n"; // $d=="Pretender to the Throne"
swapByValue($c, $d);
echo $c."\n"; // $c=="King"
echo $d."\n"; // $d=="Pretender to the Throne"
swapByRef($c, $d);
echo $c."\n"; // $c=="Pretender to the Throne"
echo $d."\n"; // $d=="King"
function swapByValue($x, $y){
$temp=$x;
$x=$y;
$y=$temp;
//All this beautiful work will disappear
//because it was done on COPIES of pointers.
//The originals pointers still point as they did.
}
function swapByRef(&$x, &$y){
$temp=$x;
$x=$y;
$y=$temp;
//Note the parameter list: now we switched 'em REAL good.
}
?>
First principle:
A pointer stores a memory address to access an object. Any time an object is assigned, a pointer is generated. (I haven't delved TOO deeply into the Zend engine yet, but as far as I can see, this applies)
2nd principle, and source of the most confusion:
Passing a variable to a function is done by default as a value pass, ie, you are working with a copy. "But objects are passed by reference!" A common misconception both here and in the Java world. I never said a copy OF WHAT. The default passing is done by value. Always. WHAT is being copied and passed, however, is the pointer. When using the "->", you will of course be accessing the same internals as the original variable in the caller function. Just using "=" will only play with copies.
3rd principle:
"&" automatically and permanently sets another variable name/pointer to the same memory address as something else until you decouple them. It is correct to use the term "alias" here. Think of it as joining two pointers at the hip until forcibly separated with "unset()". This functionality exists both in the same scope and when an argument is passed to a function. Often the passed argument is called a "reference," due to certain distinctions between "passing by value" and "passing by reference" that were clearer in C and C++.
Just remember: pointers to objects, not objects themselves, are passed to functions. These pointers are COPIES of the original unless you use "&" in your parameter list to actually pass the originals. Only when you dig into the internals of an object will the originals change.
Original document or forum can be found here somewhere:
http://php.net/manual/en/language.oop5.references.php
I like this example, very easy to follow on passing reference and value:
<?php
//The two are meant to be the same
$a = "Clark Kent"; //a==Clark Kent
$b = &$a; //The two will now share the same fate.
$b="Superman"; // $a=="Superman" too.
echo $a;
echo $a="Clark Kent"; // $b=="Clark Kent" too.
unset($b); // $b divorced from $a$b="Bizarro";
echo $a; // $a=="Clark Kent" still, since $b is a free agent pointer now.
//The two are NOT meant to be the same.
$c="King";
$d="Pretender to the Throne";
echo $c."\n"; // $c=="King"
echo $d."\n"; // $d=="Pretender to the Throne"
swapByValue($c, $d);
echo $c."\n"; // $c=="King"
echo $d."\n"; // $d=="Pretender to the Throne"
swapByRef($c, $d);
echo $c."\n"; // $c=="Pretender to the Throne"
echo $d."\n"; // $d=="King"
function swapByValue($x, $y){
$temp=$x;
$x=$y;
$y=$temp;
//All this beautiful work will disappear
//because it was done on COPIES of pointers.
//The originals pointers still point as they did.
}
function swapByRef(&$x, &$y){
$temp=$x;
$x=$y;
$y=$temp;
//Note the parameter list: now we switched 'em REAL good.
}
?>
First principle:
A pointer stores a memory address to access an object. Any time an object is assigned, a pointer is generated. (I haven't delved TOO deeply into the Zend engine yet, but as far as I can see, this applies)
2nd principle, and source of the most confusion:
Passing a variable to a function is done by default as a value pass, ie, you are working with a copy. "But objects are passed by reference!" A common misconception both here and in the Java world. I never said a copy OF WHAT. The default passing is done by value. Always. WHAT is being copied and passed, however, is the pointer. When using the "->", you will of course be accessing the same internals as the original variable in the caller function. Just using "=" will only play with copies.
3rd principle:
"&" automatically and permanently sets another variable name/pointer to the same memory address as something else until you decouple them. It is correct to use the term "alias" here. Think of it as joining two pointers at the hip until forcibly separated with "unset()". This functionality exists both in the same scope and when an argument is passed to a function. Often the passed argument is called a "reference," due to certain distinctions between "passing by value" and "passing by reference" that were clearer in C and C++.
Just remember: pointers to objects, not objects themselves, are passed to functions. These pointers are COPIES of the original unless you use "&" in your parameter list to actually pass the originals. Only when you dig into the internals of an object will the originals change.
Original document or forum can be found here somewhere:
http://php.net/manual/en/language.oop5.references.php
Monday, February 20, 2012
Laptop screen replacement cost in the Philippines
On my last blog, I wrote about my desktop pc which I revived from neglect will be used when something happens to my laptop. It happened, my laptop was broken in the sense that my screen cracked. Never happend before on my former laptop, which I bought locally.
Having a broken laptop is a predicament indeed, since I was expecting to replace my laptop in 5 years time. And my current laptop is just almost 2 years old. This is just an unexpected expense. I was thinking of holding out a bit, for a few months, until I can replace the screen. But I can't hold out any longer on having its screen replaced. I need to have my screen replaced right away, since I always use my laptop, instead of desktop.
My laptop is a Dell model 1545, and it has a 15.6 inch screen. I found out the hard way, that a replacement laptop screen costs a lot. From now on, I won't drop the darn thing.
I was researching on the internet on how much will a replacement cost, the usual 14 inch screen cost on average on the following range:
It took me 2 days, before I gave in to the need of having my broken laptop screen replaced with a working one(either a brand new or a 2nd hand screen). I was in a hurry to have my laptop fixed, since I can't rely on my desktop, it is already old also.
I had to pay the repair shop P6,500 for a brandnew LED 15.6 inch screen. The price could have gone lower, I guess, but I am the type of person who don't try much on price haggling. At that price, there is only a 3 months warranty, since they say it is brand new. I just hope this screen last more than 3 months and will last more that 3 years, since my target for a laptop replace/upgrade is 3 more years.
I agreed to have my laptop fixed by a non-Dell accredited repair shop, since a Dell repair shop cost P9,000 (about $205) for a laptop screen replacement. Since, this was an unexpected expense, I have to go towards the lowest price. So far my laptop screen replacment is working, although, I'm not used to the new screen, there's just something different about the color it produces.
Until, next time.
Having a broken laptop is a predicament indeed, since I was expecting to replace my laptop in 5 years time. And my current laptop is just almost 2 years old. This is just an unexpected expense. I was thinking of holding out a bit, for a few months, until I can replace the screen. But I can't hold out any longer on having its screen replaced. I need to have my screen replaced right away, since I always use my laptop, instead of desktop.
My laptop is a Dell model 1545, and it has a 15.6 inch screen. I found out the hard way, that a replacement laptop screen costs a lot. From now on, I won't drop the darn thing.
I was researching on the internet on how much will a replacement cost, the usual 14 inch screen cost on average on the following range:
- P3,500 (about $80) for a second hand
- P5,000 (about $115) for a brandnew
- P7,000 (about $160) for a brand new
- P5,000 for a second hand
It took me 2 days, before I gave in to the need of having my broken laptop screen replaced with a working one(either a brand new or a 2nd hand screen). I was in a hurry to have my laptop fixed, since I can't rely on my desktop, it is already old also.
I had to pay the repair shop P6,500 for a brandnew LED 15.6 inch screen. The price could have gone lower, I guess, but I am the type of person who don't try much on price haggling. At that price, there is only a 3 months warranty, since they say it is brand new. I just hope this screen last more than 3 months and will last more that 3 years, since my target for a laptop replace/upgrade is 3 more years.
I agreed to have my laptop fixed by a non-Dell accredited repair shop, since a Dell repair shop cost P9,000 (about $205) for a laptop screen replacement. Since, this was an unexpected expense, I have to go towards the lowest price. So far my laptop screen replacment is working, although, I'm not used to the new screen, there's just something different about the color it produces.
Until, next time.
Monday, January 23, 2012
Bios password protected Desktop
Happy Chinese New Year, Everyone. It's 2012 and it's the year of the Water Dragon, they say.
Today, I was trying to revive my old desktop. I haven't been using it for quite a while, almost a year, it has been neglected and unused. I know you would say, what has it have to do with development. Well, for one, I could use it as a test PC. Two, it's my back-up PC in case, my laptop has a mishap.
Ok. I think, I placed the password myself as protection before, but have completely forgotten the password itself. I was in a dilema on how to remove it, on Chinese New Year. I have been searching around, and in my particular case, the way was to clear the password by using the board jumper and selecting clear password on the bios itself. Remember to save the settings, password will not prompt anymore when you boot your PC.
Here is the solution I got from a forum:
------------------------------------------------------------------------------------------------------------------
Locate this jumper as show in the bellow image !!!
there are 3 pins, like * * * the pin would cover 1 and 2 pin which is the default config... - - * so take the pin out and put it as 2 and 3 cover like, * - - start the system the BIOS should revart back to the default shipping factory settings... !!! now power of the system and restore the jumper to default 1 and 2 cover settings start the system once again to do you work
-------------------------------------------------------------------------------------------------------------------
Solution pictures and words between the lines are in no way mine. I just want to show the solution, without you scrolling or looking around the forums.
The solution and the full forum descussion can be found in this link:
http://www.thinkdigit.com/forum/cpu-motherboards/79611-bios-password-intel-motherboard-d945gccr.html
Well, that solved my password problem, but not my unreadable master file table. Currently, my solution to the problem is to have retrievable data backed-up and reformat the OS partition.
This is due to the fact that my hard disk is more than 5 years old. One of them is already gone. The hard disk that is acting up, had an issue a few months from the time I bought it. I'm never buying from "PC Options" computer store again. A hard disk, a year older than the one gone is still working.
Today, I was trying to revive my old desktop. I haven't been using it for quite a while, almost a year, it has been neglected and unused. I know you would say, what has it have to do with development. Well, for one, I could use it as a test PC. Two, it's my back-up PC in case, my laptop has a mishap.
Ok. I think, I placed the password myself as protection before, but have completely forgotten the password itself. I was in a dilema on how to remove it, on Chinese New Year. I have been searching around, and in my particular case, the way was to clear the password by using the board jumper and selecting clear password on the bios itself. Remember to save the settings, password will not prompt anymore when you boot your PC.
Here is the solution I got from a forum:
------------------------------------------------------------------------------------------------------------------
Locate this jumper as show in the bellow image !!!
there are 3 pins, like * * * the pin would cover 1 and 2 pin which is the default config... - - * so take the pin out and put it as 2 and 3 cover like, * - - start the system the BIOS should revart back to the default shipping factory settings... !!! now power of the system and restore the jumper to default 1 and 2 cover settings start the system once again to do you work
-------------------------------------------------------------------------------------------------------------------
Solution pictures and words between the lines are in no way mine. I just want to show the solution, without you scrolling or looking around the forums.
The solution and the full forum descussion can be found in this link:
http://www.thinkdigit.com/forum/cpu-motherboards/79611-bios-password-intel-motherboard-d945gccr.html
Well, that solved my password problem, but not my unreadable master file table. Currently, my solution to the problem is to have retrievable data backed-up and reformat the OS partition.
This is due to the fact that my hard disk is more than 5 years old. One of them is already gone. The hard disk that is acting up, had an issue a few months from the time I bought it. I'm never buying from "PC Options" computer store again. A hard disk, a year older than the one gone is still working.
Subscribe to:
Posts (Atom)