Archive

Archive for July, 2010

WP-Syntax in WordPress

July 16th, 2010

(link to original post: http://wordpress.org/extend/plugins/wp-syntax/other_notes/)

Usage

Wrap code blocks with <pre lang="LANGUAGE" line="1"> and </pre> where LANGUAGE is a GeSHi supported language syntax. See below for a full list of supported languages. The line attribute is optional.

Example 1: PHP, no line numbers

<pre lang="php">
<div id="foo">
<?php
  function foo() {
    echo "Hello World!\\n";
  }
?>
</div>
</pre>

Example 2: Java, with line numbers

<pre lang="java" line="1">
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}
</pre>

Example 3: Ruby, with line numbers starting at 18

<pre lang="ruby" line="18">
class Example
  def example(arg1)
    return "Hello: " + arg1.to_s
  end
end
</pre>

Example 4: If your code already has html entities escaped, use escaped="true" as an option

<pre lang="xml" escaped="true">
&lt;xml&gt;Hello&lt;/xml&gt;
</pre>

Supported Languages

The following languages are supported in the lang attribute:

abap, actionscript, actionscript3, ada, apache, applescript, apt_sources, asm, asp, autoit, avisynth, bash, bf, bibtex, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cil, cfdg, cfm, cmake, cobol, cpp-qt, cpp, csharp, css, d, dcs, delphi, diff, div, dos, dot, eiffel, email, erlang, fo, fortran, freebasic, genero, gettext, glsl, gml, bnuplot, groovy, haskell, hq9plus, html4strict, idl, ini, inno, intercal, io, java, java5, javascript, kixtart, klonec, klonecpp, latex, lisp, locobasic, lolcode lotusformulas, lotusscript, lscript, lsl2, lua, m68k, make, matlab, mirc, modula3, mpasm, mxml, mysql, nsis, oberon2, objc, ocaml-brief, ocaml, oobas, oracle11, oracle8, pascal, per, pic16, pixelbender, perl, php-brief, php, plsql, povray, powershell, progress, prolog, properties, providex, python, qbasic, rails, rebol, reg, robots, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, tcl, teraterm, text, thinbasic, tsql, typoscript, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xml, xorg_conf, xpp, z80

(Bold languages just highlight the more popular ones.)

Styling Guidelines

WP-Syntax colors code using the default GeSHi colors. It also uses inline styling to make sure that code highlights still work in RSS feeds. It uses a default wp-syntax.css stylesheet for basic layout. To customize your styling, copy the default wp-content/plugins/wp-syntax/wp-syntax.css to your theme’s template directory and modify it. If a file named wp-syntax.css exists in your theme’s template directory, this stylesheet is used instead of the default. This allows theme authors to add their own customizations as they see fit.

Advanced Customization

WP-Syntax supports a wp_syntax_init_geshi action hook to customize GeSHi initialization settings. Blog owners can handle the hook in a hand-made plugin or somewhere else like this:

<?php
add_action('wp_syntax_init_geshi', 'my_custom_geshi_styles');

function my_custom_geshi_styles(&$geshi)
{
    $geshi->set_brackets_style('color: #000;');
    $geshi->set_keyword_group_style(1, 'color: #22f;');
}
?>

This allows for a great possibility of different customizations. Be sure to review the GeSHi Documentation.

Author: SquallLTT Categories: Programming Tags:

Some notes for handling string

July 16th, 2010

Clearing my phone since it is very messy with a lot of files, and found some notes here:

Handling string in C#
List of Numeric Formats

* C or C – For Currency. Uses the cultures currency symbol.
* D or D – Integer types. Add a number for 0 padding eg D5.
* E or e – Scientific notation.
* F or f – Fixed Point.
* G or g – Compact fixed-point/scientific notation.
* N or n – Number. This can be enhanced by a NumberFormatInfo object.
* P or p – Percentage.
* R or r – Round-trip. Keeps exact digits when converted to string and back.
* X or x – Hexadecimal. x – uses abcdef, X use ABCDEF.

Dates can also be specified either using Standard Format strings

* O or o – YYYY-MM-dd:mm:ss:ffffffffzz
* R or r – RFC1123 eg ddd, dd MMM yyyy HH:ss GMT
* s – sortable . yyyy-MM-ddTHH:mm:ss
* u – Universal Sort Date – yyyy-MM-dd HH:mm:ssZ

or Format specifiers. There are too many of those to list here. Example:

using System;
using System.Text;
using System.Globalization;
 
namespace ex6
{
    class Program
    {
        static void Main(string[] args)
        {
            // Numeric Formatting Examples
            // integer
            int i = 5678;
            string s = string.Format("{0,10:D}", i);  // Into a string right aligned 10 width
            Console.WriteLine("{0,10:D}", i);         // or output direct    
            Console.WriteLine("{0,10:D7}", i);         // or output direct with leading 0
 
            // double and currency in various formats
            double d=47.5;
            double bigd = 19876543.6754;
            Console.WriteLine("{0,15:C2}", d);  //  In Uk = £47.50 right aligned in 15 width
 
            Console.WriteLine("{0,15:N10}", bigd); //  Number 
            Console.WriteLine("{0,15:E3}", d);  //  Scientific 4.750E+001
            Console.WriteLine("{0,15:F5}", d);  //  Fixed Point 47.50000
            Console.WriteLine("{0,15:G4}", d);  //  Compact 47.5
            Console.WriteLine("{0,10:P2}", d/100.0);  //  %
            Console.WriteLine("{0,15:R}", bigd); //  Roundtrip - not a digit lost
 
            // Hex-a-diddly-decimal
            Console.WriteLine("{0,10:x8}", i);   // lowercase 0000162e
            Console.WriteLine("{0,10:X8}", i);   // uppercase 0000162E
 
 
            // Date formats
            DateTime dt = DateTime.Now;
            // Standards
            Console.WriteLine("{0:O}", dt);   // O or o  yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzz
            Console.WriteLine("{0:R}", dt);   // R or r ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
            Console.WriteLine("{0:s}", dt);   // s yyyy'-'MM'-'dd'T'HH':'mm':'ss
            Console.WriteLine("{0:u}", dt);   // u yyyy'-'MM'-'dd HH':'mm':'ss'Z'
 
            // Using date/time specifiers
            Console.WriteLine("{0:t}", dt);  // short time
            Console.WriteLine("{0:T}", dt);  // long time
            Console.WriteLine("{0:d}", dt);  // short date 
            Console.WriteLine("{0:D}", dt);  // long date 
            Console.WriteLine("{0:f}", dt);  // long date / short time 
            Console.WriteLine("{0:F}", dt);  // long date / long time
            Console.WriteLine("{0:g}", dt);  // short date / short time 
            Console.WriteLine("{0:G}", dt);  // short date / long time
            Console.WriteLine("{0:o}", dt);  // Round Trip
 
            // roll your own... 
            Console.WriteLine("{0:dd/mm/yyyy HH:MM:ss}", dt);  // custom - what most people use (UK)!
            Console.WriteLine("{0:mm/dd/yyyy HH:MM:ss}", dt);  // custom - what most people use (US)!
            Console.WriteLine("{0:yyyy/mm/dd HH:MM:ss}", dt);  // custom - (Japan) Good for sorting!
 
            Console.WriteLine("{0:dd MMM yyyy HH:MM:ss}", dt);  // custom - month (UK)
            Console.WriteLine("{0:MMM dd yyyy HH:MM:ss}", dt);  // custom - month (US)
            Console.WriteLine("{0:yyyy MMM dd HH:MM:ss}", dt);  // custom - (Japan) 
            Console.ReadKey();
        }
    }
}

C:
Standard: \r\n
(don’t use \n\r)

Author: SquallLTT Categories: Programming Tags:

Nothing else matters – MetallicA

July 12th, 2010

This wonderful song is written by the awesome thrash metal band – MetallicA . Love it so much.
Title: Nothing Else Matters
Words: Metallica
Music: Metallica
Instructions: Tab by B. Joosten
Tempo = 69
Guitar I (clean)

Legend
L – tied note
x – dead note
h – hammer on/pull off
b – bend
s – slide
~ – vibrato
g – ghost note
> – accentuated note
t – trill
M – palm mute
. – staccato
P – popping (bass)
S – slapping (bass)
+ – tapping
W – wide vibrato
< - fade in
w - whammy bar
= - tremolo picking
v - brush up
^ - brush down
V - pick stroke up
n - pick stroke down
Read more…

Author: SquallLTT Categories: Others Tags:

My handy program

July 12th, 2010

Delphi 2010

The first version was written 6 years ago, when I was a high school student with the love in computer programming. This program has been always a handy program of mine. I use it almost everyday.

Pascal/Delphi – those were the days…

Author: SquallLTT Categories: Diary Tags: