Showing posts with label Tips And Tricks. Show all posts
Showing posts with label Tips And Tricks. Show all posts

Friday, October 14, 2011

Enabling proxy under Debian



In order to enabled a proxy, there's two main places (at least for my use this did the trick, there's probably are others). The first one is simple defining the following variables:
export http_proxy="http://your.proxy.com:your_port"
export ftp_proxy="http://your.proxy.com:your_port"

Secondly in order to have apt-get work through proxy, you need to update /etc/apt/apt.conf.d/proxy (or create it):
Acquire::http::Proxy "http:///your.proxy.com:your_port";



Friday, May 6, 2011

Thumbnails for Videos

I recently installed a web gallery to host photos and videos named Zenphoto. It works perfectly to my taste except for a small detail. Video galleries load a flash player named flowplayer, which does the job nicely, but until you click on the actual video to make the flash player load, you can't see a thumbnail of the video.

 The solution to have thumbnails for videos in Zenphotos, the same way you have for photos, is to place a jpg with the same name as the video. For instance if you have a video named a.mp4, create a jpeg named a.jpg in the same folder as the video. This photo will be used as thumbnail for you video.

It's fine to do a few manually ... but call me lazy I don't fancy the extra manual step each time I need to add a new video. So a create a little script to generate the thumbnails. 


Before digging in the details, it assumes a few things. First this only works under linux, so you must not be afraid of command line. Secondly it relies on ffmpeg to extract a frame automatically.

If you don't have ffmpeg and you're using an Ubuntu / Debian type:


Then you into the folder under which the videos are and type:

And paste the following content into the file:

Run the script and you're done.

Sunday, October 18, 2009

How to get Adsense ads more relevant to your site content

Adsense is a great tool to generate revenue on your pages, and very easy to use. A couple of click and editing into your site or blog (widget installation maybe), and you're good to go.

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 == &quot;item&quot;'>

<div class='similiar'>

 <div class='widget-content'>
  <div id='relatedPosts' /> <br/>
  <div expr:id='&quot;relatedPosts_&quot; + data:post.id'/> <br/>

  <script type='text/javascript'>

  var blogURL = &quot;<data:blog.homepageUrl/>&quot;;
  var maxNumberOfLabels = 10;
  var nPost = 0;
  var maxPosts = 5;
  var numLabel = 0;
  var receivedResult = 0;

  var outputDone = false;

  var txt = document.createTextNode(&quot;You may also want to read:&quot;); 
  var ul = document.createElement(&#39;ul&#39;);
  var labelRelatedPost = document.createElement(&#39;h3&#39;);
  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 &lt;= RemainingPosts) ? json.feed.entry.length : RemainingPosts;

   for (var i = 0; i &lt; 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 &lt; entry.link.length; k++) {
      if (entry.link[k].rel == &#39;alternate&#39;) {
       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(&#39;li&#39;);
       var a = document.createElement(&#39;a&#39;);
       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 &amp;&amp; nPost &gt; 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(&#39;h5&#39;);
      var em = document.createElement(&#39;em&#39;);
      var a = document.createElement(&#39;a&#39;);
      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 &lt; postsFound.length;i++)
   {
    if(postsFound[i] == postURL) 
    {
     return true;
    }
   }
   postsFound[postsFound.length] = postURL;
   return false;
  }

  function searchQuery(query, label) {

   var script = document.createElement(&#39;script&#39;);


   var xhr = new XMLHttpRequest();
   xhr.onreadystatechange = function() {

    if (xhr.readyState == 4) {
     // Your callback code goes here
     listEntries(xhr.responseText, &quot;<data:post.id/>&quot;);
    }
   }
   xhr.open(&#39;GET&#39;, query+ &#39;feeds/posts/default/-/&#39; + label + &#39;?alt=json&#39; , true);
   xhr.send(null);
  }



  <b:if cond='data:post.labels'>
  <data:postLabelsLabel/>
  <b:loop values='data:post.labels' var='label'>
  var textLabel = &quot;<data:label.name/>&quot;
  //alert(textLabel);
  if (numLabel &lt; 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)
Not bad heh ;) And there are much much more which haven't made they way to the official package.

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 &lt;.

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

I don't know you, but my dad came to computer in the recent year, and it's not as natural to him as to people of my generation. So naturally whenever he has a problem he usually ask me. Unfortunatly sometimes, it's very hard either to understand either is problem, or to explain him the solution.

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 :


The first button is for you dad (the person of which you want to control the PC) and the second one for the person helps. When you dad clicks on the button it'll give him a code that you will need when you click on your. After you are both connected you will be connected in view only mode. Advantage of this mode is that your dad will see where and how many times you click. You also have the possibility to take full control of the computer. Your dad has to click on the of Spark Angel nearin the task tray and click on control panel, to change the control mode to "Controle Total" and Tadam ...

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...

Latetly I had to reinstall Nero on a new computer. I didn't had to do that for a long time. I know things change quickly in IT world, but not that quickly and Nero is still the best software around to burn CD.


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 some tricks that can help in daily work with oracle. Very often, I need to extract query result from Oracle, or to be more precise ask people to send me query results. It is quite easy to save a file, that's very true but the formatting is excruciatingly unreadable. There's a flurry of tools that can allow you to export your query, but sometimes the only things you have at end because you're connecting to production environment is a good old Sql*Plus.

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 &gt; 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?"

Blogger Settings

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

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