Notes

Android developers

February 20, 2013 by Jean

Good stuff about application design and style at http://developer.android.com/design/index.html.

Comments (0)

jQuery checkboxes

May 15, 2012 by Jean

Very useful reference at http://technosophos.com/node/223 on how to properly manipulate checkboxes with jQuery.

Cured my headache better than Advil.

In: Javascript 

Read more  Comments (0)

Apache Railo Tomcat Windows installation

February 10, 2012 by Jean

Some notes on our standard Windows + Apache + Railo + Tomcat + Apache (=WART?) install.

Railo can be installed 2 different ways:

  • Common class install: makes Railo global to the Tomcat server. All hosts share the same Railo server context, and have a unique dedicated Railo web context. That's the setup you end up with when using the Railo installers.
  • WAR install: requires a new war deployment for each host, and each host ends up with its own Railo server and web context.

We are going for the war install, to keep the option to run other Tomcat webapps (like solr) on the same server.

In: ColdFusion 

Read more  Comments (0)

Create CF admin mapping

November 3, 2011 by Jean

Using railo admin api to create mapping:

<cfadmin action="updateMapping"
    type="web"
    password="****"
    virtual="/tags"
    physical="#replace('#expandPath('../')#service/utility/tags','\','/','all')#"
    archive=""
    primary="physical"
    trusted="false">

In: ColdFusion 

Comments (0)

Import SSL certificates into Sun JDK

May 23, 2011 by Jean

List trusted authorities in Java runtime:

C:\ColdFusion8\runtime\jre\bin>keytool -list -storepass changeit -noprompt
-keystore C:\ColdFusion8\runtime\jre\lib\security\cacerts

Import new certificate:

  • Save certificate using web browser (DER encoded) as eg mycert.cer.
  • Place certificate in runtime/jre/lib/security/
  • Command line:
C:\ColdFusion8\runtime\jre\lib\security>..\..\bin\keytool -import -trustcacerts
-keystore cacerts -storepass changeit -noprompt
-alias mycert -file mycert.cer

Notes taken from Talking Tree. Thanks!

Requires ColdFusion service restart.

Comments (0)

Ogone hash test page

January 11, 2011 by Jean

For reference, the Ogone SHA hash test page is here:

https://secure.ogone.com/ncol/test/testsha.asp

And the entire PDF documentation is here:

https://secure.ogone.com/ncol/Ogone_e-Com-ADV_FR.pdf

In: Webservices 

Comments (0)

Optimize newsletter for smartphones

December 14, 2010 by Jean

This note needs to be updated, just wanted to paste a few pointers before loosing them.

How to optimize newsletters for smartphones?

  • The iPhone email client resizes the content of HTML newsletters to fit its screen.
  • The Android email client does not resize the content of HTML newsletters.

Needs to look into:

body { -webkit-text-size-adjust: none;}
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

References:

In: HTML 

Comments (2)

CSS font case

December 13, 2010 by Jean

The usual CSS font case modifiers:

{text-transform:uppercase;}
{text-transform:lowercase;}
{text-transform:capitalize;} 

And then the one I never remember (hence this note):

{font-variant: small-caps;}

In: CSS 

Comments (0)

Get a host IP address using ColdFusion

December 11, 2010 by Jean

Here is how to retrieve the IP address of a host using ColdFusion:

function getHostIP(host)
{
    var address=createObject("java", "java.net.InetAddress").getByName(host);
    return address.getHostAddress();
}
writeOutput(getHostIP('www.google.com'));

In: ColdFusion 

Comments (0)

Get ColdFusion server host information

December 11, 2010 by Jean

Here is how to get the ColdFusion server host name and IP address:

iaclass = CreateObject("java", "java.net.InetAddress");addr=iaclass.getLocalHost();
hostName = iaclass.localHost.getHostName();
hostName2 = addr.getHostName();
hostIp = addr.getHostAddress();

In: ColdFusion 

Comments (0)

Get ColdFusion locale information

December 11, 2010 by Jean

Getting information about a locale is pretty straightforward:

<cfset pc = getPageContext() />
<cfset setLocale("Chinese (China)") />
<cfoutput>
     <ul>
          <li>Current Locale: #getLocale()#</li>
          <li>Language: #pc.getResponse().getLocale().getLanguage().toString()#</li>
          <li>Country: #pc.getResponse().getLocale().getCountry().toString()#</li>
     </ul>
</cfoutput>

Create an instance of a Java locale:

myLocale = createObject("java","java.util.Locale").init("fr","FR"); 

See all available java.util.Locale methods:

<cfdump var="#createObject("java","java.util.Locale").init("fr","FR")#">

<cfdump var="#getPageContext().getResponse().getLocale()#">

In: ColdFusion 

Comments (0)

Key order in ColdFusion structures

December 10, 2010 by Jean

One issue with ColdFusion structures is that they do not preserve the order of their keys. Considering:

variables.myStruct = structNew();
variables.myStruct.one = 1;
variables.myStruct.two = 2;

The output of:

<cfoutput>#structKeyList(variables.myStruct)#</cfoutput>

is not always the same. Sometimes "one,two" and sometimes "two,one". It depends on server conditions that only unicorns understand. For the rare cases where the order of the keys does matter, the cure is to use a Java hash map:

variables.myStruct = createObject("java", "java.util.LinkedHashMap").init();
variables.myStruct.one = 1;
variables.myStruct.two = 2;

The output of #structKeyList(variables.myStruct)# will always be "one,two" - the order in which the keys have been created.

Notes:

  • Most (if not all) structure functions (structKeyList(), structKeyExists() ...) can be applied to the Java hash maps. YAY!
  • A cfdump of a Java hash map does not respect the order of the keys, but seems to order the keys alphabetically.
  • To be tested, but it looks like Railo preserve the order of keys in structures.

In: ColdFusion 

Comments (4)

Spell out numbers using icu4j

December 9, 2010 by Jean

Needed to spell out numbers (421 → four hundred twenty-one) for printing on receipts. Ended using icu4j, a Java internalization library developed by IBM.

Once the icu4j.jar is available to your ColdFusion class path, something like this should work:

function spellOut(int)
{
locale = createObject("java", "com.ibm.icu.util.ULocale").init('en_US');
ruleBased = createObject("java","com.ibm.icu.text.RuleBasedNumberFormat").init(locale,1); return ruleBased.format(javacast("long", arguments.int),"%spellout-numbering"); }

In: ColdFusion 

Read more  Comments (0)

CSS to act like pre tag

December 8, 2010 by Jean

CSS code to keep preformatting (acts like <pre> tag):

p {white-space:pre;}

CSS code to remove preformatting (acts like <p> tag):

pre {white-space:normal;}

Source: http://www.w3schools.com/css/pr_text_white-space.asp

In: CSS 

Comments (0)

Get file information

October 30, 2009 by Jean

Get information on a file using Java functions:

variables.myFile = CreateObject("java", "java.io.File");
variables.myFile.init("/path/to/file");
variables.last_modified = myFile.lastModified();

Sometimes more convenient than CFFILE.

In: ColdFusion 

Comments (0)

Get ColdFusion memory usage

October 30, 2009 by Jean

Retrieve the memory usage of the ColdFusion server using Java functions:

variables.runtime = createObject("java","java.lang.Runtime").getRuntime();
variables.freeMemory = variables.runtime.freeMemory() / 1024 / 1024;
variables.totalMemory = variables.runtime.totalMemory() / 1024 / 1024;
variables.percentFreeAllocated = round((variables.freeMemory / variables.totalMemory) * 100);

In: ColdFusion 

Comments (0)

Sleep for a while

October 30, 2009 by Jean

Make the current request sleep for a while:

thread = createObject("java", "java.lang.Thread");
thread.sleep(javaCast("long", 1000*attributes.interval));

In: ColdFusion 

Comments (0)

Client variables purge query

October 30, 2009 by Jean

Queries run by ColdFusion to purge database stored client variables in CDATA:

delete FROM CDATA WHERE CFID in (SELECT CFID from CGLOBAL where CGLOBAL.lvisit < '2008-11-19 14:18:03')

and then in CGLOBAL:

delete FROM CGLOBAL WHERE CGLOBAL.lvisit < '2008-11-19 14:18:03'

In: ColdFusion 

Comments (0)

Set JVM encoding to UTF-8

October 30, 2009 by Jean

Add to the JVM arguments:

-Dfile.encoding=UTF-8

In: ColdFusion 

Comments (0)

Get rid of duplicates in lists

October 30, 2009 by Jean

Regex to remove dupliactes from a list. Not sure where it comes from, but it works:

function DeDupe(list,type)
{
     return reReplaceNoCase(ListSort(list,type),"([^,]+)(,1)*","1","ALL");
}

In: Regex ColdFusion 

Comments (0)