Phonegap: detecting correct connection type on iOS 7.1 iPad

I just spent 2 hours debugging a Phonegap iPad app. The app downloads a library of images and videos to localStorage, but only if the device is currently on WiFi. The iPads do have a cellular 4G connection as well, but the data transfer would be too costly, the client said.

In all tests the files downloaded fine, and all was good. Untill a few days back: now the app constantly shows my custom msg "downloading files (waiting for WIFI)". It turned out the iPads were updated to a newer iOS version. While debugging, the network.connection.type now always returned "cellular", even when cellular was disabled on the iPad.

Solution? Turned out to be simple: overwrite the old CDVReachability.m and .h files (version 2.2) with the latest ones, version 3.5. You'll need to rename references in the 2 files from "Reachability" to "CDVReachability".
Or... just download these 2 files here, and add them to:

/plugins/org.apache.cordova.network-information/src/ios/
/platforms/ios/{app name}/Plugins/org.apache.cordova.network-information/

Hope it helps you out, I will try to add a pull request as well.

No Comments

Coldfusion Usergroup NL meeting with Bilal Soylu - May 28 2014

I am part of the organizing commitee for the Dutch CFUG, and we finally got a new meeting! The 28th of may 2014, we will be honored to have Bilal Soylu present on Style, Standards, Sanity. You can read all about it at www.cfug.nl!

Come to Utrecht and join us in a great evening full of CFML :-D

No Comments

Logging memory and cpu usage in Ubuntu

I recently installed a cluster of Ubuntu VMs for a client's web application. Now it was time for logging and monitoring, but that turned out to be not so simple at all. I couldn't find a solid Linux script which would log CPU and memory usage, so decided to write it myself.

The script extracts data from the files /proc/meminfo and /proc/loadavg, and saves them in sysinfo.log as a tab-delimited text file. The columns are:

Date   MemTotal   MemFree   MemCached   CPU-usage (=last minute avg.)

MemTotal will always remain the same, but is usefull for calculating relative available memory. MemFree + MemCached == available memory; don't be misled by the column name "MemFree".

#!/bin/bash

FILE=/home/paulk/sysinfo.log
MEMDATA=`sudo cat /proc/meminfo | egrep "^(MemTotal|MemFree|Cached)" | sed 's/[^0-9]\+//g' | tr '\n' '\t'`
CPUDATA=`sudo cat /proc/loadavg | sed 's/ .\+//'`

if [ ! -f $FILE ]
then
echo "Date MemTotal MemFree MemCached CPU-usage" > $FILE
fi
echo "$(date) $MEMDATA $CPUDATA" >> $FILE

Steps to install/use:

  1. sysinfo console output example

    Save this script as 'logsysinfo.sh' (for example in your home directory)
    1. $ nano ./logsysinfo.sh
    2. paste the script, then do CTRL + X
  2. chmod the file to 755
    1. $ chmod 755 ./logsysinfo.sh
  3. test-run:
    1. $ sudo ./logsysinfo.sh
    2. tail ./sysinfo.log
  4. If the output of the last command was 2 lines (1st=header, 2nd=numbers), then all is good.
  5. Make sure the log is updated every 5 minutes:
    1. $ sudo crontab -e
    2. add the following line in the text editor which just opened, then close the editor:
      1. */5 * * * * /home/paulk/logsysinfo.sh
    3. Wait for max 5 minutes, then do $ tail ./sysinfo.log again
    4. If there is more output then before, all seems to be working :)

Personally, I now use this log file for input of a daily monitoring script: check min-max available memory (= MemFree + MemCached), cpu spikes, etc. I hope it helps you out as well!

1 Comment

Find broken links in your cfml sourcecode

For a client which is migrating from a Windows environment to Linux, I needed to check if the source code contained broken links, due to case sensitivity on Linux. So I wrote this script, which goes through all your source files, and checks all links inside href="..." and src="..." to see if they exist.

5 Comments

Calling inner class of a Java Class in Railo

Thanks to the Railo documentation on Github, I finally found the answer I was searching for...

Question: how to call an inner Java class of a Java class with Railo?

Answer: use a $ sign: createObject("java", "main.java.class$innerClass")

Long version: I was busy implementing the javaEWSApi (MS Exchange Web Services API) into a new mobile project, but got stuck on getting the unread-count for the user’s Inbox. An example online showed ...

No Comments

supreme-blast