• kth Percentile in CFML

    I recently needed to analyze some data in CFML where there was a wide range of values but some real outliers - latency numbers for example. So I ported this kthPercentile() function. You pass in the percentile and an array of numbers - kthPercentile(99, [...]) will give you the 99th percentile for example - kthPercentile(50, [...]) is the same as the median.

    	function kthPercentile (k, data) {
    		if (k > 1) { //this allows users to pass in .99 or 99
    			k = k / 100;
    		arraySort(data, "numeric");
    		var kth = k * arrayLen(data);
    		if (kth == ceiling(kth)) { //its a whole number
    			return data[kth];
    		} else {
    			return (data[int(kth)] + data[ceiling(kth)]) / 2;


  • CFML Fuzzy Time

    A friend asked recently how I would go about writing a function to do fuzzy time - something that formats time in a casual way, the way you would talk about it in conversation - “just now”, “a few minutes ago”, “2 days ago”, etc. He wanted it to be customizable, where they could define the groupings used. This is what we came up with:

    Read more


  • Today I learned

    I have been considering starting a blog (technically again) for a while now but I couldn’t convince myself that I had something worth saying. But after being inspired by a few different people that even just documenting what you have learned can make useful and worthwhile content. I don’t expect a large audience — but this is more about me and my journey than anything.

    The subjects for the posts here will be varied; Certainly lots of technical posts about what I am learning at my new job but I would expect some scientific, social and possibly even the occasional political thought to come by as well.

    I have attempted to do this in the past without much luck — I hope to stick with it much longer this time and if you are reading this I hope you help encourage me too. Hopefully something I learn today can be something you can learn with me.


  • Jekyll Bash Function

    Trying to streamline my Jekyll development workflow, I came up with this function that I have added to my ~/.bash_profile to make things just a bit easer.

    jserve() {
    	cd ~/dev/ryanguill-blog
    	/usr/bin/open -a '/Applications/Google Chrome.app' 'http://localhost:4000'
    	bundle exec jekyll serve

    Obviously you will need to change the cd at the beginning of jserve, but this will start the Jekyll process and open up a new tab in chrome to the test address. I tried to use the detached mode for jekyll, but apparently there has been a bug for a long time that detached mode doesn’t also watch the directory so that was a non-starter. The only problem with this is that the tab will open before the serving starts, but if you wait just a second and then refresh the page it should be ready to go.

    I’m no bash expert though so if anyone has any improvements or other ideas I would like to hear about them.


  • Find leaked JS globals

    It can sometimes be easy to inadvertently leak variables / functions into the global scope in your client side javascript - this one-liner will report all non-browser global keys and their values on the page - just paste into your chrome console.

    keys(window).filter(function(key){ return ["location","document","window","external","chrome","top","lastpass_iter","lastpass_f"].indexOf(key) == -1;}).forEach(function(key){console.log(key, window[key]);});