Google Code Prettify and WordPress plugin

Google Code Prettify enable syntax highlight to source code in HTML page. In WordPress you can use Simple Code Highlighter plugin.

To use the Google Code Prettify plugin, place your code within a <pre> text block, and then specify the class of the block as “prettyprint”.  To do this, switch to Text mode within the WordPress editor.

You can use pre tag and class=”prettyprint” attribute to your code

// your code here

Here are some examples:

Default

Many
lines
of
code

Default with line numbers

Many
lines
of
code

Java

class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Prints the string to the console.
    }
}

Python

class SchoolMember:
    '''Represents any school member.'''
    def __init__(self, name, age):
        self.name = name
        self.age = age
        print('(Initialized SchoolMember: {})'.format(self.name))

    def tell(self):
        '''Tell my details.'''
        print('Name:"{}" Age:"{}"'.format(self.name, self.age), end=" ")


class Teacher(SchoolMember):
    '''Represents a teacher.'''
    def __init__(self, name, age, salary):
        SchoolMember.__init__(self, name, age)
        self.salary = salary
        print('(Initialized Teacher: {})'.format(self.name))

    def tell(self):
        SchoolMember.tell(self)
        print('Salary: "{:d}"'.format(self.salary))


class Student(SchoolMember):
    '''Represents a student.'''
    def __init__(self, name, age, marks):
        SchoolMember.__init__(self, name, age)
        self.marks = marks
        print('(Initialized Student: {})'.format(self.name))

    def tell(self):
        SchoolMember.tell(self)
        print('Marks: "{:d}"'.format(self.marks))

t = Teacher('Mrs. Shrividya', 40, 30000)
s = Student('Swaroop', 25, 75)

# prints a blank line
print()

members = [t, s]
for member in members:
    # Works for both Teachers and Students
    member.tell()

Node.js

var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World!');
}).listen(8080);

Testando o WP-CodeBox Plugin

Hoje decidi instalar um plugin do wordpress para formatar os códigos que quero postar neste blog.

Eu escolhi o WP-CodeBox, que teve uma fácil instalação, e se tem várias opções de linguagem.

Estou executando abaixo o exemplo descrito no Wp-CodBox Demo e o comportamento abaixo mostra-se ser bem legal.

**Example 1: PHP, no line numbers**

    

**Example 2: Java, with line numbers, collapse codebox**

    public class Hello {
      public static void main(String[] args) {
        System.out.println("Hello World!");
      }
    }

**Example 3: Ruby, with line numbers starting at 18, code downloading(ruby.txt)**

    class Example
      def example(arg1)
        return "Hello: " + arg1.to_s
      end
    end

Kleber Rodrigo de Carvalho

CGI Error Parte 2

Infelizmente depois de algumas horas tentativas, ainda não consegui resolver o problema do erro de CGI.

Na verdade existe um bug no CGI/FastCGI do IIS.

Eu achei que era um problema do wordpress:

http://wordpress.org/support/topic/146225
http://wordpress.org/support/topic/131976

Mas perceba que esse problema somente aparece no Microsoft-IIS/6.0, meu ambiente de teste aqui é Windows/Apache com CGI/FastCGI, e não tem problema. O mesmo acontece no Linux/Apache. Realmente o problema está no IIS com FastCGI.

A empresa de host que contratei, possui alguns plano e eu assino o plano Aw, com Windows e Microsoft-IIS/6.0.

Se os problemas persistirem, e ter outro custo beneficio melhor, terei que mudar.

Kleber Rodrigo de Carvalho