At Last!

19th October 2007 at 12:52:32 am

After many hours of wasted time and effort, I have created my first WordPress Plugin.

document.write('Is it not just so pretty?');

<?php
 
if ( is_impressive( ) )
    echo 'wow, so impressive';
else
{
    echo 'you are terrible!';
}
 
?>
die "not impressed" if !is_impressive;

Hover over each block to find out what language it is being highlighted as.

I plan to adjust more of the colors to suit my liking (and to match my current Eclipse color scheme).
Also, I will eventually add more Language Images to my theme (like PHP).

One of the coolest parts is that all the colors and stuff are controlled through CSS in the theme, not through the plugin. :D

#include <stdio.h>
 
int main(char *argv[], int argc)
{
    printf("Hooray for C.\n");
}
#include <iostream>
 
using namespace std;
 
int main(char *argv[], int argc)
{
    cout << "Hooray for C++." << endl;
}

(Don’t tell anyone, but those are both on the CPP formatter ;) [backwards-compatible and all that jazz])

All the highlighting is done via the PEAR Module, Text_Highlighter. Unfortunately, it has a bit of a weak-spot on specifics of languages, such as a built-ins list for PHP, or a types/preprocessor list for CPP, and eventually I plan to try to remedy that, but for now, this is GREAT.
The colors will be updated to more accurately reflect my current Eclipse Java highlighting, because I like it. (Interestingly enough, the theme controls the colors, not the script. :))
Also, I eventually plan to add more of the cool little images in the bottom-right corner (which are also controlled by the theme :P).

Several Bottles:

    ''=~(        '(?{'        .('`'        |'%')        .('['        ^'-')
    .('`'        |'!')        .('`'        |',')        .'"'.        '\\$'
    .'=='        .('['        ^'+')        .('`'        |'/')        .('['
    ^'+')        .'||'        .(';'        &'=')        .(';'        &'=')
    .';-'        .'-'.        '\\$'        .'=;'        .('['        ^'(')
    .('['        ^'.')        .('`'        |'"')        .('!'        ^'+')
   .'_\\{'      .'(\\$'      .';=('.      '\\$=|'      ."\|".(      '`'^'.'
  ).(('`')|    '/').').'    .'\\"'.+(    '{'^'[').    ('`'|'"')    .('`'|'/'
 ).('['^'/')  .('['^'/').  ('`'|',').(  '`'|('%')).  '\\".\\"'.(  '['^('(')).
 '\\"'.('['^  '#').'!!--'  .'\\$=.\\"'  .('{'^'[').  ('`'|'/').(  '`'|"\&").(
 '{'^"\[").(  '`'|"\"").(  '`'|"\%").(  '`'|"\%").(  '['^(')')).  '\\").\\"'.
 ('{'^'[').(  '`'|"\/").(  '`'|"\.").(  '{'^"\[").(  '['^"\/").(  '`'|"\(").(
 '`'|"\%").(  '{'^"\[").(  '['^"\,").(  '`'|"\!").(  '`'|"\,").(  '`'|(',')).
 '\\"\\}'.+(  '['^"\+").(  '['^"\)").(  '`'|"\)").(  '`'|"\.").(  '['^('/')).
 '+_,\\",'.(  '{'^('[')).  ('\\$;!').(  '!'^"\+").(  '{'^"\/").(  '`'|"\!").(
 '`'|"\+").(  '`'|"\%").(  '{'^"\[").(  '`'|"\/").(  '`'|"\.").(  '`'|"\%").(
 '{'^"\[").(  '`'|"\$").(  '`'|"\/").(  '['^"\,").(  '`'|('.')).  ','.(('{')^
 '[').("\["^  '+').("\`"|  '!').("\["^  '(').("\["^  '(').("\{"^  '[').("\`"|
 ')').("\["^  '/').("\{"^  '[').("\`"|  '!').("\["^  ')').("\`"|  '/').("\["^
 '.').("\`"|  '.').("\`"|  '$')."\,".(  '!'^('+')).  '\\",_,\\"'  .'!'.("\!"^
 '+').("\!"^  '+').'\\"'.  ('['^',').(  '`'|"\(").(  '`'|"\)").(  '`'|"\,").(
 '`'|('%')).  '++\\$="})'  );$:=('.')^  '~';$~='@'|  '(';$^=')'^  '[';$/='`';

Single Bottle:

         $a=
        "cpuu
       \bmft p
       \bg cff
       \bs";$b
       ="po ui
       \bf xbm
      \bm";$c="
      Ypv ublf p
     \bof epxo qb
   \btt ju bspvoe";
  $a =~ s/\n//;$a =~
  s/\s+/ /g; $b   =~
  s/\n// ;  $b    =~
  s/\s+/ /g;$c    =~
  s/\n// ;  $c    =~
  s/\s+/ /g;$a    =~
  y/b-z/a-z/;$b   =~
  tr/b-z/a-z/;$c  =~
  tr/b-z/a-z/ ; for(
  $d=100;$d>0;$d--){
  print"$d $a $b $d"
  ;print" $a,\n$c, "
  ;print($d-1);print
  " $a $b.\n";} $x =
  "cjc"; $y="dobbz";
  $z="com";print"\n"
  ;print "- $x\@$y."
   ;print"$z \n\n";

And finally, some OOP: (I leave you with a nice long one, so you can see the length cutoff.)

#!/usr/bin/perl
use strict;
use warnings;
 
#######################################
#
#   99 bottles of beer on the wall
#   Written in object oriented Perl
#
#######################################
my $beer = Bottles->new();
$beer->Take_One_Down() while $beer->Remaining();
 
package Bottles;
 
sub new
{
    my $bottles = 99;
    bless \$bottles;
}
 
sub Take_One_Down
{
    my $self = shift;    
    my $s = $$self == 1 ? '' : 's';
    
    print "$$self bottle$s of beer on the wall,\n";
    print "$$self bottle$s of beer.\n";
    print "Take one down, pass it around.\n";
    
    $$self--;
    
    $s = $$self == 1 ? '' : 's';
    
    print "$$self bottle$s of beer on the wall.\n\n";
}
 
sub Remaining
{
    my $self = shift;
    return $$self;    
}

Source of Beer Bottles: http://99-bottles-of-beer.net/.

Author Bio: Tianon Gravi

Tianon is a programmer for a respectable software company.

Actions: Trackback

2 comments :D

  • 1) PixelFish commented 19th October 2007 at 07:05:44 pm:

    I’ll just nod my head and pretend like I understood half that. :)

  • 2) Tianon commented 20th October 2007 at 02:53:18 am:

    Just sit back and enjoy the pretty colors. :D