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

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:


<!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

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
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:


To add a SQL login or msdb role to a SQL Server Agent fixed database role
  1. In Object Explorer, expand a server.
  2. Expand Security, and then expand Logins.
  3. Right-click the login you wish to add to a SQL Server Agent fixed database role, and select Properties.
  4. On the User Mapping page of the Login Properties dialog box, select the row containing msdb.
  5. 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
  1. In Object Explorer, expand a server.
  2. Expand SQL Server Agent.
  3. Right-click Proxies and select New Proxy.
  4. 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).
  5. Check the appropriate subsystems for this proxy.
  6. On the Principals page, add or remove logins or roles to grant or remove access to the proxy account.
Other things concerning Agent Roles can be found on this link: http://msdn.microsoft.com/en-us/library/cc966397.aspx


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
Transact-SQL subsystems will execute under the owner just as they did in SQL Server 2000.
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

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:
  • P3,500 (about $80) for a second hand 
  • P5,000 (about $115) for a brandnew
My unit uses a 15 inch and on average cost the following:
  • P7,000 (about $160) for a brand new 
  • P5,000 for a second hand 
Although some repair shops advertise online they cost P3,500 for a 15.6 inch second hand, but when you contact them, they have no current stock on 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.