Ansermot.ch Another computer sciences blog….

3août/100

Convert file to utf-8 on Unix based OS

A little snippet that I needed today. I didn't found what I needed so I wrote it.

  1. cp originalFile backupFile
  2. iconv -f fromEncoding -t utf-8 originalFile > originalFile

Cheers :)

3mar/100

JS – setInterval tip

You want to use the Javascript function setInterval() but you dont know how ?
Or you tried but it doesn't work ?

I think you do the thing like this :

var timerId = setInterval('myFunction', 200);

but it doesn't works.
Try like this :

var timerId = setInterval(function() { myFunction(); } , 200);

Hope this snippet helps you.
See ya !

19fév/100

jQuery – Element exists ?

Here's a very small snippet about how to know if a Dom element is on the document with jQuery

  1. var myElement = $('#myElement');
  2. if (myElement.size() == 0) {
  3. // Element doesn't exists
  4. } else {
  5. // Element exists
  6. }
8fév/100

FsCharts – Goals for 1.1.0

I'm currently working on the version 1.1.0, with new usable features.

Here're major the goals :

  • Localisation
  • Widget configuration panel
  • Display of visits on the chart

Take a look too on the svn for the development version if you're interested. I regulary commit the sources

2déc/090

Including JS and CSS in WP Header

Lot of people add Javascript and Css file by "echoing" them from theyre extension.
WordPress allow you to add correctly them to the page's head by using two functions :

  1. // Add a new script file
  2. wp_enqueue_script($handle, $src, $deps, $ver, $in_footer);
  3. wp_enqueue_script('jsfoo', '/wp-content/plugins/myplugin/JS/foo.js');
  4.  
  5. // Add a new stylesheet
  6. wp_enqueue_style($handle, $src, $deps, $ver, $media);
  7. wp_enqueue_style('main', '/wp-content/plugins/myplugin/main.css');

For more informations :
wp_enqueue_style();
wp_enqueue_script();