Simple Fast Highlighter

Examples

Javascript

// Returns a string with all the object's properties.
function dump_props(obj, obj_name) {
   var result = "";
   for (var i in obj) {
      result += obj_name + "." + i + " = " + obj[i] + "<br>";
   }
   result += "<hr>";
   return result;
}

PHP

<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192); // Read in chunks
}
fclose($handle);
?>

VB.NET

Module MyModule

  ' Example of events in VB.NET
  Sub Main()

    Dim c As Counter = New Counter(New Random().Next(10))
    AddHandler c.ThresholdReached, AddressOf c_ThresholdReached

    Console.WriteLine("press 'a' key to increase total")
    While Console.ReadKey(True).KeyChar = "a"
      Console.WriteLine("adding one")
      c.Add(1)
    End While 

  End Sub 

  Sub c_ThresholdReached(sender As Object, e As EventArgs)

    Console.WriteLine("The threshold was reached.")
    Environment.Exit(0)

  End Sub

End Module

C#

class Program
{
  /* Example of events in C# */
  static void Main(string[] args)
  {
    Counter c = new Counter(new Random().Next(10));
    c.ThresholdReached += c_ThresholdReached;

    Console.WriteLine("press 'a' key to increase total");
    while (Console.ReadKey(true).KeyChar == 'a')
    {
      Console.WriteLine("adding one");
      c.Add(1);
    }
  }

  static void c_ThresholdReached(object sender, EventArgs e)
  {
    Console.WriteLine("The threshold was reached.");
    Environment.Exit(0); 
  }
}

CSS

body {
  background-color:#f0f0f0;
  color:black;
  padding:1em;
}

Python

import threading
from contextlib import contextmanager

_tls = threading.local()

@contextmanager
def _nested():
  _tls.level = getattr(_tls, "level", 0) + 1
  try:
    yield "   " * _tls.level
  finally:
    _tls.level -= 1

@contextmanager
def _recursion_lock(obj):
  if not hasattr(_tls, "history"):
    _tls.history = []  # can't use set(), not all objects are hashable
  if obj in _tls.history:
    yield True
    return
  _tls.history.append(obj)
  try:
    yield False
  finally:
    _tls.history.pop(-1)

MySQL

SELECT * FROM my_table WHERE DATE(created) < NOW();