text:
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Pechkin.Util;

namespace Pechkin
{
    /// <summary>
    /// Static class with utility methods for the interface.
    /// Acts mostly as a facade over PechkinBindings with log tracing.
    /// </summary>
    [Serializable]
    internal static class PechkinStatic
    {
        public static IntPtr CreateGlobalSetting()
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Creating global settings (wkhtmltopdf_create_global_settings)");

            return PechkinBindings.wkhtmltopdf_create_global_settings();
        }

        public static IntPtr CreateObjectSettings()
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Creating object settings (wkhtmltopdf_create_object_settings)");

            return PechkinBindings.wkhtmltopdf_create_object_settings();
        }

        public static int SetGlobalSetting(IntPtr setting, string name, string value)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting global setting (wkhtmltopdf_set_global_setting)");

            return PechkinBindings.wkhtmltopdf_set_global_setting(setting, name, value);
        }

        public static string GetGlobalSetting(IntPtr setting, string name)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Getting global setting (wkhtmltopdf_get_global_setting)");

            byte[] buf = new byte[2048];

            PechkinBindings.wkhtmltopdf_get_global_setting(setting, name, ref buf, buf.Length);

            int walk = 0;
            while (walk < buf.Length && buf[walk] != 0)
            {
                walk++;
            }

            byte[] buf2 = new byte[walk];
            Array.Copy(buf, 0, buf2, 0, walk);

            return Encoding.UTF8.GetString(buf2);
        }

        public static int SetObjectSetting(IntPtr setting, string name, string value)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting object setting (wkhtmltopdf_set_object_setting)");

            return PechkinBindings.wkhtmltopdf_set_object_setting(setting, name, value);
        }

        public static string GetObjectSetting(IntPtr setting, string name)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Getting object setting (wkhtmltopdf_get_object_setting)");

            byte[] buf = new byte[2048];

            PechkinBindings.wkhtmltopdf_get_object_setting(setting, name, ref buf, buf.Length);

            int walk = 0;
            while (walk < buf.Length && buf[walk] != 0)
            {
                walk++;
            }

            byte[] buf2 = new byte[walk];
            Array.Copy(buf, 0, buf2, 0, walk);

            return Encoding.UTF8.GetString(buf2);
        }

        public static IntPtr CreateConverter(IntPtr globalSettings)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Creating converter (wkhtmltopdf_create_converter)");

            return PechkinBindings.wkhtmltopdf_create_converter(globalSettings);
        }

        public static void DestroyConverter(IntPtr converter)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Destroying converter (wkhtmltopdf_destroy_converter)");

            PechkinBindings.wkhtmltopdf_destroy_converter(converter);
        }

        public static void SetWarningCallback(IntPtr converter, StringCallback callback)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting warning callback (wkhtmltopdf_set_warning_callback)");

            PechkinBindings.wkhtmltopdf_set_warning_callback(converter, callback);
        }

        public static void SetErrorCallback(IntPtr converter, StringCallback callback)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting error callback (wkhtmltopdf_set_error_callback)");

            PechkinBindings.wkhtmltopdf_set_error_callback(converter, callback);
        }

        public static void SetFinishedCallback(IntPtr converter, IntCallback callback)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting finished callback (wkhtmltopdf_set_finished_callback)");

            PechkinBindings.wkhtmltopdf_set_finished_callback(converter, callback);
        }

        public static void SetPhaseChangedCallback(IntPtr converter, VoidCallback callback)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting phase change callback (wkhtmltopdf_set_phase_changed_callback)");

            PechkinBindings.wkhtmltopdf_set_phase_changed_callback(converter, callback);
        }

        public static void SetProgressChangedCallback(IntPtr converter, IntCallback callback)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting progress change callback (wkhtmltopdf_set_progress_changed_callback)");

            PechkinBindings.wkhtmltopdf_set_progress_changed_callback(converter, callback);
        }

        public static bool PerformConversion(IntPtr converter)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Starting conversion (wkhtmltopdf_convert)");

            return PechkinBindings.wkhtmltopdf_convert(converter) != 0;
        }

        public static void AddObject(IntPtr converter, IntPtr objectConfig, string html)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Adding string object (wkhtmltopdf_add_object)");

            PechkinBindings.wkhtmltopdf_add_object(converter, objectConfig, html);
        }

        public static void AddObject(IntPtr converter, IntPtr objectConfig, byte[] html)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Adding byte[] object (wkhtmltopdf_add_object)");

            PechkinBindings.wkhtmltopdf_add_object(converter, objectConfig, html);
        }

        public static int GetPhaseNumber(IntPtr converter)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Requesting current phase (wkhtmltopdf_current_phase)");

            return PechkinBindings.wkhtmltopdf_current_phase(converter);
        }

        public static int GetPhaseCount(IntPtr converter)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Requesting phase count (wkhtmltopdf_phase_count)");

            return PechkinBindings.wkhtmltopdf_phase_count(converter);
        }

        public static string GetPhaseDescription(IntPtr converter, int phase)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Requesting phase description (wkhtmltopdf_phase_description)");

            return Marshal.PtrToStringAnsi(PechkinBindings.wkhtmltopdf_phase_description(converter, phase));
        }

        public static string GetProgressDescription(IntPtr converter)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Requesting progress string (wkhtmltopdf_progress_string)");

            return Marshal.PtrToStringAnsi(PechkinBindings.wkhtmltopdf_progress_string(converter));
        }

        public static int GetHttpErrorCode(IntPtr converter)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Requesting http error code (wkhtmltopdf_http_error_code)");

            return PechkinBindings.wkhtmltopdf_http_error_code(converter);
        }

        public static byte[] GetConverterResult(IntPtr converter)
        {
            Tracer.Trace("T:" + Thread.CurrentThread.Name + " Requesting converter result (wkhtmltopdf_get_output)");

            IntPtr tmp;
            var len = PechkinBindings.wkhtmltopdf_get_output(converter, out tmp);
            var output = new byte[len];
            Marshal.Copy(tmp, output, 0, output.Length);
            return output;
        }

        internal class StrPaperSize
        {
            private readonly string _width;
            private readonly string _height;

            public StrPaperSize(string width, string height)
            {
                _width = width;
                _height = height;
            }

            public string Height
            {
                get
                {
                    return _height;
                }
            }

            public string Width
            {
                get
                {
                    return _width;
                }
            }
        }

        internal static readonly Dictionary<PaperKind, StrPaperSize> PaperSizes = new Dictionary<PaperKind, StrPaperSize>();

        static PechkinStatic()
        {
            // paper sizes from http://msdn.microsoft.com/en-us/library/system.drawing.printing.paperkind.aspx
            PaperSizes.Add(PaperKind.Letter, new StrPaperSize("8.5in", "11in"));
            PaperSizes.Add(PaperKind.Legal, new StrPaperSize("8.5in", "14in"));
            PaperSizes.Add(PaperKind.A4, new StrPaperSize("210mm", "297mm"));
            PaperSizes.Add(PaperKind.CSheet, new StrPaperSize("17in", "22in"));
            PaperSizes.Add(PaperKind.DSheet, new StrPaperSize("22in", "34in"));
            PaperSizes.Add(PaperKind.ESheet, new StrPaperSize("34in", "44in"));
            PaperSizes.Add(PaperKind.LetterSmall, new StrPaperSize("8.5in", "11in"));
            PaperSizes.Add(PaperKind.Tabloid, new StrPaperSize("11in", "17in"));
            PaperSizes.Add(PaperKind.Ledger, new StrPaperSize("17in", "11in"));
            PaperSizes.Add(PaperKind.Statement, new StrPaperSize("5.5in", "8.5in"));
            PaperSizes.Add(PaperKind.Executive, new StrPaperSize("7.25in", "10.5in"));
            PaperSizes.Add(PaperKind.A3, new StrPaperSize("297mm", "420mm"));
            PaperSizes.Add(PaperKind.A4Small, new StrPaperSize("210mm", "297mm"));
            PaperSizes.Add(PaperKind.A5, new StrPaperSize("148mm", "210mm"));
            PaperSizes.Add(PaperKind.B4, new StrPaperSize("250mm", "353mm"));
            PaperSizes.Add(PaperKind.B5, new StrPaperSize("176mm", "250mm"));
            PaperSizes.Add(PaperKind.Folio, new StrPaperSize("8.5in", "13in"));
            PaperSizes.Add(PaperKind.Quarto, new StrPaperSize("215mm", "275mm"));
            PaperSizes.Add(PaperKind.Standard10x14, new StrPaperSize("10in", "14in"));
            PaperSizes.Add(PaperKind.Standard11x17, new StrPaperSize("11in", "17in"));
            PaperSizes.Add(PaperKind.Note, new StrPaperSize("8.5in", "11in"));
            PaperSizes.Add(PaperKind.Number9Envelope, new StrPaperSize("3.875in", "8.875in"));
            PaperSizes.Add(PaperKind.Number10Envelope, new StrPaperSize("4.125in", "9.5in"));
            PaperSizes.Add(PaperKind.Number11Envelope, new StrPaperSize("4.5in", "10.375in"));
            PaperSizes.Add(PaperKind.Number12Envelope, new StrPaperSize("4.75in", "11in"));
            PaperSizes.Add(PaperKind.Number14Envelope, new StrPaperSize("5in", "11.5in"));
            PaperSizes.Add(PaperKind.DLEnvelope, new StrPaperSize("110mm", "220mm"));
            PaperSizes.Add(PaperKind.C5Envelope, new StrPaperSize("162mm", "229mm"));
            PaperSizes.Add(PaperKind.C3Envelope, new StrPaperSize("324mm", "458mm"));
            PaperSizes.Add(PaperKind.C4Envelope, new StrPaperSize("229mm", "324mm"));
            PaperSizes.Add(PaperKind.C6Envelope, new StrPaperSize("114mm", "162mm"));
            PaperSizes.Add(PaperKind.C65Envelope, new StrPaperSize("114mm", "229mm"));
            PaperSizes.Add(PaperKind.B4Envelope, new StrPaperSize("250mm", "353mm"));
            PaperSizes.Add(PaperKind.B5Envelope, new StrPaperSize("176mm", "250mm"));
            PaperSizes.Add(PaperKind.B6Envelope, new StrPaperSize("176mm", "125mm"));
            PaperSizes.Add(PaperKind.ItalyEnvelope, new StrPaperSize("110mm", "230mm"));
            PaperSizes.Add(PaperKind.MonarchEnvelope, new StrPaperSize("3.875in", "7.5in"));
            PaperSizes.Add(PaperKind.PersonalEnvelope, new StrPaperSize("3.625in", "6.5in"));
            PaperSizes.Add(PaperKind.USStandardFanfold, new StrPaperSize("14.875in", "11in"));
            PaperSizes.Add(PaperKind.GermanStandardFanfold, new StrPaperSize("8.5in", "12in"));
            PaperSizes.Add(PaperKind.GermanLegalFanfold, new StrPaperSize("8.5in", "13in"));
            PaperSizes.Add(PaperKind.IsoB4, new StrPaperSize("250mm", "353mm"));
            PaperSizes.Add(PaperKind.JapanesePostcard, new StrPaperSize("100mm", "148mm"));
            PaperSizes.Add(PaperKind.Standard9x11, new StrPaperSize("9in", "11in"));
            PaperSizes.Add(PaperKind.Standard10x11, new StrPaperSize("10in", "11in"));
            PaperSizes.Add(PaperKind.Standard15x11, new StrPaperSize("15in", "11in"));
            PaperSizes.Add(PaperKind.InviteEnvelope, new StrPaperSize("220mm", "220mm"));
            PaperSizes.Add(PaperKind.LetterExtra, new StrPaperSize("9.275in", "12in"));
            PaperSizes.Add(PaperKind.LegalExtra, new StrPaperSize("9.275in", "15in"));
            PaperSizes.Add(PaperKind.TabloidExtra, new StrPaperSize("11.69in", "18in"));
            PaperSizes.Add(PaperKind.A4Extra, new StrPaperSize("236mm", "322mm"));
            PaperSizes.Add(PaperKind.LetterTransverse, new StrPaperSize("8.275in", "11in"));
            PaperSizes.Add(PaperKind.A4Transverse, new StrPaperSize("210mm", "297mm"));
            PaperSizes.Add(PaperKind.LetterExtraTransverse, new StrPaperSize("9.275in", "12in"));
            PaperSizes.Add(PaperKind.APlus, new StrPaperSize("227mm", "356mm"));
            PaperSizes.Add(PaperKind.BPlus, new StrPaperSize("305mm", "487mm"));
            PaperSizes.Add(PaperKind.LetterPlus, new StrPaperSize("8.5in", "12.69in"));
            PaperSizes.Add(PaperKind.A4Plus, new StrPaperSize("210mm", "330mm"));
            PaperSizes.Add(PaperKind.A5Transverse, new StrPaperSize("148mm", "210mm"));
            PaperSizes.Add(PaperKind.B5Transverse, new StrPaperSize("182mm", "257mm"));
            PaperSizes.Add(PaperKind.A3Extra, new StrPaperSize("322mm", "445mm"));
            PaperSizes.Add(PaperKind.A5Extra, new StrPaperSize("174mm", "235mm"));
            PaperSizes.Add(PaperKind.B5Extra, new StrPaperSize("201mm", "276mm"));
            PaperSizes.Add(PaperKind.A2, new StrPaperSize("420mm", "594mm"));
            PaperSizes.Add(PaperKind.A3Transverse, new StrPaperSize("297mm", "420mm"));
            PaperSizes.Add(PaperKind.A3ExtraTransverse, new StrPaperSize("322mm", "445mm"));
            PaperSizes.Add(PaperKind.JapaneseDoublePostcard, new StrPaperSize("200mm", "148mm"));
            PaperSizes.Add(PaperKind.A6, new StrPaperSize("105mm", "148mm"));
            PaperSizes.Add(PaperKind.LetterRotated, new StrPaperSize("11in", "8.5in"));
            PaperSizes.Add(PaperKind.A3Rotated, new StrPaperSize("420mm", "297mm"));
            PaperSizes.Add(PaperKind.A4Rotated, new StrPaperSize("297mm", "210mm"));
            PaperSizes.Add(PaperKind.A5Rotated, new StrPaperSize("210mm", "148mm"));
            PaperSizes.Add(PaperKind.B4JisRotated, new StrPaperSize("364mm", "257mm"));
            PaperSizes.Add(PaperKind.B5JisRotated, new StrPaperSize("257mm", "182mm"));
            PaperSizes.Add(PaperKind.JapanesePostcardRotated, new StrPaperSize("148mm", "100mm"));
            PaperSizes.Add(PaperKind.JapaneseDoublePostcardRotated, new StrPaperSize("148mm", "200mm"));
            PaperSizes.Add(PaperKind.A6Rotated, new StrPaperSize("148mm", "105mm"));
            PaperSizes.Add(PaperKind.B6Jis, new StrPaperSize("128mm", "182mm"));
            PaperSizes.Add(PaperKind.B6JisRotated, new StrPaperSize("182mm", "128mm"));
            PaperSizes.Add(PaperKind.Standard12x11, new StrPaperSize("12in", "11in"));
            PaperSizes.Add(PaperKind.Prc16K, new StrPaperSize("146mm", "215mm"));
            PaperSizes.Add(PaperKind.Prc32K, new StrPaperSize("97mm", "151mm"));
            PaperSizes.Add(PaperKind.Prc32KBig, new StrPaperSize("97mm", "151mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber1, new StrPaperSize("102mm", "165mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber2, new StrPaperSize("102mm", "176mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber3, new StrPaperSize("125mm", "176mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber4, new StrPaperSize("110mm", "208mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber5, new StrPaperSize("110mm", "220mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber6, new StrPaperSize("120mm", "230mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber7, new StrPaperSize("160mm", "230mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber8, new StrPaperSize("120mm", "309mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber9, new StrPaperSize("229mm", "324mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber10, new StrPaperSize("324mm", "458mm"));
            PaperSizes.Add(PaperKind.Prc16KRotated, new StrPaperSize("146mm", "215mm"));
            PaperSizes.Add(PaperKind.Prc32KRotated, new StrPaperSize("97mm", "151mm"));
            PaperSizes.Add(PaperKind.Prc32KBigRotated, new StrPaperSize("97mm", "151mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber1Rotated, new StrPaperSize("165mm", "102mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber2Rotated, new StrPaperSize("176mm", "102mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber3Rotated, new StrPaperSize("176mm", "125mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber4Rotated, new StrPaperSize("208mm", "110mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber5Rotated, new StrPaperSize("220mm", "110mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber6Rotated, new StrPaperSize("230mm", "120mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber7Rotated, new StrPaperSize("230mm", "160mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber8Rotated, new StrPaperSize("309mm", "120mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber9Rotated, new StrPaperSize("324mm", "229mm"));
            PaperSizes.Add(PaperKind.PrcEnvelopeNumber10Rotated, new StrPaperSize("458mm", "324mm"));
        }
    }
}


text:
<?php

namespace Civi\API\Subscriber;

use Civi\API\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * This class determines what fields are allowed for a request
 * and validates that the fields are provided correctly.
 */
class APIv3SchemaAdapter implements EventSubscriberInterface {
  /**
   * @return array
   */
  public static function getSubscribedEvents() {
    return array(
      Events::PREPARE => array(
        array('onApiPrepare', Events::W_MIDDLE),
        array('onApiPrepare_validate', Events::W_LATE),
      ),
    );
  }

  /**
   * @param \Civi\API\Event\PrepareEvent $event
   *   API preparation event.
   *
   * @throws \API_Exception
   */
  public function onApiPrepare(\Civi\API\Event\PrepareEvent $event) {
    $apiRequest = $event->getApiRequest();
    if ($apiRequest['version'] > 3) {
      return;
    }

    $apiRequest['fields'] = _civicrm_api3_api_getfields($apiRequest);

    _civicrm_api3_swap_out_aliases($apiRequest, $apiRequest['fields']);
    if (strtolower($apiRequest['action']) != 'getfields') {
      if (empty($apiRequest['params']['id'])) {
        $apiRequest['params'] = array_merge($this->getDefaults($apiRequest['fields']), $apiRequest['params']);
      }
      // Note: If 'id' is set then verify_mandatory will only check 'version'.
      civicrm_api3_verify_mandatory($apiRequest['params'], NULL, $this->getRequired($apiRequest['fields']));
    }

    $event->setApiRequest($apiRequest);
  }

  /**
   * @param \Civi\API\Event\Event $event
   *   API preparation event.
   *
   * @throws \Exception
   */
  public function onApiPrepare_validate(\Civi\API\Event\Event $event) {
    $apiRequest = $event->getApiRequest();
    // Not sure why this is omitted for generic actions. It would make sense
    // to omit 'getfields', but that's only one generic action.

    if (isset($apiRequest['function']) && !$apiRequest['is_generic'] && isset($apiRequest['fields'])) {
      _civicrm_api3_validate_fields($apiRequest['entity'], $apiRequest['action'], $apiRequest['params'], $apiRequest['fields']);
      $event->setApiRequest($apiRequest);
    }
  }

  /**
   * Return array of defaults for the given API (function is a wrapper on getfields).
   * @param $fields
   * @return array
   */
  public function getDefaults($fields) {
    $defaults = array();

    foreach ($fields as $field => $values) {
      if (isset($values['api.default'])) {
        $defaults[$field] = $values['api.default'];
      }
    }
    return $defaults;
  }

  /**
   * Return array of required fields for the given API (function is a wrapper on getfields).
   * @param $fields
   * @return array
   */
  public function getRequired($fields) {
    $required = array('version');

    foreach ($fields as $field => $values) {
      if (!empty($values['api.required'])) {
        $required[] = $field;
      }
    }
    return $required;
  }

}

redpajama_set_name: RedPajamaGithub


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Lecidea pueblensis Cretz.

### Remarks
null


text:
var should  = require('chai').should(),
    cangjie = require('../index');

describe('Synchronous methods', function() {
  describe('cangjie.toCangjie()', function() {
    it('should convert MGILG to 一土戈中土', function() {
      cangjie.toCangjie('MGILG').should.equal('一土戈中土');
    });

    it('should be case insensitive', function() {
      cangjie.toCangjie('MgilG').should.equal('一土戈中土');
    });

    it('should convert I to 戈', function() {
      cangjie.toCangjie('I').should.equal('戈');
    });

    it('should convert ONF to 人弓火', function() {
      cangjie.toCangjie('ONF').should.equal('人弓火');
    });

    it('should ignore unknown characters', function(){
      cangjie.toCangjie('O!NF?').should.equal('人!弓火?');
    });

    it('should return nothing when given nothing', function(){
      should.not.exist(cangjie.toCangjie());
    });
  });

  describe('cangjie.fromCangjie()', function() {
    it('should convert 一土戈中土 to MGILG', function() {
      cangjie.fromCangjie('一土戈中土').should.equal('MGILG');
    });

    it('should convert 戈 to I', function() {
      cangjie.fromCangjie('戈').should.equal('I');
    });

    it('should convert 人弓火 to ONF', function() {
      cangjie.fromCangjie('人弓火').should.equal('ONF');
    });

    it('should ignore unknown characters', function(){
      cangjie.fromCangjie('人!弓火?').should.equal('O!NF?');
    });

    it('should return nothing when given nothing', function(){
      should.not.exist(cangjie.fromCangjie());
    });
  });
});


text:
layout: post
title: paradoxical commands of leadership
categories:
- Learning
---

Here's a gem to start off the week. These are the "Paradoxical Commandments of Leadership," by Kent Keith ( [source](http://www.paradoxicalcommandments.com/origin.html)):

1. People are illogical, unreasonable, and self-centered. Love them anyway.
2. If you do good, people will accuse you of selfish ulterior motives. Do good anyway.
3. If you are successful, you win false friends and true enemies. Succeed anyway.
4. The good you do today will be forgotten tomorrow. Do good anyway.
5. Honesty and frankness make you vulnerable. Be honest and frank anyway.
6. The biggest men with the biggest ideas can be shot down by the smallest men with the smallest minds. Think big anyway.
7. People favor underdogs, but follow only top dogs. Fight for a few underdogs anyway.
8. What you spend years building may be destroyed overnight. Build anyway.
9. People really need help but may attack you if you do help them. Help people anyway.
10. Give the world the best you have and you'll get kicked in the teeth. Give the world the best you have anyway.

[Excellent read by any student](http://www.paradoxicalcommandments.com/origin.html), I would say:

> "I saw a lot of idealistic young people go out into the world to do what they thought was right, and good, and true, only to come back a short time later, discouraged, or embittered, because they got negative feedback, or nobody appreciated them, or they failed to get the results they had hoped for." recalls Keith. "I told them that if they were going to change the world, they had to really love people, and if they did, that love would sustain them. I also told them that they couldn't be in it for fame or glory. I said that if they did what was right and good and true, they would find meaning and satisfaction, and that meaning and satisfaction would be enough. If they had the meaning, they didn't need the glory."


text:
import { Component, Output, EventEmitter } from "angular2/core";
import { NorthwindService }                from "../services/NorthwindService";
import { ICustomer }                       from "../interfaces/ICustomer";
import { ICustomerSelectedEvent }          from "../interfaces/ICustomerSelectedEvent";
import domready                            from "domready";
import bows                                from "bows";
import randomizer                          from "random-js";

const random = randomizer();
const log = bows("TableComponent");

@Component({
  selector: "nw-table",
  template: `<table id="northwind" class="display" width="100%"></table>`,
  providers: [NorthwindService]
})
export class TableComponent {
  @Output() customerSelected = new EventEmitter<ICustomerSelectedEvent>();
  private _table : DataTables.DataTable;
  private ajaxDataFunc: DataTables.FunctionAjax = (data : Object,
                                                   callback : Function,
                                                   settings : DataTables.SettingsLegacy) : void => {
    this._nwService.getCustomersEx().subscribe((cdata : ICustomer[]) => {
      cdata.forEach((c : ICustomer) => {
        c.Picture = `http://robohash.org/set_set2/${random.integer(0,100)}?size=150x150`;
        this._table.row.add(c);
      });
      this._table.draw();
    });
  }
  private tableSettings : Object = {
        ajax: {
           //url: "http://northwind.servicestack.net/customers.json",
           data: this.ajaxDataFunc,
           dataSrc: "Customers"
        },
        columns: [
            { data: "Id", title: "Id" },
            { data: "CompanyName", title: "Company" },
            { data: "ContactName", title: "Contact" },
            { data: "ContactTitle", title: "Title" },
            { data: "Address", title: "Address" },
            { data: "City", title: "City" },
            { data: "Country", title: "Country" },
            { data: "Phone", title: "Phone" }
        ],
        select: true
  }
  constructor(private _nwService: NorthwindService) {
    domready(() => {
      this.init();
    });
  }
  init(){
    this._table = $("#northwind").DataTable(<DataTables.Settings>this.tableSettings);
    $.fn.dataTable.ext.errMode = "ignore";
    this._table.on("select", (e : Event, dt: DataTables.DataTable, type: string, indexes : number[]) => {
     if ( type === "row" ) {
        let customer = dt.rows(indexes[0]).data()["0"];
        this.customerSelected.emit({
                                     sender: this,
                                     customer
                                    });
      }
    });
  }
}


text:
package com.podio.item.map.converter;

import java.util.Map;

public interface FieldConverter {

	Map<String, ?> fromModel(Object value);

	Object toModel(Map<String, ?> map, Class modelClass);
}


text:
title: Black and White and Southern African All Over
author: David Hogge
layout: post
permalink: /south-africa/black-and-white-and-southern-african-all-over.html
thumbnail: http://farm1.static.flickr.com/188/434769539_7fcc08888f
thumbnail_alt: All Your Base Are Belong to Us
geo_latitude:
  - -33.9237762
geo_longitude:
  - 18.4233455
geo_address:
  - Cape Town, Western Cape, South Africa
geo_enabled:
  - 1
geo_public:
  - 1
categories:
  - South Africa
tags:
  - Anti-communism
  - British Commonwealth
  - Foreign relations of Zimbabwe
  - Namibia
  - Robert Mugabe
  - Social Issues
  - South Africa
  - White people in Zimbabwe
  - Zimbabwean presidential election
---
This is the part of the blog where I get us in trouble. We've only been here five weeks or so, but it's hard to leave here without making a comment about the racial tension in this part of the world, and it comes from both directions. From the white Zimbabwean who corrected us by saying that he was "Rhodesian", to the Black South African who informed us that when watching a soccer match he always pulled for the team with more Blacks (bonus points if they were from Africa) it's impossible to escape how much things are defined by skin here.

### Don't Call Me Whitey…

First, I have never met a group of people as humorless and vaguely unfriendly at all times as white Southern Africans. Maybe it's a result of being a ruling minority for over a hundred years, maybe it's just the German blood coming out, but it's hard to get a response from many of them even when you (try) to look them in the eye and wish them a good day – and I'm white like them! Somehow this hasn't effected our (generally) good opinion of them.

And we're constantly surprised at how many whites we see here. Everywhere we go, there they are: Namibia – full of Germans, Zambia and Zimbabwe – full of English and Dutch, South Africa – All of the above and a huge number of Portuguese for good measure. Many are members of old families that have been here for generations, and they consider themselves Africans, despite whatever problems they face this is their home.

But for how long will they be there? It's apparent that there's white flight, but one person we spoke to was taking it to the next level. One of our drivers in Kruger was a white Namibian living and working in South Africa. When we spoke to him about the future he shocked us by pointing at the back of his hand and saying "This isn't a racist statement, but I'm just the wrong color for this continent." Now, that is a racist statement, but what he said next was even more shocking to me. He was living and working in South Africa just long enough to qualify for a South African passport, then he was picking up the family and moving to Australia. It's much easier to immigrate to Australia from S. Africa than Namibia as S.A. is a member of the British Commonwealth like Australia.

### The Cult of Robert Mugabe

Almost as shocking is how Robert Mugabe, Zimbabwe's leader, is held on high among African governments. Despite the fact that the country is a shambles and it's estimated that 1/4 of the population has fled into neighboring countries illegally there are a surprising number of monuments to him around Africa.

In Johannesburg, where there are over a million Zimbabwean refugees, the main square in downtown is named after him. It's not uncommon to look for an address on "Robert Mugabe Street" either. It seems that while most people will admit that he's a bastard and not helping his country or his people he is "Their" bastard, and that is preferable to the alternative.

I'm not trying to talk anyone out of coming here, far from it. Many of these issues are the same that we encounter in the US, but here unlike the US people are much more open about their prejudices and much more determined to stick to their guns. It's awful and interesting and familiar all at the same time.


text:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
	id="WebApp_ID" version="3.1">

	<!-- Nome da Aplicação -->
	<display-name>AgendaLab</display-name>

	<welcome-file-list>
		<welcome-file>pages/index.xhtml</welcome-file>
	</welcome-file-list>

	<!-- Localização do faces-config.xml -->
	<context-param>
		<param-name>javax.faces.CONFIG_FILES</param-name>
		<param-value>/WEB-INF/faces-config.xml</param-value>
	</context-param>

	<!-- Estátio do Projeto -->

	<context-param>
		<param-name>javax.faces.PROJECT_STAGE</param-name>
		<param-value>Development</param-value>
	</context-param>

	<!-- Tema do PrimeFaces -->
	<context-param>
		<param-name>primefaces.THEME</param-name>
		<param-value>aristo</param-value>
	</context-param>

	<!-- Configuracao JSF -->
	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.xhtml</url-pattern>
	</servlet-mapping>

</web-app>


text:
 [
   Main Table Of Contents
| Table Of Contents
| Keyword Index
| Categories
| Modules
| Applications
 ]

textutil::expander(n) 1.3.1 tcllib "Text and string utilities, macro processing"

Name

textutil::expander - Procedures to process templates and expand text.

Table Of Contents

Table Of Contents

Synopsis

Description

EXPANDER API

TUTORIAL

Basics

Embedding Macros

Writing Macro Commands

Changing the Expansion Brackets

Customized Macro Expansion

Using the Context Stack

HISTORY

Bugs, Ideas, Feedback

See Also

Keywords

Category

Copyright

Synopsis

package require Tcl 8.2

package require textutil::expander ?1.3.1?

::textutil::expander expanderName

expanderName cappend text

expanderName cget varname

expanderName cis cname

expanderName cname

expanderName cpop cname

expanderName ctopandclear

expanderName cpush cname

expanderName cset varname value

expanderName cvar varname

expanderName errmode newErrmode

expanderName evalcmd ?newEvalCmd?

expanderName expand string ?brackets?

expanderName lb ?newbracket?

expanderName rb ?newbracket?

expanderName reset

expanderName setbrackets lbrack rbrack

expanderName textcmd ?newTextCmd?

expanderName where

Description

The Tcl subst command is often used to support a kind of
template processing. Given a string with embedded variables or
function calls, subst will interpolate the variable and function
values, returning the new string:

    % set greeting "Howdy"
    Howdy
    % proc place {} {return "World"}
    % subst {$greeting, [place]!}
    Howdy, World!
    %

By defining a suitable set of Tcl commands, subst can be used to
implement a markup language similar to HTML.

The subst command is efficient, but it has three drawbacks for
this kind of template processing:

There's no way to identify and process the plain text between two
embedded Tcl commands; that makes it difficult to handle plain text in
a context-sensitive way.

Embedded commands are necessarily bracketed by [ and
]; it's convenient to be able to choose different brackets
in special cases.  Someone producing web pages that include a large
quantity of Tcl code examples might easily prefer to use <<
and >> as the embedded code delimiters instead.

There's no easy way to handle incremental input, as one might wish to
do when reading data from a socket.

At present, expander solves the first two problems; eventually it will
solve the third problem as well.

The following section describes the command API to the expander; this
is followed by the tutorial sections, see TUTORIAL.

EXPANDER API

The textutil::expander package provides only one command,
described below. The rest of the section is taken by a description of
the methods for the expander objects created by this command.

::textutil::expander expanderName

The command creates a new expander object with an associated Tcl
command whose name is expanderName. This command may be used to
invoke various operations on the graph. If the expanderName is
not fully qualified it is interpreted as relative to the current
namespace.  The command has the following general form:

expanderName option ?arg arg ...?

Option and the args determine the exact behavior of the
command.

The following commands are possible for expander objects:

expanderName cappend text

Appends a string to the output in the current context.  This command
should rarely be used by macros or application code.

expanderName cget varname

Retrieves the value of variable varname, defined in the current
context.

expanderName cis cname

Determines whether or not the name of the current context is
cname.

expanderName cname

Returns the name of the current context.

expanderName cpop cname

Pops a context from the context stack, returning all accumulated
output in that context.  The context must be named cname, or an
error results.

expanderName ctopandclear

Returns the output currently captured in the topmost context and
clears that buffer. This is similar to a combination of cpop
followed by cpush, except that internal state (brackets) is
preserved here.

expanderName cpush cname

Pushes a context named cname onto the context stack.  The
context must be popped by cpop before expansion ends or an
error results.

expanderName cset varname value

Sets variable varname to value in the current context.

expanderName cvar varname

Retrieves the internal variable name of context variable
varname; this allows the variable to be passed to commands like
lappend.

expanderName errmode newErrmode

Sets the macro expansion error mode to one of nothing,
macro, error, or fail; the default value is
fail.  The value determines what the expander does if an
error is detected during expansion of a macro.

fail

The error propagates normally and can be caught or ignored by the
application.

error

The macro expands into a detailed error message, and expansion
continues.

macro

The macro expands to itself; that is, it is passed along to the output
unchanged.

nothing

The macro expands to the empty string, and is effectively ignored.

expanderName evalcmd ?newEvalCmd?

Returns the current evaluation command, which defaults to
uplevel #0.  If specified, newEvalCmd will be saved for
future use and then returned; it must be a Tcl command expecting one
additional argument: the macro to evaluate.

expanderName expand string ?brackets?

Expands the input string, replacing embedded macros with their
expanded values, and returns the expanded string.

Note that this method pushes a new (empty) context on the stack of
contexts while it is running, and removes it on return.

If brackets is given, it must be a list of two strings; the
items will be used as the left and right macro expansion bracket
sequences for this expansion only.

expanderName lb ?newbracket?

Returns the current value of the left macro expansion bracket; this is
for use as or within a macro, when the bracket needs to be included in
the output text.  If newbracket is specified, it becomes the new
bracket, and is returned.

expanderName rb ?newbracket?

Returns the current value of the right macro expansion bracket; this
is for use as or within a macro, when the bracket needs to be included
in the output text.  If newbracket is specified, it becomes the
new bracket, and is returned.

expanderName reset

Resets all expander settings to their initial values.  Unusual results
are likely if this command is called from within a call to
expand.

expanderName setbrackets lbrack rbrack

Sets the left and right macro expansion brackets.  This command is for
use as or within a macro, or to permanently change the bracket
definitions.  By default, the brackets are [ and
], but any non-empty string can be used; for example,
< and > or (* and *) or even
Hello, and World!.

expanderName textcmd ?newTextCmd?

Returns the current command for processing plain text, which defaults
to the empty string, meaning identity. If specified,
newTextCmd will be saved for future use and then returned; it
must be a Tcl command expecting one additional argument: the text to
process. The expander object will this command for all plain text it
encounters, giving the user of the object the ability to process all
plain text in some standard way before writing it to the output. The
object expects that the command returns the processed plain text.

Note that the combination of "textcmd plaintext"
is run through the evalcmd for the actual evaluation. In other
words, the textcmd is treated as a special macro implicitly
surrounding all plain text in the template.

expanderName where

Returns a three-element list containing the current character
position, line, and column the expander is at in the processing of the
current input string.

TUTORIAL

Basics

To begin, create an expander object:

    % package require textutil::expander
    1.2
    % ::textutil::expander myexp
    ::myexp
    %

The created ::myexp object can be used to expand text strings
containing embedded Tcl commands.  By default, embedded commands are
delimited by square brackets.  Note that expander doesn't attempt to
interpolate variables, since variables can be referenced by embedded
commands:

    % set greeting "Howdy"
    Howdy
    % proc place {} {return "World"}
    % ::myexp expand {[set greeting], [place]!}
    Howdy, World!
    %

Embedding Macros

An expander macro is simply a Tcl script embedded within a text
string.  Expander evaluates the script in the global context, and
replaces it with its result string.  For example,

    % set greetings {Howdy Hi "What's up"}
    Howdy Hi "What's up"
    % ::myexp expand {There are many ways to say "Hello, World!":
    [set result {}
    foreach greeting $greetings {
	append result "$greeting, World!\\n"
    }
    set result]
    And that's just a small sample!}
    There are many ways to say "Hello, World!":
    Howdy, World!
    Hi, World!
    What's up, World!
    And that's just a small sample!
    %

Writing Macro Commands

More typically, macro commands are used to create a markup
language.  A macro command is just a Tcl command that returns an
output string.  For example, expand can be used to implement a generic
document markup language that can be retargeted to HTML or any other
output format:

    % proc bold {} {return "<b>"}
    % proc /bold {} {return "</b>"}
    % ::myexp expand {Some of this text is in [bold]boldface[/bold]}
    Some of this text is in <b>boldface</b>
    %

The above definitions of bold and /bold returns HTML, but
such commands can be as complicated as needed; they could, for
example, decide what to return based on the desired output format.

Changing the Expansion Brackets

By default, embedded macros are enclosed in square brackets,
[ and ].  If square brackets need to be
included in the output, the input can contain the lb and
rb commands.  Alternatively, or if square brackets are
objectionable for some other reason, the macro expansion brackets can
be changed to any pair of non-empty strings.

The setbrackets command changes the brackets permanently.
For example, you can write pseudo-html by change them to <
and >:

    % ::myexp setbrackets < >
    % ::myexp expand {<bold>This is boldface</bold>}
    <b>This is boldface</b>

Alternatively, you can change the expansion brackets temporarily by
passing the desired brackets to the expand command:

    % ::myexp setbrackets "\\[" "\\]"
    % ::myexp expand {<bold>This is boldface</bold>} {< >}
    <b>This is boldface</b>
    %

Customized Macro Expansion

By default, macros are evaluated using the Tcl uplevel #0
command, so that the embedded code executes in the global context.
The application can provide a different evaluation command using
evalcmd; this allows the application to use a safe
interpreter, for example, or even to evaluated something other than
Tcl code.  There is one caveat: to be recognized as valid, a macro
must return 1 when passed to Tcl's "info complete" command.

For example, the following code "evaluates" each macro by returning
the macro text itself.

    proc identity {macro} {return $macro}
    ::myexp evalcmd identity

Using the Context Stack

Often it's desirable to define a pair of macros which operate in some
way on the plain text between them.  Consider a set of macros for
adding footnotes to a web page: one could have implement something
like this:

    Dr. Pangloss, however, thinks that this is the best of all
    possible worlds.[footnote "See Candide, by Voltaire"]

The footnote macro would, presumably, assign a number to this
footnote and save the text to be formatted later on.  However, this
solution is ugly if the footnote text is long or should contain
additional markup.  Consider the following instead:

    Dr. Pangloss, however, thinks that this is the best of all
    possible worlds.[footnote]See [bookTitle "Candide"], by
    [authorsName "Voltaire"], for more information.[/footnote]

Here the footnote text is contained between footnote and
/footnote macros, continues onto a second line, and contains
several macros of its own.  This is both clearer and more flexible;
however, with the features presented so far there's no easy way to do
it.  That's the purpose of the context stack.

All macro expansion takes place in a particular context.  Here, the
footnote macro pushes a new context onto the context stack.
Then, all expanded text gets placed in that new context.
/footnote retrieves it by popping the context.  Here's a
skeleton implementation of these two macros:

    proc footnote {} {
        ::myexp cpush footnote
    }
    proc /footnote {} {
        set footnoteText [::myexp cpop footnote]
        # Save the footnote text, and return an appropriate footnote
        # number and link.
    }

The cpush command pushes a new context onto the stack; the
argument is the context's name.  It can be any string, but would
typically be the name of the macro itself.  Then, cpop
verifies that the current context has the expected name, pops it off
of the stack, and returns the accumulated text.

Expand provides several other tools related to the context stack.
Suppose the first macro in a context pair takes arguments or computes
values which the second macro in the pair needs.  After calling
cpush, the first macro can define one or more context
variables; the second macro can retrieve their values any time before
calling cpop.  For example, suppose the document must specify
the footnote number explicitly:

    proc footnote {footnoteNumber} {
        ::myexp cpush footnote
        ::myexp csave num $footnoteNumber
        # Return an appropriate link
    }
    proc /footnote {} {
        set footnoteNumber [::myexp cget num]
        set footnoteText [::myexp cpop footnote]
        # Save the footnote text and its footnoteNumber for future
        # output.
    }

At times, it might be desirable to define macros that are valid only
within a particular context pair; such macros should verify that they
are only called within the correct context using either cis
or cname.

HISTORY

expander was written by William H. Duquette; it is a repackaging
of the central algorithm of the expand macro processing tool.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category textutil of the
Tcllib Trackers.
Please also report any ideas for enhancements you may have for either
package and/or documentation.

See Also

[uri, http://www.wjduquette.com/expand, regexp, split, string

Keywords

string, template processing, text expansion

Category

Documentation tools

Copyright

Copyright © William H. Duquette, http://www.wjduquette.com/expand


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<title>Digital Land Charges</title>

	<link rel="stylesheet" href="/public/stylesheets/styles.css">
	<link rel="stylesheet" href="/public/stylesheets/elements.css">
	<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'>

{{>includes/header}}

Home

		      	Bankruptcies

						Applications:

						Registrations (11)

						Amendments (9)

						Cancellations (14)

						Searches (27)

						Office copies (3)

		      	Land Charges

						Applications:

						Registrations (13)

						Amendments (6)

						Cancellations (2)

						Searches (34)

						Office copies (4)

		      	Agricultural Credits

						Applications:

						Lorum ipsum (6)

						Seremus sempre (2)

						Caesar romanus (12)

						Mentorares (9)

						Dolore causare (2)

		      	Index of Proprietors

						Applications:

						Sucumbare (5)

						Aliquam pensare (27)

						Sentra caligulas (14)

						Migus pintare (2)

						Sandalias est (7)

Land Registry Digital Service

The Land Registry are working with The Government Digital Service (GDS) to build a new digital service. The service will form a part of GOV.UK and is currently in alpha phase following guidance in the Government Service Design Manual in order to meet the Government Digital By Default Service Standard.

			The service is being built in the open, with the code developed as open source, and the architecture and other documentation published under the open government licence.

Digital Land Charges

P334 Digital Land Charges work package - The following functions are carried out by the Land Charges department:

			• Agricultural Credits

			• Bankruptcy

			• Land Charges

			The current IT solution for Land Charges is difficult to maintain, being developed many years ago and using old technology. There is currently a reliance upon paper based systems and processes (particularly in the Agricultural Credits arena). With the new Insolvency rules that are expected to come into effect April 2016, there is an opportunity to work with the Insolvency Service to provide a better user experience to benefit all.

			The current Alpha activities are to create a digital service to enable Business to Business (B2B) automated processing between Insolvency Service and the Land Charges Bankruptcy Index.

			Subject to passing the GDS Service Delivery Assessment at end of Alpha, the service will move into a wider scoped Beta phase.

			Dev Wiki

Help & support

Project team & stakeholders

P334 team

Practice guides

Technical support

{{>includes/footer}}


text:
package tcell

// initialize is used at application startup, and sets up the initial values
// including file descriptors used for terminals and saving the initial state
// so that it can be restored when the application terminates.
func (t *tScreen) initialize() error {
	var err error
	if t.tty == nil {
		t.tty, err = NewDevTty()
		if err != nil {
			return err
		}
	}
	return nil
}