google

#! code Logo

Creating A Chatbot Agent With Dialogflow And Kommunicate

19th April 2020 - 12 minutes read time

Having a chat feature on your website (commonly called 'live chat') is useful when helping your users overcome any difficulties they are having. You can pop up a little chat window in the page and ask if they need any help finding what they need. This can be especially useful on large commerce sites where users might get stuck looking for things.

The addition of a chatbot also allows you to automatically answer some of more common questions. For example, if a user asks where they can find the delivery and returns policy then a chatbot can automatically respond with a response. These rules can get more complicated, but it depends on what you instruct the bot to answer to.

Python Logo

Using Python To Beat The 2012 Olympic Google Doodles

11th August 2012 - 5 minutes read time

The other day I was inspired by a story on Reddit about a guy who had created a Python script to automatically play the olympic hurdles Google Doodle. The Python script just passed the correct keyboard commands to the game so that the game was finished in 1.5 seconds, earning a gold medal. The problem was that his script was specifically for Windows, so I set about trying to create a Linux version that I could run on Kubuntu.

After a bit of research I found a decent plugin that sends keyboard commands through Python called uinput. To get this installed I had to add the following lines to /etc/apt/sources.list.

JQuery Logo

Easy QR Code Generation With Google Charts API

26th April 2012 - 4 minutes read time

When I found about the ability to create QR codes using the Google Charts API I decided to sit down and create a little tool that would generate QR codes for me. I've had this tool for a while and I recently noticed that the QR code mechanism has become deprecated. The API will still work for a couple of years so I thought it was worth posting this. Creating a static QR code using Google Charts is quite easy, all you need to do is create an image. For instance, to create a QR code for the #! code address I would do the following.

<img src="https://chart.googleapis.com/chart?chs=177x177&cht=qr&chl=http://www.hashbangcode.com/&choe=UTF-8" />

Which creates the following image.

Image removed.

PHP Logo

Find Longitude And Latitude Of PostCode or ZipCode Using Google Maps And PHP

4th September 2008 - 2 minutes read time

Converting from PostCode to map reference is far from accurate, but it can be done using the Google Maps API. You can get a Google Maps API key from Google by just asking for it, although you are limited to a certain number of requests each day.

Google Maps usually works through JavaScript, but it is possible to ask Google to return the data in JSON format and then use the PHP function json_decode() to decode the information into a usable array format. To get Google to return the data in JSON you must pass the parameter "output=json" in your query string.

The following function can take a postal code and convert it into longitude and latitude.

JavaScript Logo

Multiple Google Analytics On Same Page

10th January 2008 - 1 minute read time

To set up multiple Google Analytics tags on the same page you need to use the _uff = false; command in between the unchinTracker() calls to reset the tracker for the next account. The urchinTracker() function will send information on the page visit off to Google Analytics.

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
  _uacct = "UA-XXXXX"; // First account details
  urchinTracker();
  _uff = 0; // Reset tracker for second account
  _uacct = "UA-YYYYY"; // Second account details
  urchinTracker();
</script>

You can do this for as many accounts as you like, but be aware that there will come a point when there will be a noticeable delay on the site when the calls to Google Analytics are done so don't do too many.