Archive for the “Programming” Category

.NET (C#), PHP

I’ve just had a situation: I’ve defined a new Linux virtual machine with 512MB swap space and Oracle requirement was 1GB.

What do you need to do in order to increase the swap:
- shut down the virtual machine
- Add a new hard disk (either IDE or SCSI)
- start the virtual machine and wait to that hard disk to be discovered
- run:

#fdisk /dev/sdX
or
#fdisk /dev/hdX

where X is a-z, ussualy b. You will use hdX if your drive is IDE and sdX if your drive is SCSI
- click p to see the existing partitions
- if this is your new virtual hard drive, click n to create a new patition
- click t to change the partition type to “Linux Swap” (it is 82)
- click w to write changes
- run:

#mkswap /dev/sdX1
or
#mkswap /dev/hdX1

- change the swap location with the following command:

swapon /dev/sdX1
or
swapon /dev/hdX1

good luck

Comments 1 Comment »

If you install VS2005 and then ODP.Net you will probably get a strange error when you will try to use Oracle Explorer for the first time:

Package ‘Oracle Developer Tools for Visual Studio .NET’ has failed
to load properly ( GUID = {D601BB95-E404-4A8E-9F24-5C1A462426CE} ).
Please contact package vendor for assistance. Application restart is
recommended, due to possible environment corruption. Would you like to
disable loading this package in the future? You may use
‘devenv /resetskippkgs’ to re-enable package loading.
 

The problem is an assembly mismatch. As Christian Shay (principal product manager for ODP.net at Oracle) said in an announcement, there are 2 options to solve this issue:

1. My recommended solution:

Execute the following command from a command prompt:

gacutil /i <Oracle Home>\odp.net\bin\2.x\Oracle.DataAccess.dll

where is the Oracle Home directory where you installed ODT 2005. For example, on my machine is c:\oracle\product\10.2.0\client_1.

2. Reinstall:

Deinstall ODP.NET 1.x from your machine (if you’re not using it) and install ODP.NET 2.0 in the same Oracle Home.

Andrei
http://www.webxpert.ro

Comments No Comments »

Every webmaster knows about MediaTemple. It seems to be one of the most recognized hosting companies, especially with their site design, which I think is the most cloned layout in the world.

When Mihai and I were looking for a hosting provider, both of us agreed that we need the best hosting and we chose a MT dedicated server. All was ok until the last week.

Mihai requested a new password for root, and then his computer broke. After he fixes his computer, our server was down.
The reason? The bright-heads from MT set up the “root” password for “root” account, and they suggested changing the password as soon as possible. But Mihai was able to read the email only after 4 days… and it was to late… we were hacked.

We all agreed that it was a conjuncture issue, but the following question harasses me: why they set a very very weak password for root account and let us to secure it? The most professional way was to set a very strong password (30 characters or so, it is the root account, for God sake!) and let us to change it to a simple one….

Later edit:
We have received an email from MediaTemple regarding this post:
Hello *****,

We saw your blog post and wanted to touch on this issue.
1. We agree with you. Setting a root password to “root” is absolutely not acceptable and action has been taken to keep this from ever happening again.
2. In our defense, after reviewing your request to change the root password, it does seem that you wanted it changed to the password to “root”. You’d be surprised how common this request is.
We apologize for the inconvenience! Thanks for the continued support and business.

Best,
Jason McVearry


Andrei
http://www.webxpert.ro

Comments No Comments »

I noticed a high degree of interest in my previous article about rounded-border textbox, so I decided that I must continue that post. Based on the comments that I received, I want to illustrate here another approach.

A better way than create the background for all the form is to set up the background just for input objects. In this demo we will create the background just for textbox. The image that we are using is the following:
Screenshot

All we need to do is to tell the textbox to use this image, through a CSS class, so first of all we have created a class called my_textbox:

.my_textbox {
 background-image: url(tbBg.jpg); /*Here we load the background image */
 background-repeat: no-repeat;
 background-attachment: fixed;
 height: 27px; /*we specify the the object dimensions like the image dimensions*/
 width: 174px;
 margin: 0px;
 padding: 5px 10px 0px 10px; /*without padding, the text will start from upper-left corner*/
 border: 0px none; /*we do not need any border*/
}

Then we must create a textbox input and set the class attribute to “my_textbox”:

<input name="user" class="my_textbox" type="textbox" maxlength="20">

The final result should look like this:
Screenshot
*We left the cells background white to see where the background comes.
Good luck!

Andrei
http://www.webxpert.ro

Read also

  • Rounded-border textbox
  • Tags:

    Comments 3 Comments »

    Ever wondered how to find the background color for a specifil excel cell? Why? Because you need to filter the sheet by color, and the only way that excel can filter is by value. So, instead of color, you need to save the color name in a separate column.

    Excel doesn’t offer a function for this, so you must use VBA.
    To start the VBA editor, press Alt+F11, then create this function:

    Function GetBgColor(rCell As Range)
       
        ‘declare color variable
        Dim strColor As String

        ‘switch cell background color
        Select Case rCell.Interior.ColorIndex
           Case 1
            strColor = "Black"
           Case 6
            strColor = "Yellow"
           Case 2
            strColor = "White"
           Case Else
            ‘the color has no Index
            strColor = "No fill"
        End Select
       
        ‘return color name
        GetBgColor= strColor
       
    End Function

    Save this function by pressing Alt+Q, and return to your worksheet. Now, in a separate column, start a new formula as

    =GetBgColor(A2)

    where A2 is the cell that you want to query.

    Here’s a screenshot:
    Screenshot

    You can improve this function in order to test multiple colors, but this is the template.

    Andrei
    http://www.webxpert.ro

    Comments No Comments »

    HTML emails….. hmm, not such a good idea.
    I am not such a big fan of HTML emails, because I am assaulted by tens of such emails daily, most of them spam ones. And using Microsoft Outlook as email client, it ask me to download (or not) pictures from the server. This could be a bad idea sometimes, because harmful code could be be hidden in image files today (especially GIF files).

    I was hired to make a newsletter module for one website and first I started to search how to make this.
    The steps are below.

    1. Create the HTML page for newsletter.
    2. Take care to have the CSS and JS embedded in the HTML file and not outside the file.
    3. Replace the relative location of image files with absolute location. E.g:
    if you have:
    [code lang="xml"]
    Coming Soon name="com_soon" width="100" height="35" border="0" id="com_soon" />
    [/code]
    you must replace with:
    [code lang="xml"]
    alt="Coming Soon" name="com_soon" width="100" height="35"
    border="0" id="com_soon" />
    [/code]
    Read the rest of this entry »

    Comments No Comments »

    Honestly, when Mihai told me that we have to do a website for selling movie costumes replicas, I told him that it will be a waste of time and money.

    I WAS WRONG !

    MPM Costumes (http://www.mpmcostumes.com) seems to be a real success story:

    • 5700 unique visitors per month
    • costumes and accessories of almost £ 10000 sold in the first 2 months
    • number 10 in google search on “jedi costumes” and still raising.

    Why this version is so successful ?:

    • first of all costumes are very qualitative and Martin (the owner) knows his business very well
    • neither me or Mihai refused any programming or design challenge, so there are many innovations there
    • it has payment callbacks in order to be informed when a secure payment (through PayPal or WorldPay) is made
    • very aesthetic gallery
    • the possibility to choose the measures depending on the product (for some products just color, for the others Neck Measurement or Wrist to Top of Shoulder) and save this options within the shopping cart.
    • very poweful control panel where any authorized user (even a non-technical one) can easily change/add/delete items.
    • *NEW: friendly URLs made with Apache’s rewrite directive.
    • Stopping here? No way! We wants to be number one in google search and wear everybody in his favorite movie costume and made many people happy.
      To understand what we have meaned, please visit the client gallery to see how many customers (I used to call them “freaks”, but now they are “customers”) agreed to share their photos in MPM costumes. P.S.: Andreea is the best!

      Andrei
      http://www.webxpert.ro

    Comments 5 Comments »

    Microsoft has just released (on February 28th) a new update to Internet Explorer 6 for Microsoft Windows XP Service Pack 2 (SP2) and for Microsoft Windows Server 2003 Service Pack 1 (SP1).

    This update changes the way in which Internet Explorer handles some Web pages that use ActiveX controls. Examples of programs that use ActiveX controls include the following:

    • Adobe Reader
    • Apple QuickTime Player
    • Macromedia Flash
    • Microsoft Windows Media Player
    • Real Networks RealPlayer
    • Sun Java Virtual Machine

    After you install this update, you cannot interact with ActiveX controls from certain Web pages until these controls are enabled. To enable an ActiveX control, manually click the control. There are also techniques that Web developers can use to update their Web pages.

    Microsoft recently lost a legal battle with a patent holder about the way Internet Explorer displays OBJECTs and EMBEDs in webpages. Microsoft then decided to update its Internet Explorer browser with changes requiring user input to display and activate ActiveX based media.

    It means users have to click the object first in order to activate its functions.

    The behavior is the following:
    Activate ActiveX

    It is a real shot for Macromedia (Adobe), because Flash is the most frequently used technology from the entire above list. Think a little bit: if a website is entirely made in Flash, then all the content is disabled until the first click; if a website has its navigation made in Flash, for click-ing the menu you must first activate the navigation.

    Fortunately, the community found some solutions to this problem. Even Macromedia (Adobe) has provided an official solution:
    http://www.macromedia.com/devnet/activecontent/articles/devletter.html

    Other several resources related to this new “feature” are:
    http://support.microsoft.com/kb/912945
    http://www.amarasoftware.com/flash-problem.htm
    http://blogs.technet.com/msrc/archive/2006/03/29/423560.aspx
    http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/…
    http://blog.deconcept.com/2005/12/15/internet-explorer-eolas-changes-and-the-flash-plugin/

    Finally, I must notice that a cross-platform technology was murdered by the most common browser. Let’s be honest, not all the website owners will modify their applications to deal with this behavior. Anf if they do, who guarantee that Microsoft will not block all the above solutions in their next update to Internet Explorer???


    Andrei
    http://www.webxpert.ro

    Comments 1 Comment »

    Let’s assume that you have a script that creates folders and files with specific php functions.
    On Linux-based servers, these files and folders belongs to “apache” user, and not to you. Of course, you can create them with 777 permissions, but default is 755, which means no write permissions to other users and groups than “apache”.
    Can you delete these files and folders through FTP ? No way.
    The only way to delete them is like you create (through php functions, under the “apache” user):
    - unlink (file) deletes a file
    - rmdir (folder) deleted a folder
    You can use them independently or, if you want to recursive delete a folder, its subfolders and files you can use this function (i found it php manual unlink page):

    function SureRemoveDir($dir) {
       if(!$dh = @opendir($dir)) return;
       while (($obj = readdir($dh))) {
         if($obj==‘.’ || $obj==‘..’) continue;
         if (!@unlink($dir.‘/’.$obj)) {
             SureRemoveDir($dir.‘/’.$obj);
         } else {
             $file_deleted++;
         }
       }
       if (@rmdir($dir)) $dir_deleted++;
    }

    and you can simply call it as:

    <? SureRemoveDir ("Test"); ?>

    Another techniques can also solve this situation, such as:
    - if you have SSH access, you can user sudo chown command to take control and then delete then normally
    - you can ask for help to an administrator (he will also use the sudo chown)
    - use suExec, if it is installed on the machine

    Andrei
    http://www.webxpert.ro

    Comments 4 Comments »

    Typical formatting of all HTML 4.0 FORM tag has a strange behavior when it contains a table cell inside. A strange vertical space appears after the FORM, even there is no <BR> or something else there.
    Here is the a typical behavior:

    Email:

    and the code is:

    <table style="text-align: left; background-color: #336699; width: 300px;" border="1" cellpadding="2" cellspacing="0">
        <tr>
          <td>
          <form name="example1">
            <table style="text-align: left; background-color: #ffffff; width: 100%;" border="1" cellpadding="2" cellspacing="0">
                <tr>
                  <td><small><span style="font-family: Tahoma;">Email:</span></small></td>
                  <td><input name="text1" value="just a test"/></td>
                </tr>
                <tr>
                  <td rowspan="1" colspan="2"><input name="Submit" value="Submit" type="submit"/></td>
                </tr>
            </table>
          </form>
          </td>
        </tr>
    </table>

    Read the rest of this entry »

    Comments No Comments »