Archive

Archive for the ‘IT’ Category

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:

How to get auto upgrade WordPress on host pipni.cz

May 19th, 2010

Host pipni.cz has some security settings that don’t allow user to access the default temp directory, so we can’t do auto upgrade version for WordPress. Here, I’ll show you how to do auto upgrade by creating our own temp directory.

1) First, add a “tmp” foler under wordpress blog directory.
2) Added the following lines to “wp-config.php” to point wordpress temp directory to it

if ( !defined(‘WP_TEMP_DIR’) )
define(‘WP_TEMP_DIR’, dirname(__FILE__) . ‘/tmp/’);

<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information by
* visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/
 
if ( !defined('WP_TEMP_DIR') )
define('WP_TEMP_DIR', dirname(__FILE__) . '/tmp/');
 
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'databasename');
 
/** MySQL database username */
define('DB_USER', 'username');
...
...
...
?>
Author: SquallLTT Categories: IT Tags:

SquallLTT presents: My PDA phone :D

June 24th, 2009

Here is the link to the video clip: http://www.25phut.net/uploadedvideoclips/viva.html

In conclusion I’d like to say that Windows Mobile phones are the best, at least, to me. Countless softwares are available out there. And, I can do some coding for my PDA as u can see in the video, I’ve implemented image processing (Canny Edge detection), written a program to operate a robot via WIFI, and much more… :D

Files searching tool from rapid.25phut.net

May 12th, 2009

rapid.25phut.net is a tool which allows users to find freely available files from all around the web!

Visitors can searches: RapidShare, MegaUpload, MegaShares, Badongo, FileFront, SaveFile

To begin using this amazing tool, simply type in your search query in the search box located at the top of this page and hit search. It really is that simple! You now have the most comprehensive file search tool at your fingretips.

Note that: this tool is mainly used for searching education materials: ebooks related to computer programming or literatures

Here is the link: http://rapid.25phut.net/

Author: SquallLTT Categories: IT Tags: ,

Config Aptana Studio to work with XAMPP

May 8th, 2009

Launch you Aptana Studio, select: Run -> Run…

A dialog appears and choose the following options:

aptana studio work with xampp

Author: SquallLTT Categories: IT Tags:

Force www vs non-www to avoid duplicate content on Google Search

May 7th, 2009

When you have your site accessible both under your_domain.com and www.your_domain.com you may come up with duplicate content on Google Search. To avoid such problems you can use the following lines in your .htaccess file to force only the www version of your web site:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]

Note that the .htaccess should be located in the web site main folder.

This will redirect all requests to the non-www version of your site to the www version using 301 Permanent redirect which will make the search engines to index your site only using the www.your_domain.com URL. In this way you will avoid a duplicate content penalty.

Author: SquallLTT Categories: IT Tags: ,

Duplicate content fix index.html vs / (slash only)

May 7th, 2009

This similar to the www vs non-www version of your site work-around.
As you might now you, by default you can access your site as http://www.domain.com/ and http://www.domain.com/index.html with some setups it can be index.php or index.asp or default.aps, etc.
Unfortunately, this creates a risk of duplicate content from the search engine point of view. To avoid this, you can use the following ModRewrite rules in your .htaccess file:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.domain.com/ [R=301,L]

The file should be located in your website main folder (web root).

The rules above will tell the browser or the search engine both that all requests to index.html should be directed to the "/" (slash only).

Author: SquallLTT Categories: IT Tags: ,

Make PHP to work in your HTML files with .htaccess

May 7th, 2009

By default most web servers across the internet are configured to treat as PHP files only files that end with .php. In case you need to have your HTML files parsed as PHP (e.g .html) or even if you want to take it further and make your PHP files look like ASP, you can do the following:
For web servers using PHP as apache module:

AddType application/x-httpd-php .html .htm

For web servers running PHP as CGI:

AddHandler application/x-httpd-php .html .htm

In case you wish to do the ASP mimick:

For PHP as module:

AddType application/x-httpd-php .asp

OR for PHP as CGI:

AddHandler application/x-httpd-php .asp
Author: SquallLTT Categories: IT Tags: , ,

Some useful shortcuts for Firefox

May 7th, 2009

My most-used shortcuts:

F6 or Ctrl+L : Gets you right up into the Address/URL bar.
F5 : Reload the page.
Ctrl+F : Find what you’re looking for on the page. I also just learned you can “quick search” by using just the / key!
Ctrl+T : Opens a new tab. If you’re spending time clicking the new tab icon all day, you’re missing out!
Ctrl+K : Takes you to the Firefox search box.
Ctrl+U : View the page’s source.
F11 : View the page in full-screen mode.
Ctrl+W : Closes the active tab.
Ctrl+= : Increases font size.
Ctrl+- : Decreases font size.
Ctrl+Shift+T : Opens the last closed tab. No more right-clicking and asking Firefox to open the tab you accidentally closed!

Author: SquallLTT Categories: IT Tags: ,