Posts RSS Comments RSS 133 Posts and 258 Comments till now

Archive for the 'Software' Category

Administrator Tips: Prevent Users Uploading MP3 files to your Windows 2003 Server

Winamp, the famous MP3 player

For those of you who is currently managing a Windows 2003 Server (or any server), users upload MP3 files to the company server might poise a possible copyright infringement. If you are, hopefully this ARTICLE will help you do your work.

 

But please note that it could be possible that user actually upload the whole album in a document archive (zip, rar, ace, etc). So there are ways to work around the prohibition described in that article. So it’s actually a continuous effort from you to prevent users from uploading copyrighted materials into your company server.

 

I take above approach as the curative approach. The preventive approach should be educating the users in your company about copyright infringements. And always let the users know that whatever they are doing in the company’s servers, they should be responsible to their actions. And don’t forgot to emphasize that “We’re watching you!” (and you may finish it with an evil laugh .. :P )

Foxit Reader on Ubuntu Linux (through Wine)

I like Foxit Reader very much. It’s fast, small and give you pretty much everything you need for a PDF Reader. Although they have the Linux version, I don’t really like it because I don’t seem to be able to automatically open a PDF file with a single click from Nautilus (although I already set ReaderLinux as the default Application).

 

Before we proceed, I am assuming you already have Wine up & running, and have installed the Windows version of Foxit Reader. What we need to do next is to associate the PDF file to Foxit Reader through Wine in Nautilus (or other File Manager that you have). If you have not install Wine, you could read the tutorial HERE.

 

After you have Wine up and running, download the Windows version of Foxit Reader HERE. Install it using the default settings.

 

First save the following script as foxit.sh in your home directory

#!/bin/bash
# Purpose: To convert Linux-style filename to Windows-style to pass as an argument
# to wine when starting Foxit Reader
Filename="z:"${1//\//\\}
#assuming you use the default installation folder for Foxit in Wine
App='eval wine "C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe" "'$Filename'"'
$App

 

Use foxit.sh as the Default Application for PDF File (select any PDF file in Nautilus, Right-Click -> Properties -> Open With -> Click [+ Add] Button -> Browse for foxit.sh located in your home folder.

 

Voila! Foxit Reader is now the default application for your PDF documents.

 

(Disclaimer: This post was based on 64-bit Ubuntu Gutsy Gibbon and Foxit Reader 2.1 Build 2023)

SQL String Formatter (Part 2)

As I promised before, I will put the output of the programs that I mention in the previous post.

As input I will use the following SQL string (which I have verified that it is a valid SQL statement).

 ALTER PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name   sysname AS BEGIN     CREATE TABLE #aspnet_RoleMembers     (         Group_name      sysname,         Group_id        smallint,         Users_in_group  sysname,        User_id         smallint     );     INSERT INTO #aspnet_RoleMembers     EXEC sp_helpuser @name;     DECLARE @user_id smallint;    DECLARE @cmd nvarchar(500);    DECLARE c1 cursor FORWARD_ONLY FOR         SELECT User_id FROM #aspnet_RoleMembers;    OPEN c1;    FETCH c1 INTO @user_id;    WHILE (@@fetch_status = 0)    BEGIN        SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';        EXEC (@cmd);        FETCH c1 INTO @user_id      END;     CLOSE c1;    DEALLOCATE c1  END

The output of the program are as follows:

  1. SQLinForm
    ALTER
    PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name sysname
    AS
            BEGIN
                    CREATE TABLE #aspnet_RoleMembers
                                    (
                                    Group_name sysname    ,
                                    Group_id smallint     ,
                                    Users_in_group sysname,
                                    User_id smallint
                                    );
                    INSERT INTO #aspnet_RoleMembers EXEC sp_helpuser @name;
                    DECLARE @user_id smallint;
                    DECLARE @cmd nvarchar(500);
                    DECLARE c1
                    cursor FORWARD_ONLY FOR
                            SELECT User_id FROM #aspnet_RoleMembers;
                            OPEN c1;
                            FETCH c1 INTO @user_id;
                    WHILE (@@fetch_status = 0)
                    BEGIN
                            SET @cmd =  'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';
                            EXEC (@cmd);
                            FETCH c1 INTO @user_id
                    END;
                    CLOSE c1;
                    DEALLOCATE c1
            END
    



    Initially I thought there was missing ‘END’, but I found out that because I choose ‘Any SQL’ instead of ‘SQL Server’. Very impressive!!!

  2. SQL Online Formatter
    ALTER PROCEDURE [DBO].[ASPNET_SETUP_REMOVEALLROLEMEMBERS]
                   @name SYSNAME
    AS
      BEGIN
        CREATE TABLE #ASPNET_ROLEMEMBERS (
          GROUP_NAME     SYSNAME,
          GROUP_ID       SMALLINT,
          USERS_IN_GROUP SYSNAME,
          USER_ID        SMALLINT);
    
        INSERT INTO #ASPNET_ROLEMEMBERS
        EXEC SP_HELPUSER
           @name;
    
        DECLARE  @user_id SMALLINT;
    
        DECLARE  @cmd NVARCHAR(500);
    
        DECLARE C1 CURSOR FORWARD_ONLY FOR
        SELECT USER_ID
        FROM   #ASPNET_ROLEMEMBERS;
    
        OPEN C1;
    
        FETCH  C1
        INTO @user_id;
    
        WHILE (@@FETCH_STATUS = 0)
          BEGIN
            SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';
    
            EXEC( @cmd);
    
            FETCH  C1
            INTO @user_id
          END;
    
        CLOSE C1;
    
        DEALLOCATE C1
      END
    

    As you see, it also performs as good as SQLinForm

  3. SQL Review
    ALTER PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name sysname AS
    BEGIN
    
    CREATE TABLE #aspnet_RoleMembers (
          Group_name sysname,
          Group_id smallint,
          Users_in_group sysname,
          User_id smallint
       );
    
    INSERT INTO #aspnet_RoleMembers
    EXEC sp_helpuser @name;
    
    DECLARE
       @user_id smallint;
    
    DECLARE
       @cmd nvarchar(500);
    
    DECLARE
       c1
    CURSOR FORWARD_ONLY
    FOR
    SELECT
       User_id
    FROM
       #aspnet_RoleMembers;
       OPEN c1;
       FETCH c1 INTO @user_id;
       WHILE (@@fetch_status = 0)
    BEGIN
    
    SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';
    
    EXEC (@cmd);
       FETCH c1 INTO @user_id
    END;
    CLOSE c1;
    DEALLOCATE c1
    END
    


    Unfortunately there is no option to indent text between BEGIN and END. But the plus point is you can run it

  4. Pl/sql tidy
    Hmm.. doesn’t seem to work. Is it because it only parse PL/SQL? (I will investigate further when I really have nothing to do :P)

As for the LEX script, I’m still trying to get it work on C# using CsLEX, so it would take sometime before I post the result here.

SQL String Formatter (Part 1)

I am looking for a code (or command line software) that able to format/tidy-up SQL string to make it readable and doesn’t irritate the eyes. So far I have found:

  1. SQLinForm
    It’s quite handy, you can run it on your browser and download the offline version which is packaged into one single Java Jar file. Unfortunately, I’m looking for something with with command line or open source. At least with command line support I can invoke it from my .NET program to process the temporary file.
  2. SQL Online Formatter
    Still without the programmability support.
  3. SQL Review
    With command line support. Unfortunately It’s throwing error on one of my stored procedure, but it still gives you the output.
  4. Pl/Sql Tidy
    This program is only available in command line. Unfortunately, it never able to process my stored procedure. I not so sure whether it’s still maintained.
  5. Using Flex Script.
    This page is pure inspirational. It immediately opened up my eyes for the possibility of using Flex or Regular Expression. I think will stick to this solution.

Although I have made up my mind, I will provide the output of each program in the next posting. Hopefully once I am be able to port VS. Babu’s lex script (or make my own regular expression code), I will share it with you all.

Credits:

1. Carson McDonald

Internet Explorer is ‘The Blue Pill’, Firefox is ‘The Red Pill’

Yes. I am talking about those pills offered by Morpheus to Neo in ‘The Matrix‘ movie. Isn’t a huge coincidence that Internet Explorer is ‘Blue’ and Firefox is ‘Red’?

 

Now, before you telling me ‘Dude, what the heck are you talking about?’. Imagine that we as Web Developers/Programmers become Neo. Then imagine that Natural laws such as gravity, electricity and magnetism are the W3C definition for HTML, CSS and XHTML.

 

OK, back to the movie. If Neo chooses the Red Pill, he will wake up from his ‘artificial life’ and life in the real world. He will suffer, but he will know the real world. But if Neo chooses the Blue Pill, he will carry on in his ‘artificial life’. He might never meet the hardship of the real world.

 

So the premise here are ‘Red Pill’ will bring you to real life. To get something, you must follow the natural laws (e.g. W3C’s HTML Definition). But ‘Blue Pill’ will make your life easier as you don’t need to always follow the natural laws (e.g. W3C’s HTML definition) yet you will still get the same thing.

 

For example, to get a tooltip for your images, Internet Explorer will only need the ALT attribute in your image. But Firefox will not display the tooltip if you use ALT attribute. Because according to the natural laws (i.e. W3C’s HTML Definition), ALT is to be displayed when the Image is not available. To have the tooltip, W3C’s rules stated that you must use the TITLE attribute in your images.

 

So throw away your ‘Blue Pill’ and take the ‘Red Pill’. As I said, you might suffer a little bit, but you will see the real world. =)

 

PS: This post was inspired by my inability to see the tooltips in my WP-Translate images. Apparently I’ve been consuming the Blue Pill without realizing it. >.<

 

Reference:
Firefox, ALT Tags, and Tooltips

Pages (2): [1] 2 »

Close
E-mail It
Socialized through Gregarious 42