g0's disqus on Blogger ghetto hack

1) I like showing whole posts --not just snippets-- on the front page of aLog --I know I am weird.

2) I don't like disqus comments popping on the front page, the show older, and the search (blog/search* ) pages that show more than a Post. ( example )

3) It is OK for the IPduh Tools page to show disqus comments ( for now ).

4) I also want a Link on every post saying Comment showing up on every page of the blog that I don't want disqus comments. ( huh! confusing? remember 2? )

There must be some political correct way of doing that on Blogger. One that most probably would require me browsing through half the Internet to find. Here is my "it took a whole 20 minutes to put together and takes less than 5 min to install and works just exactly as I wanted it" shot at it.

The template needs a javascript include in the head. Something like the following:
<script src='http://kod.ipduh.com/js/alogjs.js' type='text/javascript'></script>
This way someone who does not have some other place to host the js is screwed. Bummer indeed and I tried to put all the javascript in the Blogger template but I could not use any && there, and after I spent more than 5 min trying to figure out what is wrong and then tried to encode && a couple of different ways with no success I gave up. Hmm! it just hit me! One could use nested ifs to avoid && and that should be fine for the Blogger template.

Something like the following should be put in the Template where you want to put the disqus comments:
<a name='comment'> </a> <div id='disqus_thread'></div>
<script type='text/javascript'>

The alogjs.js looks like that:
/*g0 2012 for alog.ipduh.com --http://ipduh.com/contact */

var disqus_shortname ='thealog'; // set your disqus forum shortname
var blog='alog.ipduh.com'; // set this too

function put_disqus() 

var blog_url='http://'+blog+'/';
var regex_str='http:\/\/'+blog+'\/search';
var searchregex=new RegExp(regex_str,"i");

if (window.location.href.toString() != blog_url.toString() && !searchregex.test(window.location.href.toString()) )
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);


function print_comment_link(path) 

if(window.location.pathname.toString() != path.toString() ) 
document.write('<a href="http://'+blog+path+'#comment">Comment</a>');

Replace the if statement in put_disqus() with nested ifs if you want to put this code in the Blogger template and having issues with the AND ( && ) operator.

and then put on the bottom of every post something like the following:
<script type="text/javascript" language="javascript">
Yeah , I looked (not very hard ) through this template's variable names to find the path but not cigar. So I am setting it manually for each post for now.

That's all folks.

g0's disqus on Blogger ghetto hack

New Stuff

The URL Bouncer is a go. Currently it checks IPv4 addresses contained in URIs against IPv4 Black Lists and Domain Names contained in URIs against the Google Safe Browsing Lists. The Bouncer will construct HTTP URIs from plain IPv4 addresses , plain IPv6 , and plain DNS Domain Names. Use it to link to everything :), blank your referral , or whatever. Soon an option will enable all IPduh list makers ( ip/list , dns/list , demux/list ) to put URL Bouncer links to all their listed items. ( and then they will be really useful )

Also demux/class got a tiny bit smarter. Now it knows what a URI is as well.

new stuff

chm to html

g0:~/ebooks$ sudo apt-get install libchm-bin

g0:~/ebooks$ extract_chmLib 
usage: extract_chmLib <chmfile> <outdir>

g0:~/ebooks$ mkdir APinTheUnixEnv
g0:~/ebooks$ extract_chmLib APinTheUnixEnv.chm APinTheUnixEnv



Done working on demux and demux/class which will help many of my Internet Structure Challenged Friends and Family members and hopefully guide stray 404s ( http://ipduh.com/example.net ).

I also concluded on the syntax for the IPduh list creators ( ip/list , dns/list , demux/list )
which could be used to create and bookmark lists more important than this:
"funny" IPv6 addresses List

g0 1342191971

1342191971 ... funny IPv6

syntax highligted source code snippets in HTML

Add syntax highlighted source code snippets in HTML documents.

In Vim

TOhtml is a standard plugin and produces source code snippets in HTML that look like the syntax highlighting in Vim.

By default :TOhtml produces (good to inline ) source code snippets that look like this:

/*#g0 hi.c*/
#include <stdio.h>
#include <stdlib.h>

int main()
  printf ("Hola %s.\n", getenv("USER"));
  return 0;

syntax highligted source code snippets in HTML

and HTML source code that looks like:

<font face="monospace">
<font color="#8080ff">/*</font><font color="#8080ff">#g0 hi.c</font><font color="#8080ff">*/</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;stdio.h&gt;</font><br>
<font color="#ff40ff">#include </font><font color="#ff6060">&lt;stdlib.h&gt;</font><br>
<font color="#00ff00">int</font>&nbsp;main()<br>
&nbsp;&nbsp;printf (<font color="#ff6060">&quot;Hola </font><font color="#ff40ff">%s</font><font color="#ff6060">.</font><font color="#ff40ff">\n</font><font color="#ff6060">&quot;</font>, getenv(<font color="#ff6060">&quot;USER&quot;</font>));<br>
&nbsp;&nbsp;<font color="#ffff00">return</font>&nbsp;<font color="#ff6060">0</font>;<br>

which is very easy to use within another HTML document.

To produce a snippet from a section of code use
where n is the first line code and m the last line of source code you want to HTMLify.

To produce HTML source code with CSS enable it with
:let html_use_css = 1

:TOhtml with html_use_css enabled produces great looking highlighted source code snippets that look like:

and HTML that looks like:

HTML source code snippets with CSS can be 'inlined' in an HTML document with an iframe eg:

<iframe src="http://kod.ipduh.com/alogsup/hi.c.html"></iframe>

If a site contains many snippets of the same language it would be better to use an external style-sheet and just inline the pre blocks in HTML.

To add number lines in your source snippets
:let html_number_lines = 1

To learn more about converting source code to HTML in Vim use:
:help 2html


GNU Source-highlight is a nice piece of software that highlights source code and produces HTML among other outputs. Source-Highlight is a library and a standalone program that it is easy to use. Many Source highlighting capable programs use Source-Highlight one way or another. -- src-highlite

In debian based systems you could:
$ sudo apt-get install source-highlight
$ source-highlight -s c hi.c
Processing hi.c ... created hi.c.html

Source-highlight produces by default great looking source code snippets that look like this:

/*#g0 hi.c*/
#include <stdio.h>
#include <stdlib.h>

int main()
  printf ("Hola %s.\n", getenv("USER"));
  return 0;

and HTML source code with no CSS that looks like

<pre><tt><i><font color="#9A1900">/*#g0 hi.c*/</font></i>
<b><font color="#000080">#include</font></b> <font color="#FF0000">&lt;stdio.h&gt;</font>
<b><font color="#000080">#include</font></b> <font color="#FF0000">&lt;stdlib.h&gt;</font>

<font color="#009900">int</font> <b><font color="#000000">main</font></b><font color="#990000">()</font>
<font color="#FF0000">{</font>
  <b><font color="#000000">printf</font></b> <font color="#990000">(</font><font color="#FF0000">"Hola %s.</font><font color="#CC33CC">\n</font><font color="#FF0000">"</font><font color="#990000">,</font> <b><font color="#000000">getenv</font></b><font color="#990000">(</font><font color="#FF0000">"USER"</font><font color="#990000">));</font>
  <b><font color="#0000FF">return</font></b> <font color="#993399">0</font><font color="#990000">;</font>
<font color="#FF0000">}</font>

which is easy to inline

Online Services

People allergic to Vim or the command line could use an online service to produce the HTML and store their snippets and just link to them. A few that rock:

pb.rbfh.de like in http://pb.rbfh.de/25y1ogkDJriCd

gist.github.com and public gists like this

CSS Containers used for the inline source code snippets at aLog.IPduh

The .code class

.code {
         font-size: 1em;
         padding: 0; margin: 0; 
         /*background: #F6F6F6; if yellow on white is hard to see */
         background: #FFFFFF;
         line-height: 20px;
         font-family: "Terminal" , "VT-100" , "System" , "monospace";
         /*width: 640px;*/ /*don't if you use a div hover pseudo class*/
         border: 1px solid black;

The div container and the hover pseudoclass

div.div {
        z-index: 2; /*no cigar*/
        border: 1px solid black;

div.div:hover {
         z-index: 2;/*fails in most templates*/

At aLog I use the .code class for sections of source code that are not very wide or I don't want them to expand on hover eg:

<pre class=code>
  source code snippet in html here

.code may be used in div containers as well.

For sections of source code with long lines that I want to be expanded at hover I use the following scheme.

<div class='div'>
    <pre class='code'>
        source code snippet in html with wide lines that I want them seen oooooon hoooooover


Javascript Source Highlighters

I would not use them in a blog or some code archive but I can see many cool uses for them.

One that I like is called SHJS, uses source-highlight language definitions and it is GNU licensed -- SHJS

My bad joke for the day

I am pretty sure that there is at least one emacs meta yoga finger exercise that HTMLifies source code while it takes out the trash and makes coffee.
But if you are an emacs user you already know it.

Hey, I love emacs users --If I was smarter I would use it too.

syntax highligted source code snippets in HTML