new DWRUtil javascript functions

Ajax 1 Comment »

I use AjaxCFC currently and have written a few custom JS functions for the DWRUtil.js library. I thought I would share these in case they are useful to anyone else. I found that I needed to these particular tasks quite a lot.

Just drop these into the util.js file

 

  • selectPop()
    Populate a select list with an object of arrays returned by AjaxCFC
  • selectOption()
    looks for a specific option value in a select list, if it is there, sets it to SELECTED
  • getSelected()
    get the currently selected item in a SELECT list. if multiple options selected, return as an array
  • getSelectedText()
    As above but gets the text of selected options

 

/* DWRUtil.selectPop
added by Russ Michaels
Populate a select list with an object of arrays returned by AjaxCFC
e.g.
r.id[0] = 1
r.name[0] = 'Russ'

arguments:-
list  : name of select list to populate
obj   : object containing array
text  : item to be used for option text
value  : item to be used for option value
defaultTop : default value to be inserted at top of list
overwrite : boolean, whetehr or not to overwrite existing list
Synjtax:-
DWRUtil.selectPop('customers', r, 'id','name',['select one'], [true])
*/
DWRUtil.selectPop = function(list, obj, text, value, defaultTop, overwrite) {
 if(overwrite) $(list).options.length = 0;
 //insert a default top item in the list such as **please select**, its value will be 0
 if(defaultTop)
  $(list).options[0] = new Option(defaultTop, 0);
  for(x=0;x<obj[text].length;x++)
   {
   $(list).options[$(list).options.length] = new Option(obj[text][x], obj[value][x]);
   }
};

selectOption = function (list,searchstr)
 {
 //looks for a specific option value in a select list, if it is there, sets it to SELECTED
 
 for(a=0;a<list.length;a++)
  {
  if(list.options[a].value == searchstr)
   {
   list.options[a].selected = true;
   }
  }
 }

getSelected = function (ele)
{

//get the currently selected item in a SELECT list. if multiple options selected, return as an array
 element = $(ele);
 selectedArray = new Array();
 for(x=0;x<element.options.length;x++)
  {
   if(element.options[x].selected)
    selectedArray[selectedArray.length] = element.options[x].value;
  }
 
 if(selectedArray.length == 1)
  return selectedArray[0];
 else
  return selectedArray;

}
getSelectedText = function (ele)
{

//gets the text of selected options
 element = $(ele);
 selectedArray = new Array();
 for(x=0;x<element.options.length;x++)
  {
   if(element.options[x].selected)
    selectedArray[selectedArray.length] = element.options[x].text;
  }
 
 if(selectedArray.length == 1)
  return selectedArray[0];
 else
  return selectedArray;

}

 

SQL Server 2005 security and best practices

SQL Server No Comments »

Like me I bet a lot of you have started playing with SQL Server 2005 and found it to be a completely different beast than SQL Server 2000, especially if you are also getting to grips with the new management studio instead of Enterprise manager, which so far seems to be lacking a few features as far as I can tell ?Security is always an important factor when deploying databases and even more so in a shared environment, so here are a few useful articles to get you on track.

 

SQL Server 2005 Security Overview for Database Administrators
This paper covers some of the most important new security features in SQL Server 2005. It tells you how, as an administrator, you can install SQL Server securely and keep it that way even as applications and users make use of the data stored within.

 

Security Considerations for SQL Server
SQL Server 2005 includes a variety of highly precise, configurable security features that can empower administrators to implement defense-in-depth that is optimized for the specific security risks of their environment. Access guidance about password policy, surface-area configuration, credentials, authenticators, and more.

 

Security Considerations for Databases and Database Applications
The SQL Server 2005 Database Engine helps you protect data from unauthorized disclosure and tampering. Learn about highly granular authentication, authorization, and validation mechanisms; strong encryption; security context switching and impersonation; and integrated key management.

 

SQL Server 2005 Security Best Practices: Operational and Administrative Tasks
This white paper covers some of the operational and administrative tasks associated with SQL Server 2005 security and lists best practices and operational and administrative tasks that will result in a more secure SQL Server system.

 

Protect Sensitive Data Using Encryption in SQL Server 2005
SQL Server 2005 uses strong encryption to provide the best protection for data, a nearly inviolate barrier to exposure. Explore the encryption features in the core database engine of SQL Server 2005, and learn how they can be used to protect data stored there as well as how to allow user interaction with prtected data. Also discussed are the various keys used to protect both data and other keys within a database, and how to get information about encryption objects.

A Message for UK politicians

Jibber Jabber 1 Comment »

 

I just came across the below article which someone emailed to me, which I thought was brilliant. If only UK politicians would stand up and find some backbone instead of being scared by every idiot that falsely accuses people of being "RACIST" or "PREJUDICE" to get their own way, then perhaps we might stop being second class citizens with no rights in our own country.

 

For example, at the Nursery where we take our son, you must ring a buzzer and then push the door when it is unlocked to get inside.

There is a man who drops his son off who blatantly refuses to open the door himself when buzzed in, he will stand and wait until someone opens it for him, something to do with his religious beliefs that women should do everything for a man or something I am told, and he wife is not much nicer.

They refuse to speak English, and their children are forbidden from speaking English or playing with any white children, so they just sit in the corner and play with each other and ignore everyone else.

The poor staff in the nursery have to put up with this man being rude, obnoxious, arrogant, and treating the women like dirt, because if they don't put up with it they will be accused of being racist or prejudice even though it is quite clear that it is this couple who are in fact the racist bigots. Do you imagine for a minute that we would get away with such behaviour in their country?

 

Like the writer of the article I have no issues with immigration per se, and I would happily welcome anyone to this country as long as they behave appropriately, as the PM said which sums it up quite nice.

"We will accept your beliefs, and will not question why. All we ask is that you accept ours, and live in harmony and peaceful enjoyment with us."

 

Anyway here is the article. How you take it is up to you, if you have any issues with it, direct them at the Austrialian government.

 

---

Muslims who want to live under Islamic Sharia law were told on
Wednesday to get out of Australia , as the government targeted radicals in a bid to head off potential terror attacks.

A day after a group of mainstream Muslim leaders pledged loyalty to Australia and her Queen at a special meeting with Prime Minister John Howard, he and his Ministers made it clear that extremists would face a crackdown. Treasurer Peter Costello, seen as heir apparent to Howard, hinted that some radical clerics could be asked to leave the country if they did not accept that Australia was a secular state, and its laws were made by parliament. "If those are not your values, if you want a country which has Sharia law or a theocratic state, then Australia is not for you", he said on National Television.

 

"I'd be saying to clerics who are teaching that there are two laws governing people in Australia : one the Australian law and another Islamic law that is false. If you can't agree with parliamentary law, independent courts, democracy, and would prefer Sharia law and have the opportunity to go to another country, which practices it, perhaps, then, that's a better option", Costello said.

Asked whether he meant radical clerics would be forced to leave, he said those with dual citizenship could possibly be asked to move to the other country. Education Minister Brendan Nelson later told reporters that Muslims who did not want to accept local values should "clear off.

Basically people who don't want to be Australians, and who don't want, to live by Australian values and understand them, well then, they can basically clear off", he said.

 

Separately, Howard angered some Australian Muslims on Wednesday by saying he supported spy agencies monitoring the nation's mosques.

Quote: "IMMIGRANTS, NOT AUSTRALIANS, MUST ADAPT. Take It Or Leave It. I am tired of this nation worrying about whether we are offending some individual or their culture. Since the terrorist attacks on Bali , we have experienced a surge in patriotism by the majority of Australians."

 

"However, the dust from the attacks had barely settled when the 'politically correct' crowd began complaining about the possibility that our patriotism was offending others. I am not against immigration, nor do I hold a grudge against anyone who is seeking a better life by coming to Australia ." "However, there are a few things that those who have recently come to our country, and apparently some born here, need to understand." "This idea of Australia being a multi-cultural community has served only to dilute our sovereignty and our national identity. And as Australians, we have our own culture, our own society, our own language and our own lifestyle."

"This culture has been developed over two centuries of struggles, trials and victories by millions of men and women who have sought freedom"

"We speak mainly ENGLISH, not Spanish, Lebanese, Arabic, Chinese, Japanese, Russian, or any other language. Therefore, if you wish to become part of our society .. Learn the language!"

 

"Most Australians believe in God. This is not some Christian, right wing, political push, but a fact, because Christian men and women, on Christian principles, founded this nation, and this is clearly documented. It is certainly appropriate to display it on the walls of our schools. If God offends you, then I suggest you consider another part of the world as your new home, because God is part of our culture."

 

"We will accept your beliefs, and will not question why. All we ask is that you accept ours, and live in harmony and peaceful enjoyment with us."

"If the Southern Cross offends you, or you don't like "A Fair Go", then you should seriously consider a move to another part of this planet. We are happy with our culture and have no desire to change, and we really don't care how you did things where you came from. By all means, keep your culture, but do not force it on others.

 

"This is OUR COUNTRY, OUR LAND, and OUR LIFESTYLE, and we will allow you every opportunity to enjoy all this. But once you are done complaining, whining, and griping about Our Flag, Our Pledge, Our Christian beliefs, or Our Way of Life, I highly encourage you take advantage of one other great Australian freedom,

 

'THE RIGHT TO LEAVE'."

 

"If you aren't happy here then LEAVE. We didn't force you to come here . You asked to be here. So accept the country YOU accepted."

Samsung Q35 Ultra Portable Notebook

Product Reviews 30 Comments »

  Being a freelance consultant I spend a lot of time on the train traveling to contracts, time which I am not being paid for. I do own a laptop, a Samsung M40 17" widescreen in fact, which is way too big and heavy to be dragging to and from work every day, and is too big to use on a train or have on your lap in confined spaces, in fact it gets too hot to have on your lap period.

So I decided it was time to trade in for something small enough that I can actually carry around every day along with my PSP , my book and my Archos 504 without my bag wearing a groove into my shoulder.

To there are two options here. The new UMPC (Ultra Mobile PC) such as the  Sony Vaio UX1 or the Samsung Q1 which are great looking machines, but have limited use as they are still little more than a PDA and portable media player, sure you can run a full edition of windows and most windows app's, but I need something with enough power to be used for development. So this leaves the Ultra Portable Notebook, of which there are not too many options, and in my case this also came down to Sony and Samsung again, namely the Sony Vaio TX range and the Samsung Q35.

 

Now Sony have long held the crown for style and innovation in the notebook arena, and were I to go on looks alone then the Sony Vaio would have been my choice, but I spent a considerable amount of time in Curry's comparing these 2 machines, reading online reviews and looking at the specs, and it is quite clear that the Samsung is the superior machine here, and at half the price of the Sony, it is also a steal. In fact I ended up paying only £699, which is not only the cheapest price online but it also got delivered the next working day too.

As standard the Samsung Q35 comes with 1GB DDR RAM, 80GB HDD and Windows Visa Home Premium.

The specs state that you can only upgrade to a MAX of 1.5GB, but the chipset specs say otherwise so I went and bought 2GB DDR RAM and it is working fine.

 

 

The first and probably biggest advantage of the Samsung is the Intel Duo Core CPU, compared to the Solo core in the Sony.

The Intel Core Duo processor is optimized for multi-threaded applications and multitasking. You can simultaneously run multiple demanding applications such as graphics-intensive games or advanced programs - while downloading or running virus-scanning security programs in the background.

Core Duo Technology shows 30 - 76% performance gains in comparison to single core CPU's even as the number of tasks increases, Dual Core technology maintains performance.

So this is great if you want to use your laptop for development and will be running ColdFusion, a web server, SQL Server etc in the background, or in my case running a virtual machine.

 

Cooling is great on the Q35. On most laptops the underside can become warm, on my M40 it actually got too hot to have on your lap at all. The Q35 has so far yet to even get warm to the touch, which is due to the hefty air vent on the right hand side and the exceptional internal fan which excels all hot air but still remains quiet. If you hold your hand in front of the vent it does get pretty hot sometimes, so you know it is doing its job properly. So what this means is that you really can work with the Q35 on your lap without getting hot.

 

Battery life is also rather good with quotes of up to 6 hours in other reviews. Unfortunately I have not been able to achieve this and have only managed to get 3 hours max so far, but even this is fairly respectable compared to most laptops. I have tried numerous tweaks to improve battery time to no avail, so I may be asking for a replacement battery, of course this may also be caused by Vista.

 

Screen brightness on the Q35 is simply incredible compared to any other laptops I have used, it has 8 brightness level and I have found a setting of 3 or 4 to be acceptable when using battery power, and at level 8 it is just as bright as a desktop monitor. The LCD screen actually uses LED illumination, which does result in a glow from the bottom of the screen, but I have not found this annoying.

 

 Performance so far seems pretty good but not as good as I was expecting, but this is down to Windows Vista, which runs like a dog. Windows Vista requires 1GB RAM all by itself, takes an age to boot up and everything runs so much slower than Windows XP. Supplying this laptop pre-installed with Vista was truly a stupid idea, especially considering that Samsung states that this device will only support up to 1.5GB RAM, which means even if you upgrade you would only have an extra 512MB to play with, which is not use with today's applications. If you do not upgrade then you wont be able to launch many applications or do any serious work without the machine slowing right down to a crawl as it is forced to use the swap file being as Vista is greedily using up all the 1GB of RAM.

I have disabled all the Vista graphics effects and this has improved performance somewhat, but still not to an acceptable level.

I am going to install Windows XP which will hopefully make a big difference and I will report back on the results, but if you do want to use Vista then you will need to upgrade to the unsupported 2GB RAM as I have done.

 

Some reviews have moaned about the fact that there are only 2 USB ports, but sheesh this is meant to be an ultra portable so why would you need more? 2 is plenty for me, I only need to plug in a mouse and my USB memory stick.

If your traveling light then your hardly likely to be carrying around a load of USB devices, and for those occasions where you may need to plug in more USB devices, bring a USB hub.

 

The only real complaint I have is with the lid/monitor, which is rather flimsy. It is very easy to twist and bend, and any pressure on the top of the lip will cause the display to ripple.

It also has a small right SHIFT key and right next to it is the "\" forward slash key, as apposed to its normal position next to the left shift key.

This has caused mayhem with my typing, as I keep pressing "\" instead of shift. 

 

Update 10/08/2007

----------------------

 

For anyone that is interested, this is the RAM I upgraded with.
http://www.memoryc.com/products/description/2GB_A_Data_DDR2_667-PC2_5400-SO_DIMM_200_pin_module/index.html

 

Adding more RAM does not speed up Vista in the slightest, the only benefit you get is that you can run other other applications without constantly using the swap file, but they they will still run like a dog compared to windows XP.

I have since given up on Vista and installed windows XP instead, which is of course much better.

 

If your looking to buy a Samsung Q35, try HERE

Query of Queries quirks

ColdFusion No Comments »

Following on from all my work with web services in the last 6 months, I have recently had cause to use ColdFusions Query of Queries a lot.

Mainly due to the fact that I am converting web service responses into query recordsets and caching them in memory for later use. Then my web service facades will pull data from these cached queries (using QofQ) instead of calling the real web services.

 

Now as you should all know, when using components it is best practice to locally scope all your variables so that they are local to each function.

Note that all the below is tested on ColdFusion MX  7,0,0,91690.

 

E.G.

 

<cffunction name="echo">

<cfargument name="string"> 

<cfset var local = StructNew()>

<cfset local.return = arguments.string> 

<cfreturn local.return>

</cffunction> 

 But this is where the QofQ problems begin. It seems you cannot use more than one scoped query name. You also cannot use the word "LOCAL" as it is a reserved word, and will cause your query to fail with a less than helpful error. So when using QofQ within a CFC, you need to use the variables scope to store the queries so taht you do not need to use the scope in the actual query.

 

Here are some examples

 

THIS WORKS (because the query names are not scoped)

 

<cfquery name="foo1" dbtype="query">

select * from query1, query2
where query1.column1 = query2.column1
</cfquery>

 

THIS WORKS (as only one scoped query is being queried)

<cfquery name="foo1" dbtype="query">

select * from locals.query1
where column1 = '#locals.somevar#'
</cfquery>

 

THIS DOES NOT WORK (because 2 scoped queries are being queried)

 

<cfquery name="foo1" dbtype="query">

select * from locals.query1, locals.query2
where locals.query1.column1 = locals.query2.column1
</cfquery>


I also noticed this rather odd behaviour as well.

When joining 2 queries as above, lets say you wanted to select all rows that do not meet certain conditions, as I did. Well using <> or != does not work. You have to use the NOT clause instead.

 

E.G. 

 

!= does not work

 

<cfquery name="foo1" dbtype="query">

select * from query1, query2
where query1.column1 != query2.column1

And query1.column2 = 'foo'

</cfquery>

 

Neither does <>

 

<cfquery name="foo1" dbtype="query">

select * from query1, query2
where query1.column1 != query2.column1
And query1.column2 = 'foo'
</cfquery>

 

This does work

 

<cfquery name="foo1" dbtype="query">

select * from query1, query2
where NOT (query1.column1 = query2.column1 and query2.columns2 = 'foo')
</cfquery>

 

 

 

 What happens in the first 2 examples is that rows are returned if eaither side of the condition is true rather than BOTH.

 

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds