Nuffnang down time

This morning, Nuffnang server seems to be down.

Top banner

Top banner

[function.mysql-connect] = http://synad2.nuffnang.com.my/function.mysql-connect

Between post

Between post

Spread/Promote this post.

Digg | Del.icio.us | Stumble | Mixx | Reddit | Email This Post | Print This Post

Komodo Edit save and run python macro

Komodo Edit is a good editor for many programming language. However, since it is free as compared to its brother Komodo IDE, there is lack of debugging function.

But, Macro and run command do exist though. You can make use of those feature to save and debug your script with a click of a shortcut key.

Step 1: Create a new macro.
Add New Macro

Step 2: Enter the macro script below.

1
2
3
if (komodo.view) { komodo.view.setFocus() };
komodo.doCommand('cmd_save')
ko.run.runEncodedCommand(window, '%(python) \"%F\" {\'cwd\': u\'%D\'}');

You are free to change %(python) to %(perl), provided that perl is installed, and the environment path is set.

Enter the macro script

Step 5: Set a key binding to the new created macro.

Set a shortcut key

Now you just need to press the ‘F5′ key inorder to save and run a python script.

Spread/Promote this post.

Digg | Del.icio.us | Stumble | Mixx | Reddit | Email This Post | Print This Post

Wordpress: Display posts by categories

This function could be used to display all categories and their posts. One example of its usage is for the Archive page.

To use it copy and paste the function into the file “functions.php” located inside the “wp-content\themes\your theme” folder. You may have to create that file if it does not exist yet.

To call the function, use posts_by_cats(3), where 3 is the number of post to be displayed in each category.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
This funtion will display posts for each parent categories
*/
function posts_by_cats($num_of_posts) {
    global $wpdb;
 
    // query the cat id
    // remove `parent` = 0 to display all categories
    $sql = "SELECT `term_id` FROM $wpdb->term_taxonomy WHERE `taxonomy`='category' AND `parent` = 0 AND `count` != 0";
    $cats = $wpdb->get_results($sql, ARRAY_A);
 
    //display posts for each cat
    foreach ($cats as $cat) {
      $cat_id = $cat['term_id'];
 
      // query the cat name
      $sql = sprintf("SELECT `name` FROM $wpdb->terms WHERE `term_id`=%d", $cat_id);
      $cat_name = $wpdb->get_var($sql);
 
      echo '<p>';
      echo '<h3><a href="'. get_category_link($cat_id) . '">' . $cat_name . '</a></h3>';
 
      // query all the posts for each cat
      query_posts(sprintf("cat=%d&showposts=%d", $cat_id, $num_of_posts));
 
      // the loop
      if (have_posts()) :
          echo "<ul>";
          while(have_posts()) : the_post();
  ?>
              <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  <?php  
          endwhile;
          echo '<li><a href="'. get_category_link($cat_id) . '">(more)</a></li>';
          echo "</ul>";
      endif;
      echo "</p>";
    }
}
 
?>

Spread/Promote this post.

Digg | Del.icio.us | Stumble | Mixx | Reddit | Email This Post | Print This Post

LaTeX special characters

Special symbols

Character Command Description
§ \S section sign
\dag dagger
\ddag double dagger
\P pilcrow sign (paragraph)
© \copyright copyright sign
£ \pounds Pound sign

Printing command characters

Character Command Description
$ \$ dollar sign
& \& ampersand
% \% percent sign
# \#  
_ \_ underscore
{ \{ opening curly brace
} \} closing curly brace

European letters

Character Command Description
œ {\oe} latin small ligature oe
Œ {\OE} latin capital ligature OE
æ {\ae} latin capital ligature ae
Æ {\AE} latin small ligature AE
å {\aa} latin small letter a with ring above
Å {\AA} latin capital letter A with ring above
Ø {\o} latin capital letter O with stroke
Ø {\O} latin small letter o with stroke
ß \ss sharp S
¿ ?` inverted question mark
¡ !` inverted exclamation mark

Accents (diacritic marks)

Character Command Description
ò \`{o} with grave
ó \’{o} with acute
ô \^{o} with circumflex
ö \”{o} with umlaut
õ \~{o} with tilde
  \={o} with macron
  \.{o} with a dot above
  \u{o} with breve
  \v{o} with caron
  \H{o} with double acute
  \d{o} with a dot below
o \b{o} with an underline

Note: You can replace o with the desired character.

Spread/Promote this post.

Digg | Del.icio.us | Stumble | Mixx | Reddit | Email This Post | Print This Post

Executing Python Code Within Komodo Edit

Komodo Edit is a good free editor for Python development. However, there is no debugging feature in Komodo Edit. Therefore, it is a cumbersome process to execute Python scripts. Fortunately, there is a feature called Run command to satisfy this job.

To make use of the Run command feature to execute Python code, you can follow these steps:

  1. click Toolbox > Add > New Command.
  2. type “Run Python file” in the top field.
  3. enter
    %(python) “%F”
    in the command field.
  4. Click on the “Key Binding” tab and you can set the keyboard shortcut key (optional). I personally like the F5 key.
  5. Click OK.

komodo

Now, you can easily execute the Python script by pressing “F5″, or by double clicking the “Run Python file” in your toolbox pane, which is usually located at the right. The output will be displayed in the Command output pane at the bottom.

For more information on the “Run Command”:

http://aspn.activestate.com/ASPN/docs/Komodo/4.4/run.html

 

Spread/Promote this post.

Digg | Del.icio.us | Stumble | Mixx | Reddit | Email This Post | Print This Post