Category: Javascript

  • Alexa + AWS Lambda Hello World in Javascript

    Here is the Javascript version of my earlier tutorial Hello World in AWS Lambda + Amazon Alexa:

    'use strict';
    
    function buildResponsePayload( title, output, repromptText, shouldEndSession ) {
    	return {
    		outputSpeech: {
    			type: 'PlainText',
    			text: output
    		},
    		card: {
    			type: 'Simple',
    			title: 'alexaHelloWorld - ' + title,
    			content: 'alexaHelloWorld - ' + output
    		},
    		reprompt: {
    			outputSpeech: {
    				type: 'PlainText',
    				text: repromptText,
    			},
    		},
    		shouldEndSession,
    	};
    }
    
    function buildResponse( sessionAtts, speechResponse ) {
    	return {
    		version: '1.0',
    		sessionAtts,
    		response: speechResponse,
    	};
    }
    
    function sayHelloWorld( callback ) {
    	const sessionAtts = {};
    	const cardTitle = 'alexaHelloWorld';
    	const textOutput = 'Hello Javascript World';
    	const shouldEndSession = false;
    
    	callback( sessionAtts, buildResponsePayload( cardTitle, textOutput, textOutput, shouldEndSession ) );
    }
    
    exports.handler = ( event, context, callback ) => {
    	try {
    		sayHelloWorld( ( sessionAtts, speechResponse ) => {
    			callback( null, buildResponse( sessionAtts, speechResponse ) );
    		} );
    	} catch( e ) {
    		callback( e );
    	}
    };
    

    Enjoy!

  • I Open Sourced My Twenty Sixteen Child Theme

    Today, I open sourced my Twenty Sixteen child theme. It includes an empty resume page template and a clean travel shortcode that uses Google Maps. You’ll need to check out the source code for usage, but it’s very simple 🙂

    This child theme is meant to be only very small improvements to the WordPress Twenty Sixteen default theme, but they were improvements that I felt were very valuable.

    View the code: https://github.com/rcoll/twentysixteen-rcollier

    Pull requests are welcome.

  • Easy Automatic Facebook Share Counts (Fully Javascript)

    Drop this little gem in your site’s header:

    <script>
    function numberFormat(x) {
    	return x.toString().replace(/B(?=(d{3})+(?!d))/g, ',');
    }
    
    jQuery(document).ready(function($){
    	$('.trigger_facebook_count').each(function(){
    		var url = $(this).attr('data-url');
    		var that = $(this);
    
    		$.get('http://graph.facebook.com/' + url, function(data) {
    			that.html(numberFormat(data.shares));
    		});	
    	});
    });
    </script>
    

    Then, add elements to your page like so:

    <div class="trigger_facebook_count" data-url="http://bossip.com"></div>

    Remember to change the data-url to whatever URL you are referencing, and viola! You’re done.