CFStuff
WebDevelopment, ColdFusion, Railo, JS, Database and Tech-related by the Co-Founder and CEO of tunesBag.com
Tuesday, 15 February 2011
Subversion access without Apache: svn+ssh
By chance I realized that there is a much better, easier and more secure way to do that: svn+ssh
Just enter e.g. svn+ssh://username@subversionhost/repository as remote location and eclipse will automatically create a tunnel for you to this location and you don't have to run an apache on that host any more!
ANT is working fine with this type of location as well (although you might need to update some libraries) and I think ssh-compression is enabled because files will be transferred faster than with the default http(s) transport.
Sunday, 13 February 2011
Root + Update HTC Desire to 2.2 the simple way
There are several discussions (fire up Google) on this topic and the advice is to root the device and update the system with a custom ROM. While I'm a fan of playing around with devices and programs most of the time I'm not really happy with doing that with my phone. Why? I just want to use it for phone calls, check my emails, use some apps and browse the internet. No need to apply some specials hacks to my device.
Guess what - it's not that easy to find a firmware that's just doing that, finally I came accross this Pre-rooted Stock Froyo ROM, it's pretty much the default HTC firmware and updating to this version is really simple (You can download the original HTC firmware as well as it seems).
Just follow these three steps:
- Root your phone using unrevoked3
No mess with gold cards (at least for me), just download the app and run it (Further Instructions)! - Download the ROM from the source above and place it on the SD card
Connect your phone using the USB cable and mount your SD card as drive - Get ROM Manager from the Google Market (it's free)
Click on "Update ROM" in the program and select the ZIP file which you've just copied to the SD card - the program will reboot your phone several times and perform the update.
Most important, now I'm able to enjoy Froyo and the mobile hotspot feature.
A message towards Google - Please offer pre-build default Android versions which can be applied to any phone without any hassles using a simple "update" button like in iTunes, I'm sure most of the people are interested in a genuine platform and not a provider/vendor branded one with "special features".
Friday, 3 September 2010
Native hashchange event - Good bye polling
I just discovered that there is a native HashChange event in the latest version of several browsers (FF, Webkit, IE) - this way navigation solutions working with the hash at the end of a URL work without nasty timers.
To add the event, simply use:
if ( window.addEventListener ) {
window.addEventListener( 'hashchange', function () { checkHashChange(location.hash) }, false );
} else if ( window.attachEvent ) {
window.attachEvent( 'onhashchange' , function () { checkHashChange(location.hash) } );
}
Take a look at these samples as well. In real world applications you still will need to use a combination of both methods (polling + events).
Concerning the support of the feature in various browsers, please click here for a comparison chart.
Tuesday, 13 July 2010
Int( boolean) will return 0 or 1
Tuesday, 25 May 2010
CFIMAGE: Compile great looking artist images
Sources: http://www.flickr.com/photos/96679304@N00/176295962, http://www.flickr.com/photos/11671827@N00/522201514, http://www.flickr.com/photos/87258901@N00/2951288353, http://www.flickr.com/photos/44124348109@N01/2834953166
Thursday, 13 May 2010
Facebook Like Button will double your page hits
Tuesday, 4 May 2010
UrlEncodedFormat: Encoding space characters - plus (+) vs %20
application/x-www-form-urlencoded
This is the default content type. Forms submitted with this content type must be encoded as follows:
- Control names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
- The control names/values are listed in the order they appear in the document. The name is separated from the value by `=' and name/value pairs are separated from each other by `&'.
Sunday, 28 February 2010
Fixing "An invalid XML character (Unicode: 0x0) was found in the element content of the document."
Tuesday, 26 January 2010
Silent Setup of Sun JDK (Linux, Debian)
Here's a tips I found trying to do the same as you :Works like a charm!
1. Create an answers.txt file with the word yes inside
2. Launch fhe following command (assuming you want to install jdk-xx.bin)
./jdk-xx.bin <>/dev/null
Wednesday, 20 January 2010
Ant & SCP on Mac
Tuesday, 22 December 2009
NYCFUG - I was there ;-)
Monday, 14 December 2009
Amazon EC2 goes Lorem ipsum
Wednesday, 2 December 2009
Add missing Array.indexOf to Internet Explorer
// make sure indexOf is supported
if(!Array.indexOf){
Array.prototype.indexOf = function(obj, start){
for(var i=(start||0); i<this.length; i++){
if(this[i]==obj){
return i;
}
}
}
}
Sunday, 1 November 2009
Apache, Railo & mySQL Troubles after Upgrading to Snow Leopard
Thursday, 20 August 2009
Setup Mac OS X + Apache + Railo
Today I started with the Apache / railo setup using a guide by Luid Majano (I had to download the Apple XCode Setup file (almost 1 GB) in order to compile the connector for Apache and reset the httpd to 32 bit instead of 64 bit).
Further problems I had to solve:
- Read how to fix the "Apache Error: Client denied by server configuration" error (very restrictive configuration makes sense on real life systems but on dev systems ...?)
- I wasn't able to access my files until I executed a chmod a+x on every directory in the path to the webroot (apache log [error] [client ::1] (13)Permission denied:)
Thursday, 11 June 2009
Using the H2 database in ColdFusion
- Download the latest version of H2
- Drop the h2*.jar file in the WEB-INF/lib directory of your ColdFusion server (directory depends on your type of setup)
- Restart CF
- Add a new datasource
- JDBC URL = jdbc:h2:file:%Path to Database file on your disk%
- Driver Class = org.h2.Driver
- Driver name = default
- User name = sa
Wednesday, 29 April 2009
Railo - Compatibility issues with scopes (URL etc)
One of the most important ones is that railo always references the scope name when you use URL, FORM etc no matter if a local variable with this name exists or not. To give you an example, run this code in CF and in railo:
To make railo behave the same way, you've to add a full reference to the function -
<cfparam name="url.step" type="string" default="1" />
<cfset a_call = PrintURL( 'http://tunesBag.com/' ) />
<cfdump var="#a_call#">
<cfscript>
function PrintURL( url ) {
return url;
}
</cfscript>
return arguments.url
In ColdFusion you'll see http://tunesBag.com as output, in railo the URL structure. Some further explanations concerning the scopes and this "bug" can be found here (Adobe Livedocs) and here (Railo Bugtracker)
Having fun with railo: CFQUERY supporting complex objects
An example:
cfset q = QueryNew('data');
querySetCell( q, 'data', { firstname = 'John', surname = 'Doe' }, 1);
cfdump var="#q#"
You can access the structure by using q['data'][1]!
cool!
Important: This complex data won't survive a query of queries operation, in this case the simple classname will be shown in the column.
Monday, 23 February 2009
CFFEED not usable due to missing timeout property
Sunday, 15 February 2009
"Corrupt table" errors (ColdFusion 8, mysql)
I've updated our live servers and I hope we won't see this error again.
Sunday, 25 January 2009
Enhance performance of Joins / Queries: Make sure all columns share the same collation
I changed the collation for column B to the same as column A - and the query executive time dropped from about 1300 msec to 100 msec!
So always make sure you're using the same collation if possible when performing joins!
Friday, 16 January 2009
JavaScript variables set in onclick - different behaviour in IE / FF
An example:
a onClick="variableA = 'peter';CallFunction();return false;" ...
function CallFunction() {
alert(variableA);
}
In FF, an alert box will show "Peter", in IE you'll receive an exception.
How to solve that? Simply declare variableA on top of your JavaScript file, this way IE will modify the global variable.
var variableA = '';
Tuesday, 6 January 2009
Railo - important path placeholders
When creating these custom mappings, there are some very interesting path placeholders you can use:
{railo-web}: path to the railo web directory typical "{web-root}/WEB-INF/railo"
{railo-server}: path to the railo server directory typical where the railo.jar is located
{temp-directory}: path to the temp directory of the current user of the system
{home-directory}: path to the home directory of the current user of the system
{web-root-directory}: path to the web root
{system-directory}: path to thesystem directory
This way you can create mappings without using the full path to the directory - very cool!
Wednesday, 29 October 2008
Create & Connect to databases (mysql, SQLite etc) on the fly with ColdFusion
In this case it comes in handy that ColdFusion is a Java-based product, so you can use all the power JDBC is offering. At the online music hub tunesBag I recently had to create SQLite databases on the fly - it's quite easy in fact as you can see below:
1) Add the JDBC Driver (or use an existing one)
You can use any JDBC driver, e.g. mysql, MS-SQL etc
In my case: Download the SQLite JDBC Driver from zentus.com and place it in wwwroot/WEB-INF/lib (sqlitejdbc-v053.jar)
a_sqlite = createObject( 'java', 'org.sqlite.JDBC' )
a_prop = createObject( 'java', 'java.util.Properties' )
db_filename = '/tmp/sqlite_' & CreateUUID() & '.db'
2) Write the code (this is an example for sqlite)
a_conn = a_sqlite.connect( 'jdbc:sqlite:' & a_db_filename, a_prop.init() )
a_statement = a_conn.createStatement()
a_res = a_statement.execute( 'BEGIN;')
Create the table
a_res = a_statement.execute( 'CREATE TABLE test (id INTEGER PRIMARY KEY, firstname TEXT, surname TEXT);');
Insert data
prep = a_conn.prepareStatement( 'INSERT INTO
prep.setString( 1, 'John' );
// you can add multiple inserts ...
prep.addBatch();
prep.setString( 1, 'Max' );
prep.setString( 2, 'Mustermann' );
prep.addBatch();
// insert!
prep.executeBatch();
// save the changes
a_res = a_statement.executeUpdate( 'END;');
// quit
a_conn.close();
a_conn = 0;
Where to go from here
For more details, check out the official JDBC documentation provided by SUN!
Sunday, 19 October 2008
mySQL - cfqueryparam - Comments - "No value specified for parameter"
After some playing around I found out that you should now use question marks in the SQL comments - it seems as CF or mysql is interpreting this char and assuming a parameter, even if it's contained in a comment.
Monday, 11 August 2008
New ColdFusion primer / tutorial
Sunday, 29 June 2008
Not all CGI variables show up using CFDUMP
I am just using CGI.REDIRECT_URL now and it works.
The interesting thing is that StructKeyExists(CGI, blabla) does not work at all - the check will always return true.
Wednesday, 11 June 2008
VARing cffile and the result variable
The problem is that somehow the cffile scope will stay zero - until I added the property "result" to the cffile tag saying the result should be stored as "cffile" - so the whole call is:
Now it works again!
Saturday, 3 May 2008
Web Developer's Handbook
Sunday, 20 April 2008
Apache: Disable HostNameLookups
After some research we found out that disabling the host name lookup (HostNameLookups = Off) helped to speed up the pages delivery. Now our analyzer will perform the lookup task and we're happy again ;-)
Wednesday, 16 April 2008
JRUN crashes after changing the hostname of a machine
So make sure your internal hostname and the hostname set in /etc/hostname is the very same!
Thursday, 20 March 2008
MD5 Hash values: Be aware of uppercase/lowercase
Some further research shows that almost every other service I know produces lowercase only hash values, ColdFusion produces uppercase values. Be aware of that! ;-)
Monday, 25 February 2008
JVM heap errors: Check every cffile / cfhttp request
So be aware of this and do the following:
- Check the size of uploaded files (by performing checks with the size given in cffile or using a routine like that).
- Before you request any unknown website using cfhttp, do a HEADER operation and check out for the size (cfhttp.responseHeader, Content-Length) or add Content-Range headers to the request in order to allow only a certain content size
Sunday, 24 February 2008
ColdFusion / MacOS 10.5 / WebConnector: Not again!!
One solution might have been again to download the whole connector sources (XCode) and compile the connector myself - some hours work plus about 1-2 GB downloads for an about 90kb file.
The other solution: Follow these instructions and download the file offered for download.
Tuesday, 12 February 2008
Attention: INNER JOIN is now the default in transfer
The solution was to write the full LEFT OUTER JOIN statement instead.
Wednesday, 23 January 2008
Very uncool - no implicit structure creation within function calls
So - a major downside is that you cannot create structures using this way within functions calls ... very bad. An example:
Very uncool, same thing noticed by Ben
a_component.StoreInformation( key = arguments.key, data = { firstname= a_str_firstname } )
Tuesday, 27 November 2007
Reset ColdFusion Administrator password
Here you can find a nice solution how to achive a password - reset.
Wednesday, 14 November 2007
XML vs JSON: Incredible performance differences
During the finalization of a project we came across several performance problems with a huge dataset and I tried to move the data interaction to JSON.
The result: The time of parsing a XML with jQuery (loop over the element using each) was up to 100 times higher than doing a simple JSON request (According to the results of the firebug console.timer output). No special treatment, just looping over the records and building an array in javaScript using the default jQuery way.
So, I hope in future times XML parsing will speed up with faster computers (although I think there will be not much gain in the near future because browser XML parsers just use MSXML or Xerces right now).
If you do not have ColdFusion 8 (which offers built-in JSON support), you might take a look at this library.
Thursday, 8 November 2007
20 ways to secure your apache server
Easy way to run several ColdFusion instances using one apache server
As long as only one version of CF is running using apache as webserver everything is fine, it starts getting complicated when you decide to run e.g. 7 and 8 on one machine using one apache instance. Here you can find a solution how to set it up with different JRun ports which I did once as well (took me hours to find out all these stuff ;-)).
A very nice, quick and dirty solution I came accross some time ago is to use the power of mod_proxy - in this case you tell apache to forward all requests to a different port / URL whatever.
So I did the following:
- Set up CF 7
- Connect CF 7 to apache using the default way
- Set up CF 8 using the internal web server
- Enabled mod_proxy in apache (AddModule / LoadModule)
- Added the following lines in my virtual host configuration for a CF8 host:
ProxyRequests on
ProxyPass / http://127.0.0.1:8500/ - Worked!