Doug’s Blog

Handily dispensing information to .00000001% of the world’s population

Archive for the ‘Websites’ Category

Applying callback to grecaptcha

Tuesday, June 5th, 2018

We were having some troubles with some users rushing to click the submit button on a form immediately after clicking the good ‘ole “I’m not a robot” checkbox, instead of waiting nicely for the captcha to verify. By the way, that is TOTALLY what a robot would do, so it’s probably good that it fails the verification.

But to get the submit button to only enable after the checkbox turns green, you need to provide a “callback” routine for the grecaptcha. And, you can also provide a “expired-callback” routine for if the captcha box sits around too long after a check and then turns red. Note that you need to put the defined callbacks without quotes.

Also to add some complexity, we had two separate captchas in our page, so we had to define two of them. Some people have reported troubles doing so, but our final solution worked.

We had a problem where the callback routines were not being called, but everything else was working — it turns out we have the callback functions defined AFTER the render, and moving them before that section made everything work. So, the final layout:

<script src=”” async defer></script>
var myCaptInit = function() {
var buton11 = function() {
var butoff11 = function() {
$(“#mainsubmit”).attr(“disabled”, “disabled”);
grecaptcha.render(‘recaptcha11′, {
‘sitekey': ‘xxxx’,
‘callback': buton11,
‘expired-callback': butoff11,
‘size': ‘compact’
grecaptcha.render(‘recaptcha10′, {
‘sitekey’ : ‘xxxx’,
‘size’ : ‘compact’

Disable search in google chrome address bar

Thursday, July 14th, 2016

I dislike how Chrome has turned the address bar (also known as a “location bar” or “URL bar”) into an “Omnibox”. Since I run Chrome on my Linux box, and I have a bunch of test hosts defined in my /etc/hosts file, everytime I try to shortcut by just typing a dev hostname, Google pops up a damn search result!

There are some posted methods to avoid this. One was to check chrome://flags, which does have a bunch of nice settings, however my version of Chrome DID NOT have the one to do this!

Instead I found that creating my own search engine option was the solution. Go to chrome://settings/ and choose “Manage Search Engines”. In there, add a new one with “none”, “null” and “http://%s” as the options.

Boom! No more annoying forced search! Suck it, Omnibox!

OK, deep breath.

Amazon S3 forcing streaming or download

Wednesday, July 6th, 2016

When you upload MP3 files into AWS S3, they will default to being a content-type that browsers will treat as a download (I believe “octet-stream”). If you want to change this so the delivery will be streaming, you need to change the content-type to “audio/mpeg” via the AWS console by editing “Properties” -> “Metadata”:

And if you want to revert back to forcing download, just remove the content-type metadata — note that there is no pulldown value for octet-stream!

Bootstrap Button Text Word Wrap

Monday, June 20th, 2016

Using bootstrap to display button pulldowns,, I had trouble getting the text to wrap and make the button taller as needed. The fix was adding this to the CSS for the button!

white-space: normal;

Change back to the old Google icon

Friday, September 4th, 2015

My opinion is that Google made a huge mistake with the new name “Alphabet” — they should fire the marketing people behind that concept, who no doubt must have had a bad experience mixing Redbull, Ecstasy, and AlphaBits. I mean, hey, I get it, when in Vegas — but wait until after you sober up before renaming the company.

Anywho, the thing that really gets me upset is now there is some new horrible favicon that google uses and it looks out of place on my chrome browser tabs now. This new google icon is distracting, too busy, and insults any reasonable sense of aesthetic. So, here is how to change it back!

Download the Favicon Changer chrome extension (I use chrome, but I think there are versions for other browsers if you look around). Visit, and when you use the extension you’ll have to give it a URL to your chosen favicon, I have a sample on at — if you don’t want to see a broken https link for https sites, you’ll need to give a SSL URL, like

There, now your browser tabs are more serene.

Google Maps API stopped working on IE

Thursday, February 19th, 2015

Just got reports today from customers that websites with Google Maps Javascript API stopped working, and it seems Google made some changes a day or so ago.

I found a link that had helpful information, and the exact fix that worked for me was adding this META tag:

<meta http-equiv=”X-UA-Compatible” content=”IE=EDGE” >

Webmail on Linux

Friday, July 6th, 2012

I maintain my own mail server and for cases where I can’t easily connect directly with an IMAP mail client, I use a webmail interface.

I’ve been using SquirrelMail for a while, and just recently installed Roundcube webmail which looks worlds better!

The only drawback is that it does not have vacation plugin that works right away with Dovecot, so I’m still playing around with that functionality…

Running root commands in PHP via Apache

Friday, April 29th, 2011

I have a web application that needs to perform shells commands as root within a PHP function, and you would think that would be pretty straight forward… but it did take my a few googles to get all the details, so here are my handy notes on it. This is on a Linux system running Apache, and we’ll be using “sudo” within “shell_exec” to run the commands.

The main thing is to edit the /etc/sudoers file, and typically you can (as root) use the ”visudo” command to do so.

Make sure apache can run commands, AND not require a password:

apache  ALL=(ALL)       NOPASSWD: ALL

Then you need to comment out this line:

#Defaults    requiretty

If you don’t, then you will see these errors in /var/log/secure: “sorry, you must have a tty to run sudo”. Now you are ready to go, and the PHP code is simple:

$results = shell_exec(‘sudo date’);

Changing to PHP5 in Yahoo Web Hosting

Friday, January 28th, 2011

I was updating some code on a Yahoo hosted site, and it wasn’t working because Yahoo will default you to PHP4 on their hosting. My code of course requires PHP5.

I spent a fair amount of time searching around for an answer and finally found it at

I was surprised at how difficult it was to find this switch option! After I made this post, Yahoo support replied to give me the proper link and some more information, which I must compliment Yahoo support for doing.

http AJAX fails in Internet Explorer

Friday, December 3rd, 2010

I ran across an interesting bug recently where I had an AJAX routine failing when I viewed the page in IE8. When you clicked the little warning icon in the lower left, it gave a message of “Object doesn’t support this property or method”!

It was failing around code that looks like:

function parseCalcResponse() {
if (http.readyState == 4 && http.status == 200) {
results = http.responseText;
results = results.split(“|||”);
document.getElementById(‘test’).innerHTML = results;

It turns out, the fix was to declare “results” at the top of the function code with:

var results=”;

And that fixed it!