<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Google - All your code are belong to us]]></title><description><![CDATA[Thoughts, stories and ideas on code and technology in general.<br>Blog title inspired by <a href="https://en.wikipedia.org/wiki/All_your_base_are_belong_to_us" target="_blank">this meme</a>]]></description><link>https://allurcode.com/</link><image><url>https://allurcode.com/favicon.png</url><title>Google - All your code are belong to us</title><link>https://allurcode.com/</link></image><generator>Ghost 4.48</generator><lastBuildDate>Sat, 04 Apr 2026 12:35:50 GMT</lastBuildDate><atom:link href="https://allurcode.com/tag/google/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Add reCAPTCHA to NodeJS and ExpressJS app with AJAX form]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Google&apos;s <a href="https://www.google.com/recaptcha/">reCAPTCHA</a> is great for getting rid of those pesky bots spamming your contact forms. Implementing reCAPTCHA on your site is very easy, albeit somewhat confusing if you try to follow <a href="https://developers.google.com/recaptcha/intro">official documentation</a>.<br>
Below example assumes you&apos;re using NodeJS with ExpressJS for back-end and Pug (formerly</p>]]></description><link>https://allurcode.com/add-recaptcha-to-nodejs-and-expressjs-app-with-ajax-form/</link><guid isPermaLink="false">5ba8b26ed282fe76158958ec</guid><category><![CDATA[reCAPTCHA]]></category><category><![CDATA[nodejs]]></category><category><![CDATA[expressjs]]></category><category><![CDATA[Google]]></category><dc:creator><![CDATA[Wojtek]]></dc:creator><pubDate>Mon, 08 Oct 2018 11:01:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Google&apos;s <a href="https://www.google.com/recaptcha/">reCAPTCHA</a> is great for getting rid of those pesky bots spamming your contact forms. Implementing reCAPTCHA on your site is very easy, albeit somewhat confusing if you try to follow <a href="https://developers.google.com/recaptcha/intro">official documentation</a>.<br>
Below example assumes you&apos;re using NodeJS with ExpressJS for back-end and Pug (formerly Jade) templating engine on the front-end. General principle is the same regardless of languages used.<br>
I&apos;ll assume you&apos;ve already set up your reCAPTCHA API keys. If you haven&apos;t just go to <a href="https://www.google.com/recaptcha/">https://www.google.com/recaptcha/</a> and follow onscreen instructions.</p>
<h3 id="templatefiles">Template files</h3>
<p>Open up your template file where you want to use reCAPTCHA, in my case <code>index.pug</code>. Add reference to reCAPTCHA JavaScript file as mentioned in official documentation.</p>
<pre><code class="language-pug">script(src=&apos;https://www.google.com/recaptcha/api.js&apos;)
</code></pre>
<p>Then copy the submit button code from official docs and paste it in your template, or in case of Pug, make it similar to below.</p>
<pre><code class="language-pug">button.btn.btn-default.g-recaptcha(data-sitekey=&quot;your_site_key&quot;, data-callback=&quot;contactSubmit&quot;) Submit
</code></pre>
<p>Remember to change <code>your_site_key</code> to your actual Site Key. If you&apos;re copying and pasting code from reCAPTCHA website, it should have your key already filled in.</p>
<h3 id="javascripttosubmittheform">JavaScript to submit the form</h3>
<p>Notice <code>data-callback=&quot;contactSubmit&quot;</code> in the above code for the button. Copying code for the button directly from documentation may have a different callback function name. I called mine <code>contactSubmit</code>.<br>
All you need to do is create a function in your JS file to handle form submission, making sure you pass the token value to it as an agrument and then pass it down the line to the server. Below is a pretty standard AJAX form submission example. I kept it to minimum to illustrate just the reCAPTCHA variable.</p>
<pre><code class="language-javascript">function contactSubmit(token) {
	var name = $(&apos;#contactForm #name&apos;),
		email = $(&apos;#contactForm #email&apos;),
		message = $(&apos;#contactForm #message&apos;);
	
	// check if the form fields are not empty
	if (name.val() !== &apos;&apos; &amp;&amp; email.val() !== &apos;&apos; &amp;&amp; message.val() !== &apos;&apos;) {
		$.ajax({
			type: &apos;POST&apos;,
			url: &apos;/handlecontact&apos;,
			data: {
				name: name.val(),
				email: email.val(),
				message: message.val(),
				recaptcha: token
			},
			dataType: &apos;json&apos;,
			error: function (data) {
				$(&apos;#contactForm #formFeedback&apos;)
                    .removeClass()
                    .addClass(&apos;alert alert-danger&apos;)
                    .html(&apos;Something went wrong, please try again&apos;)
                    .fadeIn(&apos;slow&apos;)
                    .delay(10000)
                    .fadeOut(&apos;slow&apos;);
				return false;
			},
			success : function (data, res) {
				if (data.success === true) {
					$(&apos;#contactForm #formFeedback&apos;)
                        .removeClass()
                        .addClass(&apos;alert alert-success&apos;)
                        .html(data.msg)
                        .fadeIn(&apos;slow&apos;)
                        .delay(5000)
                        .fadeOut(&apos;slow&apos;);
					// clean up form fields
					name.val(&apos;&apos;);
					email.val(&apos;&apos;);
					message.val(&apos;&apos;);
					return true;
				} else {
					$(&apos;#contactForm #formFeedback&apos;)
                        .removeClass()
                        .addClass(&apos;alert alert-danger&apos;)
                        .html(data.msg)
                        .fadeIn(&apos;slow&apos;)
                        .delay(10000)
                        .fadeOut(&apos;slow&apos;);
					return false;
				}
			}
		});
	} else {
		$(&apos;#contactForm #formFeedback&apos;)
            .removeClass()
            .addClass(&apos;alert alert-warning&apos;)
            .html(&apos;Please fill in all fields&apos;)
            .fadeIn(&apos;slow&apos;)
            .delay(10000)
            .fadeOut(&apos;slow&apos;);
		return false;
	}
}
</code></pre>
<h3 id="expressjsserverside">ExpressJS - server side</h3>
<p>Open ExpressJS file in which you handle your form data on the server side. In my case it&apos;s <code>index.js</code>, and add <code>https</code> module at the top to handle captcha verification request.</p>
<pre><code class="language-javascript">var https = require(&apos;https&apos;);
</code></pre>
<p>Then in the method handling your form data verify if user has passed captcha verification.<br>
All you really need to do is send the reCAPTCHA token back to Google for verification. That&apos;s what we need https module for.</p>
<pre><code class="language-javascript">app.post(&apos;/handlecontact&apos;, function (req, res) {
	// verify recaptcha
	if (req.body.recaptcha === undefined || req.body.recaptcha === &apos;&apos; || req.body.recaptcha === null) {
		res.send({success: false, msg: &apos;Please select captcha first&apos;});
		return;
	}
	const secretKey = &apos;your_secret_key&apos;;
	const verificationURL = `https://www.google.com/recaptcha/api/siteverify?secret=${secretKey}&amp;response=${req.body.recaptcha}&amp;remoteip=${req.connection.remoteAddress}`;
	
	https.get(verificationURL, (resG) =&gt; {
		let rawData = &apos;&apos;;
		resG.on(&apos;data&apos;, (chunk) =&gt; { rawData += chunk })
		resG.on(&apos;end&apos;, function() {
			try {
				var parsedData = JSON.parse(rawData);
				if (parsedData.success === true) {
					// All good, send contact email or perform other actions that required successful validation
					res.send({success: true, msg: &apos;Your message has been sent. Thank you.&apos;});
					return;
				} else {
					res.send({success: false, msg: &apos;Failed captcha verification&apos;});
					return;
				}
			} catch (e) {
				res.send({success: false, msg: &apos;Failed captcha verification from Google&apos;});
				return;
			}
		});
	});
});
</code></pre>
<p>When testing reCAPTCHA make sure you refresh the page between &quot;submit&quot; button clicks. Otherwise Google may think you&apos;re a bot for clicking too many times and not submit the form at all.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Add Google AdSense to WordPress without plugins]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>I wanted to add Google AdSense to my blog just to see how easy it is to do. I&#x2019;ve googled a bit and found a handful of plugins that claim to do it all for you. I couldn&#x2019;t decide which one to choose and started thinking</p>]]></description><link>https://allurcode.com/add-google-adsense-to-wordpress-without-plugins/</link><guid isPermaLink="false">5b7b0aa2b52b43084c9ea146</guid><category><![CDATA[adsense]]></category><category><![CDATA[Google]]></category><category><![CDATA[plugins]]></category><category><![CDATA[wordpress]]></category><dc:creator><![CDATA[Wojtek]]></dc:creator><pubDate>Sun, 15 Jan 2012 20:25:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>I wanted to add Google AdSense to my blog just to see how easy it is to do. I&#x2019;ve googled a bit and found a handful of plugins that claim to do it all for you. I couldn&#x2019;t decide which one to choose and started thinking from a different angle. It turns out that you don&#x2019;t need any plugins to install Google AdSense on your site and what&#x2019;s most important <strong>you don&#x2019;t even need any programming knowledge</strong>! The whole process will take you no more than 5 minutes.</p>
<ol>
<li>Log in to your blog&#x2019;s admin panel.</li>
<li>Click on <code>Appearance</code>.</li>
<li>Click on <code>Widgets</code>.</li>
<li>Find a <code>Text</code> widget and drag it to the <code>Sidebar</code> (or any other place where you want the AdSesnse to appear).</li>
<li>Enter title. I&#x2019;ve used &quot;Interesting Links&quot;.</li>
<li>Paste your Google AdSense code into widget&#x2019;s content area. My code looks like this:<pre><code class="language-javascript">&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-4589490261258499&quot;;
/* allurcode */ google_ad_slot = &quot;2642741863&quot;;
google_ad_width = 300; google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;&lt;/script&gt;
</code></pre>
</li>
<li>Click <code>Save</code>.</li>
</ol>
<p>That&#x2019;s it, we&#x2019;re done! Go to your blog&#x2019;s homepage and smile &#x1F642;<br>
Note, allow a few minutes for Google to create the adds before they actually show up.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Sharing in 2010 belonged to Facebook]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p><img src="https://allurcode.com/content/images/2011/01/2010-addthis-trends-infographic1.jpg" alt="Sharing in 2010" loading="lazy"></p>
<p>Very nice infographic by <a href="https://jeffwongdesign.blogspot.com/">http://jeffwongdesign.blogspot.com/</a></p>
<!--kg-card-end: markdown-->]]></description><link>https://allurcode.com/sharing-in-2010-belonged-to-facebook/</link><guid isPermaLink="false">5b7b0aa2b52b43084c9ea12f</guid><category><![CDATA[Facebook]]></category><category><![CDATA[Google]]></category><category><![CDATA[MySpace]]></category><category><![CDATA[share]]></category><category><![CDATA[sharing]]></category><category><![CDATA[Twitter]]></category><dc:creator><![CDATA[Wojtek]]></dc:creator><pubDate>Sun, 30 Jan 2011 17:44:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p><img src="https://allurcode.com/content/images/2011/01/2010-addthis-trends-infographic1.jpg" alt="Sharing in 2010" loading="lazy"></p>
<p>Very nice infographic by <a href="https://jeffwongdesign.blogspot.com/">http://jeffwongdesign.blogspot.com/</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Install mod_pagespeed from source on CentOS]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>I&#x2019;m not going to write about whether I think mod_pagespeed is good or not, is it suitable for your website, why you should use it or not. I&#x2019;ll focus only on installation and configuration.</p>
<p>Since you&#x2019;re here and still reading I assume you</p>]]></description><link>https://allurcode.com/install-mod_pagespeed-from-source-on-centos/</link><guid isPermaLink="false">5b7b0aa2b52b43084c9ea12d</guid><category><![CDATA[Apache]]></category><category><![CDATA[Google]]></category><category><![CDATA[install]]></category><category><![CDATA[mod_pagespeed]]></category><category><![CDATA[source]]></category><dc:creator><![CDATA[Wojtek]]></dc:creator><pubDate>Wed, 17 Nov 2010 11:48:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>I&#x2019;m not going to write about whether I think mod_pagespeed is good or not, is it suitable for your website, why you should use it or not. I&#x2019;ll focus only on installation and configuration.</p>
<p>Since you&#x2019;re here and still reading I assume you want to speed up your website with <a href="http://code.google.com/p/modpagespeed/">Google&#x2019;s mod_pagespeed</a>. If you&#x2019;re on a machine where for any reason installing from .rpm or .deb is not possible read on.</p>
<h3 id="dependencies">Dependencies</h3>
<p>First we need to install Chromium &#x2018;depot_tools&#x2019;, which are used to build multiple open-source projects with dependencies on other open-source projects.</p>
<pre><code class="language-bash">mkdir ~/bin cd ~/bin svn co http://src.chromium.org/svn/trunk/tools/depot_tools
</code></pre>
<p>You will need to add the depot_tools to your path. i.e. in bash:</p>
<pre><code class="language-bash">export PATH=$PATH:~/bin/depot_tools
</code></pre>
<h3 id="checkoutmod_pagespeedanddependencies">Check out mod_pagespeed and dependencies</h3>
<pre><code class="language-bash"># make a directory, any directory is fine
mkdir ~/mod_pagespeed
cd ~/mod_pagespeed
# always check for latest version by going to http://modpagespeed.googlecode.com/svn/tags/ in your browser
# then copy link to /src ie. http://modpagespeed.googlecode.com/svn/tags/X.X.X.X/src
# this will download all source code
gclient config http://modpagespeed.googlecode.com/svn/tags/0.9.1.1/src gclient sync --force
</code></pre>
<h3 id="compilemod_pagespeed">Compile mod_pagespeed</h3>
<p><code>BUILDTYPE</code> defaults to &apos;Debug&apos;, but we need a production ready build</p>
<pre><code class="language-bash">cd ~/mod_pagespeed/src make BUILDTYPE=Release
</code></pre>
<h3 id="installmod_pagespeed">Install mod_pagespeed</h3>
<p>First edit <code>centos.sh</code> and change parameters according to your needs. Then run it.</p>
<pre><code class="language-bash">vim install/centos.sh
cd install
./centos.sh
./centos.sh staging
./centos.sh install
</code></pre>
<h3 id="restartapache">Restart Apache</h3>
<pre><code class="language-bash">/etc/init.d/httpd restart
</code></pre>
<p>Check if Apache loaded mod_pagespeed.</p>
<pre><code class="language-bash">httpd -M # list static and shared modules, mod_pagespeed should be here
httpd -l # list compiled in modules
</code></pre>
<p>If above doesn&#x2019;t work try something like this:</p>
<pre><code class="language-bash">/usr/src/httpd/httpd -M
/usr/src/httpd/httpd -l
</code></pre>
<p>If mod_pagespeed is there, go to <code>/etc/httpd/pagespeed.conf</code> and configure it. I&#x2019;ll write a bit more about configuring mod_pagespeed in my next post. If it&#x2019;s not there make sure <code>mod_pagespeed.so</code> is in Apache module directory and if not copy it there.</p>
<pre><code class="language-bash">locate mod_pagespeed.so
cp /tmp/mod_pagespeed.install/mod_pagespeed.so /usr/local/apache2/modules/
</code></pre>
<p>Edit your Apache configuration file and add <code>Include /etc/httpd/pagespeed.conf</code> if it isn&#x2019;t already there.<br>
Next edit <code>/etc/httpd/pagespeed.conf</code> and add below line</p>
<pre><code class="language-bash">LoadModule pagespeed_module /usr/local/apache2/modules/mod_pagespeed.so
</code></pre>
<p>Restart Apache and you should see something like <code>X-Mod-Pagespeed: 0.9.1.1-173</code> in your website&#x2019;s response headers.</p>
<h3 id="references">References:</h3>
<p><a href="http://code.google.com/speed/page-speed/docs/using_mod.html">http://code.google.com/speed/page-speed/docs/using_mod.html</a><br>
<a href="http://code.google.com/p/modpagespeed/wiki/HowToBuild">http://code.google.com/p/modpagespeed/wiki/HowToBuild</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Gmail's recent email rendering change]]></title><description><![CDATA[<!--kg-card-begin: markdown--><h3 id="problem">Problem</h3>
<p>Gmail recently made a few changes in their email rendering engine. Unfortunately for us our image based HTML newsletters that used to look fine in gmail are now broken. Each image seems to have a weird spacing after it.<br>
If you&#x2019;ve been sending HTML newsletters for your</p>]]></description><link>https://allurcode.com/gmails-recent-email-rendering-change/</link><guid isPermaLink="false">5b7b0aa2b52b43084c9ea122</guid><category><![CDATA[CSS]]></category><category><![CDATA[email]]></category><category><![CDATA[gmail]]></category><category><![CDATA[Google]]></category><category><![CDATA[HTML]]></category><category><![CDATA[image]]></category><category><![CDATA[spacing]]></category><dc:creator><![CDATA[Wojtek]]></dc:creator><pubDate>Tue, 01 Jun 2010 10:14:28 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><h3 id="problem">Problem</h3>
<p>Gmail recently made a few changes in their email rendering engine. Unfortunately for us our image based HTML newsletters that used to look fine in gmail are now broken. Each image seems to have a weird spacing after it.<br>
If you&#x2019;ve been sending HTML newsletters for your clients for some time now, you probably have your own email templates that work well in all email clients. Well not anymore thanks to Google.</p>
<h3 id="solution">Solution</h3>
<p>To make things back to what they were just add <code>style=&quot;display:block;&quot;</code> to every img tag in your HTML email and we&#x2019;re back in business.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Google font api and font directory]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Google just made our life much easier by announcing <a href="http://code.google.com/apis/webfonts/">Google font api</a> and <a href="http://code.google.com/webfonts">Google font directory</a>.<br>
Using custom fonts on your website is as easy as adding two lines of code. Lets consider this simple example.</p>
<pre><code class="language-html">&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;title&gt;Custom</code></pre>]]></description><link>https://allurcode.com/google-font-api-and-font-directory/</link><guid isPermaLink="false">5b7b0aa2b52b43084c9ea120</guid><category><![CDATA[api]]></category><category><![CDATA[CSS]]></category><category><![CDATA[font]]></category><category><![CDATA[Google]]></category><category><![CDATA[HTML]]></category><category><![CDATA[Tangerine]]></category><dc:creator><![CDATA[Wojtek]]></dc:creator><pubDate>Sun, 23 May 2010 12:08:36 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Google just made our life much easier by announcing <a href="http://code.google.com/apis/webfonts/">Google font api</a> and <a href="http://code.google.com/webfonts">Google font directory</a>.<br>
Using custom fonts on your website is as easy as adding two lines of code. Lets consider this simple example.</p>
<pre><code class="language-html">&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;title&gt;Custom fonts&lt;/title&gt;
    &lt;meta charset=&quot;utf-8&quot; /&gt;
    &lt;style&gt;
      p {
        font-size: 48px;
      }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;p&gt;Hello world!&lt;/p&gt;
    &lt;/header&gt;
&lt;/body&gt;
</code></pre>
<p>Nothing fancy here, result as expected:</p>
<p>Hello world!</p>
<p>Now lets add those two aforementioned lines. Line 6 and line 9 in below listing.</p>
<pre><code class="language-html">&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;title&gt;Custom fonts&lt;/title&gt;
    &lt;meta charset=&quot;utf-8&quot; /&gt;
    &lt;link href=&apos;http://fonts.googleapis.com/css?family=Tangerine&apos; rel=&apos;stylesheet&apos; type=&apos;text/css&apos;&gt;
    &lt;style&gt;
      p.tangerine {
        font-size: 48px;
        font-family: &apos;Tangerine&apos;, serif;
      }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;p&gt;Hello world!&lt;/p&gt;
    &lt;/header&gt;
&lt;/body&gt;
</code></pre>
<p>and the effect:</p>
<link href="http://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet" type="text/css">
<style>
  p.tangerine {
    font-size: 48px;
    font-family: 'Tangerine', serif;
  }
</style>
<p class="tangerine">Hello world!</p>
<p>The font directory is a bit limited at the moment but I think we can safely assume that Google will be adding more fonts over time.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>