Posts RSS Comments RSS 129 Posts and 246 Comments till now

Archive for the 'Tricks' Category

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)

Regex to match SQL-Style String

This post is copying the style that is used by Stephen Ostermiller in his article HERE.

 

Motivation

I am currently creating a RichTextBox control that will format and highlight the SQL string. I notice that the current regex that I used is not match correctly to a certain combination of SQL-style string.

 

Consider we have the following SQL statement:

Print ‘Testing Regex\’s String Matching’; Print ‘ ‘;

 

First Try

‘.*’

Print ‘Testing Regex\’s String Matching’; Print ‘ ‘;

This is incorrect. The regex should only match those within two single-quotes, not expand to the last single-quote.

 

(After n-Try)

‘.*?[^\\]’

Print ‘Testing Regex\’s String Matching’; Print ‘ ‘;

This should be the correct one.

 

For those who want to practice their Regular Expression skill, try to download THIS software, it’s free and it’s really good for Regex practice.

Credit goes to Buddie for pointing out this PAGE.

UPDATE (22 Sep 2007)

 

As it turns out, I totally forgot that SQL-style string doesn’t use \’ (backslash-quote) but uses ” (quote-quote). So things getting more complicated now.
So we need to change the string into something like this:

Print ‘Testing Regex’’s String Matching’; Print ‘ ‘;

Another Try

‘[a-zA-Z\ ]*(”)*[a-zA-Z\ ]*’

Print ‘Testing Regex’’s String Matching’; Print ‘ ‘;

But if we change the input string into

Print ‘Testing Regex’’s String’’s Matching’; Print ‘ ‘;

It becomes

Print ‘Testing Regex’’s String’’s Matching’; Print ‘ ‘;

Which is wrong.

 

Finally

‘([a-zA-Z\ ]*(”)*)*’

Print ‘Testing Regex’’s String” Matching’; Print ‘ ‘;

This should be the correct one.

Sodeve’s WP-Translate 2.2 Released

Hi all. I have managed to patch the WP-Translate and tested it on Wordpress 2.2.

Current Version: 2.2

Overview

WP-Translate is a simple drop in way for users to view your blog in their language. Its easy for any most users to add this functionality to their site.

WP-Translate utilizes the following Online translation services:

  1. Alta Vista’s Babel Fish (for translation from English to : French, German, Italian, Dutch, Spanish, Greek, Russian, Portuguese, Japanese, Korean, Simplified/Traditional Chinese)
  2. IBM’s Websphere Translation (for translation from English to: Brazilian Portuguese)
  3. Interpret (for translation from English to: Bahasa Indonesia, Swedish, Norwegian, Afrikaans)

WP-Translate 2.2 Release Notes

Added the following language for translation:

  1. Swedish
  2. Norwegian
  3. Bahasa Indonesia
  4. Afrikaans
  5. Chinese Traditional
  6. Brazilian Portuguese

Requirements

WP-Translate works with Wordpress 1.5 up to Wordpress 2.2 (Tested on Wordpress 2.2)

Your web server should able to execute PHP.

Installation instructions

  1. Upload the wp-translate directory to your plugins folder, usually wp-content/plugins/
  2. Activate the plugin on the plugin screen.
  3. Add <?php wptranslate(n); ?> to your template where you want the list. n can be either 1 or 2. 1 is for a vertical display. 2 makes it horizontal.

Special Installation instructions for non-Wordpress users

As I mentioned before, as long as your Web server supports PHP you should be able to use this plugin. Please follow this steps:

  1. Extract the zip file
  2. Edit wp-translate.php which is located in wp-translate directory
  3. At line 103, replace $img_loc = get_settings(’siteurl’) . ‘/wp-content/plugins/wp-translate’; with $img_loc = ‘/wp-translate’;
  4. Save the file
  5. Upload the wp-translate directory to your root folder.
  6. In the page you want the flags to be displayed, put <?php include_once(realpath($_SERVER[’DOCUMENT_ROOT’]).’/wp-translate/wp-translate.php’); ?> in the first line of the file.
  7. Add <?php wptranslate(n); ?> anywhere you want the flags to be displayed. n can be either 1 or 2. 1 is for a vertical display. 2 makes it horizontal.

 

Download Sodeve’s WP-Translate 2.2

The previous version can be found here:Sodeve’s WP-Translate 2.1

 

If you like this plugin, please link-back to this post, or add me to your blog-roll. Would be greatly appreciated. Thank you.

Having problem with installing the plugin? You have ideas for the plugin? Post a comment and I will try my best to help you.

Update: 5 June 2007

Users of this plugin:

  1. Myself (^_^)v
  2. Founders Cafe
  3. Your Blog?

So You Like MS Paint? Here is the Free and Much much better Replacement

I like MS Paint for its simplicity. It’s small, fast, and quite handy for creating a simple button/banner (Like the one you see below Capt. Jack Sparrow’s picture on the sidebar).

Until I found Paint.NET. This program’s loading time is slower to MS Paint by less than 1 second. So it’s nothing to complain. The interface is almost similar to MS Paint

Some feature comparison between MS Paint and Paint.NET:

Features MS Paint Paint.NET
Tabbed document interface no yes
Layers no yes
Live thumbnail no yes
Number of Colors Supported 28 (although you can select other colors by going through the menu: Colors - Edit Colors - Define Custom Colors) alot :P
Special Effects (sharp, blur, emboss, distortion, etc.) no yes

 

And a lot more features …

And the best part, it’s open source. The online community is very active. So you can expect many plugins written by the community.

Paint.NET Minimum System Requirements:

  • Windows XP (SP2 or later), or Windows Vista, or Windows Server 2003 (SP1 or later)
  • .NET Framework 2.0
  • 500 MHz processor (Recommended: 800 MHz or faster)
  • 256 MB of RAM (Recommended: 512 MB or more)
  • 1024 x 768 screen resolution
  • 200+ MB hard drive space
  • 64-bit support requires a 64-bit CPU that is running a 64-bit version of Windows XP, Windows Vista, or Windows Server 2003, and an additional 128 MB of RAM

Get Paint.NET Now!!!

BUG FIX: How To Kill MS Excel Process Started by ASP.NET

On 18th May 2007, Tanmoy commented on “How To Kill MS Excel Process Started by ASP.NET”.

Initially on denial (^_^)/, I finally have time to investigate the issue. Tanmoy actually got it correctly. So I created a new GUI demo on how to correctly kill a particular Excel process.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Excel;
using System.Diagnostics;

namespace ThreadingGUI_01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            ApplicationClass app = new ApplicationClass();
            if (app == null)
            {
                MessageBox.Show("Unable to Open Excel");
            }

            app.Visible = true;
            _Workbook wb = app.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            this.listBox1.Items.Add(app.Hwnd);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.listBox1.SelectedIndex >= 0)
            {
                Process[] procs = Process.GetProcessesByName("EXCEL");
                int selectedExcel = (Int32)this.listBox1.SelectedItem;
                foreach (Process p in procs)
                {
                    if (p.MainWindowHandle.ToInt32() == selectedExcel )
                    {
                        p.Kill();
                        this.listBox1.Items.Remove(selectedExcel);
                    }
                }
            }
        }
    }
}

Thanks to Tanmoy (^_^)/

Download the Project here.

Pages (2): [1] 2 »

Close
E-mail It
Socialized through Gregarious 42