Tuesday 29 June 2010

HTML5 and touch phone devices

Here is the first (I think) framework for Mobile phone (touch) devices, I need to explore more on this and will post in detail soon.

http://www.sencha.com/

Sencha Touch allows your web apps to look and feel like native apps. Beautiful user interface components and rich data management, all powered by the latest HTML5 and CSS3 web standards and ready for Android and Apple iOS devices. Keep them web-based or wrap them for distribution on mobile app stores

Friday 18 June 2010

Abobe Flex ArrayCollection Sort

This is a inbuilt functionality, which I used to sort the ArrayCollection.
I just wanted to put it here so this can be handy for my reference, ;)

public var availableRegions:ArrayCollection = new ArrayCollection();
/* Create the SortField object for the "data" field in the ArrayCollection object, and make sure we do a numeric sort. */
var dataSortField:SortField = new SortField();
dataSortField.name = "name";
dataSortField.caseInsensitive = true;

/* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
var regionDataSort:Sort = new Sort();
regionDataSort.fields = [dataSortField];

/* Set the ArrayCollection object's sort property to our custom sort, and refresh the ArrayCollection. */
availableRegions.sort = regionDataSort;
availableRegions.refresh();

Load Testing using JMeter

This week I got chance to do load testing using JMeter for the work we have done @ 2nd Byte

This was the first time I used JMeter, which is an open source and quite impressive.

It's can't record user's click like some of the paid load performance check tools but it still does the job.

Here is the link for the Download: JMeter

Its very easy to use.

Give it a try, its worth trying it.

Enjoy

Action script Date Data Provider

I had a requirement to show 2 drop downs for From and To selection of months and year, values like this:

Jan, 2010
Feb, 2010 and so on

And I used the following class to get this working like this.

Based on the class from
http://flexdateutils.riaforge.org/

public function getListOfMonthsAndYear(date:Date,noOfMonths:int = 12):ArrayCollection
{
var monthArr:ArrayCollection = new ArrayCollection();
var obj:Object = new Object();
var dt:Date = new Date();
var n:int = 0;
for (var i:int = noOfMonths; i >= 0; i--)
{
n++;
dt = DateUtils.dateAdd(DateUtils.MONTH,-i, date);
obj = new Object();
obj['label'] = DateUtils.dateFormat(dt,'MMM YYYY');
obj['data'] = DateUtils.dateFormat(dt,'YYYYMM');
obj['no'] = n;
monthArr.addItem(obj);
}
return monthArr;
}

Then I created filtering on the second drop down to remove all the entries which are not relevent, like if you select in your From combo, say Month March, 2010 then you don't want user to select Jan, 2010 in To combo as that would be wrong.

Here is the filter I created on Array Collection:

/**
* From Month Change Handler
*/
private function onFromMonthChange(event:Event):void
{
var comboBox:ComboBox = null;

comboBox = event.currentTarget as ComboBox;
this.currFromMonthNo = Number( comboBox.selectedItem.no );
this.monthToDP.filterFunction = this.toMonthFilter;
this.monthToDP.refresh();
if (this.monthToDP.length > 0) this.monthsTo.selectedIndex = 0;
this.criteria.monthFrom = this.monthsFrom.selectedItem.data;
this.criteria.monthTo = this.monthsTo.selectedItem.data;
}

private function toMonthFilter(obj:Object):Boolean
{
return Number(obj.no) >= this.currFromMonthNo;
}

Actually I used a trick to store number starting from 1 to end of the list in both collections and removed the items with the no's above the selected one from To combo list

Enjoy

Adobe Flex Combo box Binding Bug

I was working on one project at 2nd Byte and hit this problem of Combo Box's data provider not being updated intermittently.

I came across one post which described the bug in SDK 3.5 (it was in previous SDK's as well.

I was doing like this:
[Bindable] public var comboDP:ArrayCollection;

myComboBox.dataProvider = comboDP;

and this wasn't getting updated values and had to do like this to get this working:

myComboBox.dropdown.dataProvider = comboDP;


Link to the post

Enjoy

Yahoo rejects emails

My Friend Anuj hit a problem of his clients emails not being delivered to Yahoo users. and I found few links which could be a help if you hit the same problem.

Link 1

Link 2

Link 3

Link 4

DomainKeys

This looks like a Marathon or Herculean task to sort this thing out.

I thought putting it here might help someone or me at some point.

Friday 11 June 2010

SQL makes decision for you - strange

I ran into a strange MSSQL behaviour.

I wanted to do some calculation and output it in my application like this:

Declare @aFlaot float

set @aFlaot = 3*1/2

select @aFlaot aFlaot

From above I was expecting a float value as I was storing it in a float type variable but it was returning 1 ( as an integer)

And when I tried following I got back right value with correct decimals

Ex 1)

set @aFlaot = 3*1.0/2

select @aFlaot aFlaot

Returned 1.5 (as expected)

Ex 2)

declare @aVal float
set @aVal = 1

set @aFlaot = 3*@aVal/2

select @aFlaot aFlaot

Returned 1.5 (as expected)

What I understand is SQL decides on the basis of values you are using in your calculation not the container type you are using.

Friday 4 June 2010

Few links to get going on Ajax or Flex - Swiz

Flex framework - Swiz
http://www.briankotek.com/blog/index.cfm/2009/1/8/Using-Swiz-Part-1-Initial-Setup

JasonLint Validator
http://www.jsonlint.com/

Tuesday 1 June 2010

Coldfusion transaction error

I came across very weird error from one of my cold fusion cfc page, which has quite a lengthy cftransaction in it with quite a lot insert queries and the error was:
Branch target offset too large for short

I had to split the code in 2 pages and moved transactions in and include page though I am against having an include page in cfc but for time being wanted this code to work, found an article related to this problem here:
Branch offset error

I am very amazed that this error is in Cold fusion from CF7 and CF9 still throws the same error.

I will try to ask the solutions from ColdFusion Gurus.

Finding file extension in SQL

Here is the SQL code to find the extension of a file:

declare @appurl varchar(50)
set @appurl= reverse('philip.singh.bedi.doc')

select reverse(LEFT(@appurl, CHARINDEX('.', @appurl) - 1)) ext,
reverse(RIGHT(@appurl, LEN(@appurl) - CHARINDEX('.', @appurl))) fname

Monday 31 May 2010

Few Handy Javascript functions for HTML forms

Here are few handy javascript function, which I use on day today basis in my Web development:

// Returns string after trimming spaces from both sides
function AllTrim(str)
{
str = LTrim(str);
str = RTrim(str);
return str;
}
//Returns string after trimming spaces from left side
function LTrim(str)
{
return str.replace(/^\s+/g,'');
}
//Returns string after trimming spaces from right side
function RTrim(str)
{
return str.replace(/\s+$/g,'');
}
// validates email form field, if you pass true, it checks for empty field as well
function checkEmail(str, required)
{
regexPattern = /^[a-zA-Z_0-9-]+(\.[a-zA-Z_0-9-]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$/;
str = AllTrim(str);
if (required == 'undefined' || required )
{
if( str.length == 0 )
{
return false;
}
}
else
{
if( str.length == 0 )
{
return true;
}
}
return regexPattern.test(str);
}
// returns selected radio button value from a group of radio buttons in a form
function getSelectedRadioValue(formObj, obj)
{
var selected_radio_val = '';
for (var i=0; i < document[formObj][obj].length; i++)
{
if (document[formObj][obj][i].checked)
{
selected_radio_val = document[formObj][obj][i].value;
break;
}
}
return selected_radio_val;
}

Saturday 29 May 2010

Coldfusion 8 Query feature

This post is the extension of my earlier post - 10 March 2009

Actually I wrote about getting Identity column value, when inserting a new record in MSSQL data base. but few days ago I found out from Ben Forta's blog, here is the link to that blog and content:

If you are using a database table with an identity (auto-increment) field, ColdFusion 8 can automatically return the newly created field value for you, without needing a trigger or a subsequent . All you need to do is look in the optional RESULT structure, and if available the value will just be there. This feature is very DBMS and driver specific (and unfortunately does not seem to be supported by Apache Derby), and the name of the structure member containing the generated value is different based on the DBMS being used. Here are the ones you should be aware of:

* SQL Server: result.IDENTITYCOL
* Oracle: result.ROWID
* Sybase: result.SYB_IDENTITY
* Informix: result.SERIAL_COL
* DB2: result.KEY_VALUE
* MySQL: result.GENERATED_KEY (MySQL 4 and 5 only, MySQL 3 does not support this feature)

Ben Forta's Article link

Upgrade to Flex 3.5 - removes html templates files

I came across the problem when I upgraded my Eclipse Flex Builder Plugin to use Flex 3.5 SDK.

When I was using clean my project option, it was removing html-template folders content, and solution is (I found a solution on web from one blog/ article):

Go to your project's properties (right click, Properties)
Go to Flex Compiler
Under "Html wrapper" un-check "Generate HTML wrapper file" Click "Apply"
Then check "Generate HTML wrapper file" (the same one you just unchecked)
Click "Apply"
You should now see that the html wrapper files are regenerated.

This happened to me when I used the clean option on one of my projects.

Thursday 27 May 2010

How to find Function, Stored Proc, Table, View Details

In Microsoft SQL Enterprise Manager

Open The query Tab for the DB

Write the object name (just name without DBO etc)

Select the object name and press Alt + F1

Will list all information related to that object
i.e. For function

Will list
1) Creation /owner etc details
2) Output details with type etc
3) Input needed by that function

Sunday 23 May 2010

Configuring Secure Virtual Host on Mac OS X

I had requirement to test my Flex Application, which I build for Raileasy in Secure environment.
It was quite difficult to configure my Mac, as I couldn't find a good post/ Blog or any article on it.
I asked few of my friends, who are using Mac for their development work and only Andy Allan gave me few tips and links:

Following are the articles helped me to set-up my Mac:
1) Mark Liyanage - article on Configuring mod_ssl on Mac OS X

2) Generating an SSL Certificate with Apache+mod_ssl

Here are the steps I took to configure my Mac (which are based on above articles):
First Open a terminal window and type in these commands:
  • sudo -s
  • cd /etc/apache2
  • mkdir ssl
  • chmod 700 ssl
  • cd ssl
  • gzip -c --best /var/log/system.log > random.dat
    (This step will create a file with the name and zip the file, which we will use to generate key)
  • openssl rand -rand file:random.dat 0

I was looking for a certificate to put on my local machine (which is self signed certificate) and to get that, here are the steps I took:
Issue following command in the already opened terminal window (which should be all in one line):

Before run the command get following questions answers ready:
***********
* Country Name (2 letter code) [AU]:GB
* State or Province Name (full name) [Some-State]:London
* Locality Name (eg, city) []:London
* Organization Name (eg, company) [Internet Widgits Pty Ltd]:Dev Co.
* Organizational Unit Name (eg, section) []:Development
* Common Name (eg, YOUR name) []:www.yourlocal.com
* Email Address []:admin@yourlocal.com
(It's important that you enter the host name of your web server exactly as it will be used later on in the "Common Name" field, like www.yourlocal.com or ssl.yourlocal.com.)
***********
COMMAND to run in terminal window:
openssl req -keyout privkey-2010.pem -newkey rsa:1024 -nodes -x509 -days 365 -out cert-2010.pem

Make sure that "TextEdit" is not running, then type these lines into the terminal window:
  • chmod 600 privkey-2001.pem
  • chown root privkey-2001.pem

On Mac Snow - Apache comes with default config file for SSL
Open following files in any text editor

/etc/apache2/httpd.conf (main config file for Apache)
/etc/apache2/httpd-ssl.conf

1) In ssl.config file look for
VirtualHost definition
You would see like this:
<VirtualHost _default_:443>

But above setting didn't work for me, I had to change it to like this, and I don't know the reason though, but it worked:
<VirtualHost www.yourlocal.com:443>

Change the DocumentRoot to the right root for your web site.
You might need to Add Directory access rights for the document root:
<Directory /sites/yoursite/wwwroot>
allow from all
Options +Indexes
</Directory>

Find the following and change them with right path and file name:
SSLCertificateFile "/etc/apache2/ssl/cert-2001.pem"
SSLCertificateFile "/etc/apache2/ssl/cert-2001.pem"

Save the file

You need to un-comment following line in httpd.conf file
#Include /private/etc/apache2/extra/httpd-ssl.conf

Save the file

from terminal window

run pwd command and make sure you are at
/etc/apache2/

run following commands:
apachectl stop
apachectl start
Now your server will provide secure access to your website.

The one thing I didn't understand was, by doing tis, all of my local website turned into secure websites.

But I was able to test my website under secure environment.

Thanks to the writers of above articles.

:)

Thursday 20 May 2010

Flex Spy (fxSpy)

This is a nice component, if you are a Flex Developer:

I found out this component today, when Anuj showed me.

This is very impressive, and useful to play with styles like you can do with firebug.



Here is the Project:

http://code.google.com/p/fxspy/



And an article by Anuj as well:

http://www.anujgakhar.com/2009/09/05/triggering-flexspy-with-a-keyboard-shortcut/



Another one from some developer:

http://blogs.warwick.ac.uk/stevencarpenter/entry/flex-spy_live_component

Wednesday 19 May 2010

Few helpful links for MAC

MAMP
http://www.mamp.info/en/index.html

SQLLite

http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/sqlite3.1.html


Installing Railo + Apache in Mac OSX

http://www.luismajano.com/category/getrailo/

Tuesday 2 March 2010

Symlinks or Symbolic links in MAC

Here is the way and explanation on how to create symbolic links on Mac:

ln -s -i -v target linkname

where
  • -s means that I want to create a symbolic link
  • -i means that I will be prompted if the symlink already exists
  • -v means that I'll see a message confirming that the symlink was created
  • target is the path to the file or folder that I want to point to
  • linkname is the path and name of the symlink file that I want to create
For example, to create a symlink to the file /Users/username/Documents/test.txt, and place that symlink in my home directory, I would use this command:
ln -s -i -v /Users/username/Documents ~/doc

I found the above in following post:


Bob's blog 


Thanks to Bob for this post.

Saturday 6 February 2010

Naat From Muhammad Ali Jahoori

कख सवाद न मिसरी अंदर, खंडा वि चख दिथियाँ (dithiyan )
पर एना सारियां चीजां नालों गलां सज्जन दियां मिठिया |
पर ओना सारियां चीजां नालों लबा सज्जन दियां मिठिया |
सुपने दे विच मिलया माहि ते मैं गल विच पा लईआं बावाँ,
डर दी मारी आख न खोलां, किते फेर विच्र्ड न जावां |
आन बसो मोरे नयनन मैं, मैं अखियाँ बंद कर लूँ,
न मैं देखू गेर को, न मैं तोहे देखन दूँ |
कजरा लागे किरकरो, मेरी आँखों से गिरता जाये
जिन नयनन मैं पिया बसे वहां दूजा कौन समाये,
मैं गल विच पा लईआं बावा,
औ डर दी मारी आख न खोलां, किते फेर विच्र्ड न जावां |
ते हिज्र तेरा जद पानी मंगे, ते मैं खू नयेना दे गेरा,
दिल चाहोंदा है तेनु सामने बिठा के अज दर्द पुराने छेर्रा
यार जीना दे विचड जावन ओ क्यों रोवन थोडा,
हर शे नालो जालम यारो जिस दा नाम विचोड़ा |
जीतन जीतन हर कोई खेड़े, तू हारान खेल फकीरा,
जीतन दा मूल कोडी पेंदा हारान दा मूल हीरा
(मियां साब दे कलाम दी तां कोई इन्तहा ही नहीं
और जीना वि पर्ददे जाओ )

Friday 22 January 2010

Adobe ColdFusion 9 in parallel with Macromedia ColdFusion 6 (or 7,8)

I managed to install Adobe ColdFusion 9 on my machine when I was contracting in Exeter. First I managed to convince them to move forward to use CF9 and helped them by installing CF9 in parallel to Macromedia ColdFusion 6 on their DEV machines so they can test their existing code and compare between both versions, I also used CF9's excellent feature "Code Analyser" to analyse the existing code, and it was a great help:
Here are the steps I took to Install CF9 and get it working:
(I achieved this by going through few blogs: I can't remember the url's, but update here)

CF9 Installation Guide
These are the steps you need to take to install CF9 in parallel to CF6 and uses Apache web server:
1) Download CF9 Trial version from https://www.adobe.com/cfusion/tdrc/index.cfm?product=coldfusion
2) Stop CF 6 Admin service (Macromedia JRun Admin Server ) (if running), and also turn Start-up Type to Manual
3) Stop CF6 Cfusion service (Macromedia JRun CFusion Server)
4) Stop CF6 Default service (Macromedia JRun Default Server) (if running), and also turn Start-up type to Manual
5) If any other CF 6 services are running, like ODBC, Search/ Verity – turn them off
6) Find the CF 9 installer and run it by double clicking it
7) Opt for the trial version
8) (IMP) Change the Folder (Default option of Jrun4) to CF9Jrun4 as Jrun4 is being used by CF 6
9) Opt for installation type Multi-Server (2nd Option), (That’s what we want in here)
10) And Opt for in-built Application web server (You don’t want to play with existing Apache web server config file)
11) You don’t need Any of ODBC, .Net services except documentation (But you can make your own call here), I would say don’t select them for this test environment.
12) Let it install and finish, if you get any message of failure, look at the log, normally you get warning about some folders can’t be removed, you can ignore this.
13) Open jrun.xml from C:\CF9Jrun4\servers\admin\SERVER-INF
a. Find “jrun.servlet.http.WebService” service and change port to 8001 (or any no, which is not being used by CF6)
b. Find “jrun.servlet.jrpp.JRunProxyService” service and change port to 51002 (or any no, which is not being used by CF6)
14) Open jrun.xml from C:\CF9Jrun4\servers\cfusion\SERVER-INF
a. Find “jrun.servlet.http.WebService” service and change port to 8383 (or any no, which is not being used by CF6)
b. Find “jrun.servlet.jrpp.JRunProxyService” service and change port to 51000 (or any no, which is not being used by CF6)
15) Save both files and re-start your machine
16) Open “Jrun Launcher” from Start/All Programs/Adobe/Coldfusion 9 (multi server version)/
a. Start Admin server
b. Start Cfusion server
17) Go To Start/All Programs/Adobe/Coldfusion 9 (multi server version)/ and right click on “Adobe ColdFusion 9 Administrator” and click on properties and change port to 8383 from 8300
18) Go To Start/All Programs/Adobe/Coldfusion 9 (multi server version)/ and right click on “JRun Management Console” and click on properties and change port to 8001 from 8000
19) Go To Start/All Programs/Adobe/Coldfusion 9 (multi server version)/ and run “Adobe ColdFusion 9 Administrator” by clicking on it
20) Enter admin password and let it run for first time and follow the on screen instruction
21) When it is ready – click ok
22) You will see CF Admin screen, now set up
a. Mail server
b. Custom Tags
c. CFX Tags
d. Data Sources
e. Or any other settings like debugging, mappings if you want to.
By loading a “*.car” file or manually
23) Open Apache Config file (httpd.conf), and go to the virtual host section of the web site you want to run under CF9 and copy and paste following three lines after the end of alias or before the
JRunConfig Apialloc false
JRunConfig Serverstore "C:/CF9Jrun4/lib/wsconfig/1/jrunserver.store"
JRunConfig Bootstrap 127.0.0.1:51000

Make sure you got the right path, though you won’t find any folder after lib and you shouldn’t be worried about this.
Save it and re-start Apache web server.


That’s it, happy CF9 server experience 

Friday 1 January 2010

Happy New Year

2009 was a mixed year for me, I got hit by recession, Emojo was closed because of this, the co I worked for almost a year and half. I started contracting, which I was thinking from quite a long time. On 21st Dec I joined Kingston Communications - Exeter as ColdFusion contractor, initially the contract is of 4 weeks with a possible extension. Lets see how it goes. I have been in talks with 2ndByte based at Godalming, Guildford, I might start here in last week of Jan.

I am looking forward to be more productive in 2010.

Best wishes to all.