Friday, October 14, 2011
Enabling proxy under Debian
Friday, May 6, 2011
Thumbnails for Videos
Run the script and you're done.
Sunday, October 18, 2009
How to get Adsense ads more relevant to your site content
But you may have noticed that something the ads displayed on your site by Adsense, are not that relevant, it not totally out of it. The reason why this happens, is because, Adsense just like Google (the search engine side of the business ;) ) uses bots to crawl on your site and analyze its content. Up to here nothing that you wouldn't expect. The catch is, everything that is on your site may not always be relevant content, and those bots have no way to identify what is and what's not.
Naturally, the trick would be to be able to "guide" those bots in the right direction and clearly indicate the content they have to consider. This can be done with the help of two specific tags that you need to include into the code of your site. If you have a blog, that's around the body of your article, any part, box, div, etc.. that wraps what you want to be indexed. Those two tags are and .
The explanation that follow are a bit specific to blogger since that's what I'm using, but the general procedure is similar whatever the blog or site.
So in blogger you have to edit your template. If you don't know how to edit your template your can check this article. Now that you're editing your template you want to start searching the following:
<data:post.body>
And replace it with:
<!-- google_ad_section_start--> <data:post.body/> <!-- google_ad_section_end -->
Here you notice that we point for Adsense the content we want to be used for your ads. Now you want want to do the opposite instead, that is point to the sections you don't want to be considered. In order to do that you have to wrap the content to ignore the same way we wrapped the post's body above:
<!-- google_ad_section_start(weight=ignore)-->
Your content to ignore goes here
<!-- google_ad_section_end -->
And That's it. It is as simple as that. One important note is, the change in your ads won't be immediate, and it may take up to two weeks for the change to actually reflect in the content of your ads.
I hope this will be useful to you, don't hesitate to drop me a line if you that post helped you.
Wednesday, October 14, 2009
Related post plugin for blogger
Since I started using blogger, I've always wondered why this feature is not present by default. To me having a list of related post is very important, because that's a nice way to put forward more relevant content to you dear reader ;)
So i've search on internet, and found a flurry of so called plugin or widget. The most common one seems to have been written by Hoctro. But none of those never really satisfied me.
As a result I decided to write my own using a bit of Ajax query to make everything smooth and nice. The result is a plugin that display on articles pages (not on the front page for now) a list of post related to the current one. It is relying on the post labels and the google API to display thoses.
And here it is:
<b:if cond='data:blog.pageType == "item"'>
<div class='similiar'>
<div class='widget-content'>
<div id='relatedPosts' /> <br/>
<div expr:id='"relatedPosts_" + data:post.id'/> <br/>
<script type='text/javascript'>
var blogURL = "<data:blog.homepageUrl/>";
var maxNumberOfLabels = 10;
var nPost = 0;
var maxPosts = 5;
var numLabel = 0;
var receivedResult = 0;
var outputDone = false;
var txt = document.createTextNode("You may also want to read:");
var ul = document.createElement('ul');
var labelRelatedPost = document.createElement('h3');
labelRelatedPost.appendChild(txt);
var postsFound = [];
function listEntries(result, postID)
{
var json = JSON.parse(result);
receivedResult = receivedResult+1;
// calculate the number of remaining post to add to the list
var RemainingPosts = (maxPosts - nPost);
var nPostToParse = (json.feed.entry.length <= RemainingPosts) ? json.feed.entry.length : RemainingPosts;
for (var i = 0; i < RemainingPosts; i++) {
var entry = json.feed.entry[i];
if(entry)
{
var postURL;
var title = entry.title.$t
// parse the link array to find the post URL
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
postURL = entry.link[k].href;
break;
}
}
// check the post is not the same as the current post
if (postURL != location.href)
{
if (postAlreadyKnown(postURL) == false)
{
nPost++;
//alert("Other post found "+nPost);
var li = document.createElement('li');
var a = document.createElement('a');
var txt = document.createTextNode(entry.title.$t);
a.href = postURL;
a.appendChild(txt);
li.appendChild(a);
ul.appendChild(li);
}
}
}
}
// check if everything's been received
if (receivedResult == numLabel ) {
if (outputDone == false && nPost > 0)
{
outputDone = true;
var relatedPostSection = 'relatedPosts_'+postID;
var relatedDiv = document.getElementById('relatedPosts_'+postID);
if (relatedDiv) {
relatedDiv.appendChild(labelRelatedPost);
relatedDiv.appendChild(ul);
//
var providedBy = document.createElement('h5');
var em = document.createElement('em');
var a = document.createElement('a');
a.href = "http://xiuxixiuxi.blogspot.com/2009/10/related-post-plugin-for-blogger.html"
var txt = document.createTextNode("Provided by XiuxiXiuxi");
a.appendChild(txt);
em.appendChild(a);
providedBy.appendChild(em);
relatedDiv.appendChild(providedBy);
}
}
}
}
function postAlreadyKnown(postURL) {
for(var i= 0; i < postsFound.length;i++)
{
if(postsFound[i] == postURL)
{
return true;
}
}
postsFound[postsFound.length] = postURL;
return false;
}
function searchQuery(query, label) {
var script = document.createElement('script');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
// Your callback code goes here
listEntries(xhr.responseText, "<data:post.id/>");
}
}
xhr.open('GET', query+ 'feeds/posts/default/-/' + label + '?alt=json' , true);
xhr.send(null);
}
<b:if cond='data:post.labels'>
<data:postLabelsLabel/>
<b:loop values='data:post.labels' var='label'>
var textLabel = "<data:label.name/>"
//alert(textLabel);
if (numLabel < maxNumberOfLabels) {
searchQuery(blogURL, textLabel);
numLabel++;
}
</b:loop>
</b:if>
</script>
</div>
</div>
</b:if>
Now where to put that code. You need to edit your blog layout.To do that, go to your blogger dashboard and click on "Layout", click on "Edit HTML", and click on "Expand Widget Templates". Now search for:
<data:post.body>
and paste the code above just after that.
And your done.
Sunday, October 11, 2009
Code Syntax Highlingting plugin
If you post any source code on your blog (site) and want to have some syntax highlighting like this on your website then this posts is for you:
alert("Hello World");
// Example of code
I will concentrate here on how to set it up for blogger but it's basically vadid for any website. More details on that at the end of the post. But let's talk about the plugin a bit.
Supported Languages
This plugin at the time I'm writing this article supports the following languages:- ActionScript3
- Bash/shell
- C#
- C++
- CSS
- Delphi
- Diff
- Groovy
- JavaScript
- Java
- JavaFX
- Perl
- PHP
- Plain
- PowerShell
- Python
- Ruby
- Scala
- SQL
- Visual Basic
- XML (as well as xslt, html, xhtml)
Installing the plugin
In order to set this up you will have to edit your template layout. To do that, go to your blogger dashboard and click on "Layout" and then click on "Edit HTML", and search for:]]></b:skin>
and paste the following code.
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"> <link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'/> <!-- add brushes here --> <script type='text/javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.all(); </script>
Using the plugin
Once you've completed previous step, all you have to do is to start writing a post, and when you have to put some code, switch to the "Edit HTML" tab and use pre tags as follow:<pre class="brush: js"> <!-- Your code goes here --> </pre>
You need to change the language code (in this case js) to match the language you want to highlight.
Make sure to replace all instances of < with <.
Don't worry if your text looks funny in the "Compose" tab, it's going to be fine when you few the post normally.
Where to know more about it:
This little baby is named SyntaxHighlighter ans it is the fruit of several years of Alex Gorbatchev efforts. You can find more on his website. You will find there the full list of scripts you can include to get syntax highlighting for different languages. There's also different theme css.I hope this will be useful to you as well.
Wednesday, September 10, 2008
How to help your dad with his computer from 2000 miles away with Spark Angels
In those situation, the best way would actually to stand beside him and show him how to do whatever he needs to do. Unfortunatly the current low of physics do not allow me to teleport, so I'd have to fly for about 15 hours ... which needless to say is not doable.
At that point I can hear some of you thinking, "Yeah that's easy, just install a remote control program". Yeah it is easy, except that when you need it, usually you don't have it installed in the first hand. And plenty of technical problem can arise (port forward, firewall ...).
So if you ever encounter that kind of situation when you need to take control of you dad (or mom ;)), there's a very nifty program called Spark Angel. What so great about this program ? Well first you have nothing to configure. All he has to do is go to this address. The program itself is in Java, so you can take control of his computer, even if you have a Mac and he has got a PC. The only problem is the software itself is in French... but it's so simple this is not a problem. I would say it's going to be translated sooner or later (from the option menus) :

Anyway, then when it launches it will ask him he has to accept the usual licence stuff. After that you will come to the normal starting screen where you have two buttons :

It does the job pretty well at least for me. I hope this will help you as well.
Thursday, August 28, 2008
Installing lite version of nero in 5 minutes...
But what has change is the size and pain to install Nero. It's so bloated now that it takes more than 800Mb to get a version of Nero, which is needless to say completely overkill to me. I just needed to burn a CD to back up photos from my holidays.
After rumbling around a little bit on the web, i found a very nice effort by a person who's website is here. You will find there two different installations that weight less than 30Mb (which is a piece of cake to download), one for the latest 7.x and the other one for 8.x. Both of them are suitable for Vista which is a plus (because earlier version of 7.x version of Nero did not work under Vista).
I suppose for sake of saving traffic on his website the files are hosted on a third party site called iFile.it. For those who wonder where to click to download the file, you have to click on the "Request download ticket" button roughly in the middle of the page.
For those who wonder, this installation doesn't wave any legal license requirement, it just makes the installation quicker and easier. You still have to purchase a valid license if you don't already have one.
Wednesday, June 4, 2008
How to save query from oracle in HTML
Here's the trick. Connect to your DB using Sql*Plus and used the following actions:
SET markup HTML on spool test.html SELECT * FROM mytable; spool off SET markup HTML off
When you type command "SET markup HTML on", your command prompt will look "funky" don't worry it is perfectly normal. After you exit you will find a nice html file. Certainly not the best format, but much more readable than plain 80 column text.
Sunday, June 1, 2008
How to get your site/blog referenced by Google (and other search engine)
I've seen a log of people asking themselves, why their blog/site is not yet referenced by a search engine. So here's a little little of the things you can do.
Basically what you need to do is to tell the search engine that you exist, because Internet is HUGE, and there's site popping everywhere every seconds, and they have no way to actually know that you exist (and want to be found).
First if you're using a blog, and specifically your Blogger blog, there's a few settings you need to tweak.
- Go to your Dashboard and then Settings > Basic.
- Make sure your setting look like mine, especially for "Add your blog to our listings?" as well as "Let search engines find your blog?"
Now, the following instruction are true for ANY kind of website, not just a blog.
Getting referenced by Google :
- Go here and fill the form.
- It's done... nothing more to do.
Now that we've done Google, which we can say is probably the most used search engine theses days, it doesn't hurt to get also referenced by other search engine.
Getting referenced by Yahoo
- First thing you can do is check if they already know about your site : Yahoo SiteExplorer
- Go here, and fill the form just like for Google.
- Tada... it's done
Getting Referenced by LiveSearch
- Fill this form
Now with those three, you've got the most commonly used search engine. Well this is partially true. I should say you have covered the most commonly used search engine in the Western world. If you want to toss some more change to have you site visited by Chinese citizen, use the following :
While you're at it you can get your site referenced by Indian search engine :
Now this time I think we are in good shape, and got most of the world covered. That being said, although those search engine are the most used ones, they are still general purpose search engine. If your site/blog is targeting a very specific audience, then you might want to get referenced in specialized search engine.
Also there's something you need to keep in mind, is that there's no better search engine than 'Word to Mouth' ... so try to have people talk/link to your site.
Finally if your site is a commercial one, or you REALLY want to get some traffic, then you might want to invest into Paid search advertising. There's a good article here about it. Most of the search engine above offer such kind of services.
Alex