The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘WordPress’ Category

WordPress.com #fail (new editor just as bad as old one): Another example of the editor eating line breaks « WordPress.com Forums

Posted by jpluimers on 2014/10/31

Complaint Friday…

A long time ago, I complained about the (now old!) WordPress.com editor being wrong, wrong, wrong: Another example of the editor eating line breaks « WordPress.com Forums.

The promise then was that the new editor would be better.

The big news: the new editor is just as bad in this respect (and far worse in other respects).

Just watch the text around my signature and PS in the texts below and shiver.

Lets start with the original text of my GoToWebinar blog post today:

Read the rest of this entry »

Posted in Power User, Software Development, Web Development, WordPress, WordPress | 1 Comment »

Optimal posting time? (via: Are there optimal days/hours to post questions in order to get visibility and answers? – Meta Super User)

Posted by jpluimers on 2014/09/22

A while ago, i came across this interesting question: Are there optimal days/hours to post questions in order to get visibility and answers? – Meta Super User.

The recommended time 1400 UTC is related to my blog post scheduling behaviour.

Virtually all my blog posts are either (when both apply at the same time, that is pure coincidence):

I schedule posts on Monday through Friday:

Difference between 0600 UTC and 1400 UTC

So why the time difference of about 8 hours between 0600 UTC and 1400 UTC?

That has to do with the public I generally interact with: software developers speaking English, mainly living in European and USA, with a minority in India, Asia and down-under.

  • At 0600 UTC, most Europeans are about to wake up or just arrived at work, so they get fresh content. Still quite a few people from India and Asia are up (returning from work) can read it the same day it was posted. And virtually everyone in the USA is still sleeping, so they get fresh content too.
  • At 1400 UTC, most Europeans are at work, people at the USA East Coast just started working and the rest of the USA is waking up and (hopefully) going to work. So you get a huge group of on-line people online with a high chance if comment/answer interaction on your question: great for getting answers on the same day.

“Missed Schedule” on WordPress blogs Read the rest of this entry »

Posted in Facebook, G+: GooglePlus, LifeHacker, LinkedIn, Power User, SocialMedia, Twitter, WordPress | Leave a Comment »

Remote Android screen monitoring and viewing

Posted by jpluimers on 2013/11/25

Another one in the “WordPress Missed schedule” series.

Below are the Android remote screen monitoring/viewer/mirror tools I know about:

  • For a long time, I have used Droid@Screen: an Open Source,  Java based mature cross platform tool that uses ADB (it can even restart it for you in case it hangs) with lots of features (zooming, no temporary files, device recognition, disabling emulator devices, etc). There are some Screen Shots | Droid@Screen.
  • A while ago, I saw android-screen-monitor – Android Screen Monitor – Google Project Hosting. It is a mixed Java/C++ solution that only works on Windows.
  • Recently, Jim McKeeth open sources his Android Screen View: Android Screen View | The Podcast at Delphi.org. It is written as a quick hack in Delphi XE5, so right now it has less features and works in a more crude way than the two Java based tools, but it shows the potential of doing similar things with Delphi.

I primarily use Droid@Screen as so far it works best for me.

But I keep a close eye on the other two just to make sure I don’t miss improvements.

–jeroen

Posted in Android Devices, Delphi, Delphi XE5, Development, Java, Missed Schedule, Mobile Development, Power User, SocialMedia, Software Development, WordPress | 1 Comment »

When the Delphi XE5 commandline compiler fails with `error F1026: File not found: ‘False.dpr’`

Posted by jpluimers on 2013/11/20

If you an error like below when compiling Delphi XE5 .dproj files using msbuild … then note the documentation for Debug information (Delphi) – RAD Studio. has not been updated yet as it still lists the values {$D+} or {$D-} {$DEBUGINFO ON} or {$DEBUGINFO OFF}.

(_PasCoreCompile target) -> C:\Program Files (x86)\Embarcadero\RAD Studio\12.0\Bin\CodeGear.Delphi.Targets(187,5): error F1026: File not found: 'False.dpr'

With Delphi XE5, you can specify 3 additional values: {$D1}{$D2} and {$D0}, or {$DEBUGINFO 1}{$DEBUGINFO 2} or {$DEBUGINFO 0}

In the msbuild .dproj files , the values are stored as DCC_DebugInformation elements. Read the rest of this entry »

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Missed Schedule, SocialMedia, Software Development, WordPress | 13 Comments »

Generating a WordPress posting categories page – part 3

Posted by jpluimers on 2012/09/26

Notes:

Log, Ln, Lg, Log10, LogE, Ld

Common logarithm – Wikipedia, the free encyclopedia.

Exponential_and_logarithmic_functions ISO 31-11 – Wikipedia, the free encyclopedia.

Binary logarithm – Wikipedia, the free encyclopedia.

What is logarithm(log, lg, ln).

Common Logarithms.

Why Use a Logarithmic Scale to Display Data Math Forum – Ask Dr. Math.

STRAIGHT LINE ON ARITHMETIC GRAPH PAPER (LINEAR FUNCTION)

http://www.humboldt.edu/geology/courses/geology531/531_handouts/equations_of_graphs.pdf

Font sizes

CSS font-size property.

Five simple steps to better typography – Part 4 | Mark Boulton.

A List Apart: Articles: How to Size Text in CSS.

–jeroen

Via: Generating a WordPress posting categories page – part 2 « The Wiert Corner – irregular stream of Wiert stuff.

Posted in .NET, C#, C# 4.0, C# 5.0, Development, Software Development, Web Development, WordPress | Leave a Comment »

.NET/C#: Generating a WordPress posting categories page – part 2

Posted by jpluimers on 2012/08/22

In Generating a WordPress posting categories page – part 1, you learned how to

  1. get the HTML with all the category information from your WordPress.com blog,
  2. convert that to XHTML,
  3. generate an XSD for the XHTML,
  4. generate C# classes from that XSD

This episode, you will learn how the data read from the XHTML can be transformed to a simple tree in HTML suited for a posting categories page like mine.

In the final post, the same data will be transferred into a real category cloud with font sizes indicating the frequency of the category usage.

From there, you can go into other directions (for instance generating squarified treemaps from the data).

That’s the cool thing about data: there are many ways to visualize, and this series was meant – next to some groundwork on how to get the data – as inspiration into some forms of visualization.
Hope you had fun reading it!

Getting a HTML tree from the optionType items

                StringBuilder outputHtml = new StringBuilder();
                string rootUrl = args[1];
                foreach (optionType item in select.option)
                {
                    if (item.Level == optionType.RootLevel)
                        continue;

                    // <a style="font-size: 100.3986332574%; padding: 1px; margin: 1px;" title="XML/XSD (23)" href="https://wiert.me/category/development/xmlxsd/">XML/XSD</a>
                    string url = String.Format("{0}/category{1}", rootUrl, item.HtmlPath);
                    string prefix = new string('.', item.Level * 5);// optionType.NbspEscaped.Repeat(item.Level);
                    outputHtml.AppendFormat("{0}<a title="{2}" href="{1}">{2} ({3})</a>", prefix, url, item.Category, item.Count);
                    outputHtml.AppendLine();
                }

One way of generating an HTML tree, is to prefix every node with a series of dots corresponding with the level of that node. Not the most pretty sight, but it will suffice for this episode.

Inside each node, I want to show the Category and Count.

Since the optionType as generated from the XSD only contains the below properties, a major portion on this posting is how to decode the Value so we can generate HTML like this:

...............<a href='https://wiert.me/category/development/software-development/net/c-' title='C#'>C#&nbsp;(118)</a>
....................<a href='https://wiert.me/category/development/software-development/net/c-/c--2-0' title='C# 2.0'>C# 2.0&nbsp;(46)</a>
....................<a href='https://wiert.me/category/development/software-development/net/c-/c--3-0' title='C# 3.0'>C# 3.0&nbsp;(33)</a>
....................<a href='https://wiert.me/category/development/software-development/net/c-/c--4-0' title='C# 4.0'>C# 4.0&nbsp;(31)</a>
....................<a href='https://wiert.me/category/development/software-development/net/c-/c--5-0' title='C# 5.0'>C# 5.0&nbsp;(2)</a>

Decoding the optionType Value property

optionType only contains the these properties:

  1. class
    • the class used to reference the style in the stylesheet
    • example value: “level-4”
  2. value
    • internal unique WordPress ID for the category (this allows you to alter the Slug and Value without breaking the links between posts and categories
    • example value: “45149061”
  3. Value
    • string that WordPress uses to make the category combobox look like a tree structure
    • example value: “&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C# 5.0&nbsp;&nbsp;(2)”

The extra properties needed for the HTML generation logic above are these:

  1. Category
    • the Value undone from leading non breaking space character escapes, and the trailing count information
    • example value: C# 5.0
  2. Count
    • the Value undone from leading non breaking space character escapes, Caption information, separator non breaking space character escapes, and surrounding parenthesis
    • example value: 2
  3. Level
    • the class undone from the level- prefix
    • example value: 4
  4. Slug
    • the category slug is the unique value for a category that WordPress uses to form category urls. It is auto-generated from the Category, but you can also edit it. I don’t, as it is not in the combobox HTML, so I derive it from the Category. Note there are also posting slugs used in the permalink of each post.
    • example value: c--5-0 (it consists of lowercase letters and hyphens derived from the Category)
  5. HtmlPath
  6. parent (used internally for making the HtmlPath code much easier

The really cool thing about XSD2Code is that it generated the optionType C# code as a partial class.
Which means we can extend the generated partial classes in a seperate C# file like the code fragments below (you can download it from the WordPressCategoriesDropDown.cs file at BeSharp.CodePlex.com)

    partial class optionType
    {
        public const int RootLevel = -1;

        private const string slash = "/";
        private const char hyphen = '-';
        public const string NbspEscaped = "&nbsp;";
        private const string emptyCountInParenthesis = "(-1)";

        public optionType parent { get; set; }

        public string Category
        {
            get
            {
                string result;
                string countInParenthesis;
                splitValue(out result, out countInParenthesis);
                return result;
            }
        }

        public int Count
        {
            get
            {
                string category;
                string countInParenthesis;
                splitValue(out category, out countInParenthesis);
                string count = countInParenthesis.Substring(1, countInParenthesis.Length - 2);
                int result = int.Parse(count);
                return result;
            }
        }

        public int Level
        {
            get
            {
                if (string.IsNullOrWhiteSpace(@class))
                    return RootLevel;
                string[] split = @class.Split(hyphen);
                string number = split[1];
                int result = int.Parse(number);
                return result;
            }
        }

        /// <summary>
        /// This is the HTML part that WordPress uses to reference a Category
        /// </summary>
        public string Slug
        {
            get
            {
                StringBuilder result = new StringBuilder();
                foreach (char item in Category)
                {
                    if (char.IsLetterOrDigit(item))
                        result.Append(item.ToString().ToLower());
                    else
                        if (result.Length > 0)
                            result.Append(hyphen);
                }
                return result.ToString();
            }
        }

        public string HtmlPath
        {
            get
            {
                if (RootLevel == Level)
                    return string.Empty;

                string result = Slug;
                if (null != parent)
                    result = parent.HtmlPath + slash + result;
                return result;
            }
        }

        private void splitValue(out string category, out string countInParenthesis)
        {
            // might want to do this using RegEx, but that is a write-only language https://wiert.me/category/development/software-development/regex/
            string result = Value;
            int nbspCountToStripFromLeftOfValue = Level * 3; // strip 3 &nbsp; for each Level
            for (int i = 0; i < nbspCountToStripFromLeftOfValue; i++)
            {
                int nbspEscapedLength = NbspEscaped.Length;
                if (result.StartsWith(NbspEscaped))
                    result = result.Substring(nbspEscapedLength, result.Length - nbspEscapedLength);
            }
            string doubleNbspEscaped = NbspEscaped + NbspEscaped;
            if (result.Contains(doubleNbspEscaped))
            {
                string[] separators = new string[] { doubleNbspEscaped };
                string[] split = result.Split(separators, StringSplitOptions.None);
                category = split[0];
                countInParenthesis = split[1];
            }
            else
            {
                category = result;
                countInParenthesis = emptyCountInParenthesis;
            }
        }

        public override string ToString()
        {
            string result = string.Format("Level {0}, Count {1}, Slug {2}, HtmlPath {3}, Category '{4}'", Level, Count, Slug, HtmlPath, Category);
            return result;
        }
    }

The bulk of the above code is in the splitValue method (that could have used RegEx, but I try to avoid RegEx when I can do without it).
Note that the HtmlPath propererty uses the parent property. Without it, the HtmlPath code would have been very complex. The value of the parent properties for all optionType instances is generated in the selectType.FixParents method below since the selectType instance contains all the optionType instances in its’ option property.

    partial class selectType
    {
        public void FixParents()
        {
            Stack<optionType> itemStack = new Stack<optionType>();
            optionType parent = null;
            int previousLevel = optionType.RootLevel;

            foreach (optionType item in option)
            {
                int itemLevel = item.Level;
                if (itemLevel == previousLevel)
                {
                    if (optionType.RootLevel != itemLevel)
                    {
                        itemStack.Pop();
                        item.parent = parent;
                    }
                    itemStack.Push(item);
                }
                else
                {
                    if (itemLevel > previousLevel)
                    {
                        parent = itemStack.Peek();
                    }
                    else
                    {
                        do
                        {
                            itemStack.Pop();
                            parent = itemStack.Peek();
                            previousLevel = parent.Level;
                        }
                        while (previousLevel >= itemLevel);
                    }
                    itemStack.Push(item);
                    item.parent = parent;
                    previousLevel = itemLevel;
                }
            }
        }
    }

–jeroen

Posted in .NET, C#, C# 4.0, C# 5.0, Development, LINQ, Software Development, Usability, User Experience (ux), Web Development, WordPress, WordPress, XML, XML escapes, XML/XSD, XSD | 4 Comments »

.NET/C#: Generating a WordPress posting categories page – part 1

Posted by jpluimers on 2012/07/31

From the category cloud it is hard to see that the categories are organized as a hierarchy. The combobox on the right shows that, but does not have room to properly show the hierarchy. Since WordPress.com does not allow you to deploy your own code, I worked around it in this way using a small .NET C# console program:

  1. Extract the HTML for the All Categories combobox on the right of the page.
  2. Convert that HTML to XHTML (and therefore XML)
  3. Generate XSD from that XML
  4. Generate C# class wrappers from the XSD

Future posts will show more logic on how to handle the imported information, and generate nice category overviews. Preliminary source code is at the BeSharp.net source repository.

Extract the HTML

The HTML is not fully accurate (see my post on HTML and XML escapes from last week), but it is fairly easy to extract. Most web browsers allow you to view the source of your web page. Do that, then search for “All Categories”. Now you see HTML like this:

</pre>
<h2 class="widgettitle">All categories</h2>
<pre><select class="postform" name="cat"><option value="-1">Select Category</option></select><select class="postform" name="cat"><option class="level-0" value="256">About  (66)</option></select><select class="postform" name="cat"><option class="level-1" value="64">   Personal  (60)</option></select><select class="postform" name="cat"><option class="level-2" value="20254983">      Adest Musica  (7)</option></select><select class="postform" name="cat"><option class="level-2" value="32122">      Certifications  (2)</option></select><select class="postform" name="cat">...</select><select class="postform" name="cat"><option class="level-0" value="756">Comics  (3)</option></select><select class="postform" name="cat"><option class="level-0" value="780">Development  (473)</option></select><select class="postform" name="cat"><option class="level-1" value="872460">   Database Development  (55)</option></select><select class="postform" name="cat">...</select><select class="postform" name="cat"><option class="level-0" value="9280">User Experience  (3)</option></select>

I don’t need the H2 heading line, but the rest I do need to generate XML from. I saved the HTML into a text file for processing by the console app.

Convert the HTML to XML

The HTML contains loads of &nbsp;, but XML does not allow for that entity. So the & ampersand needs to be escaped into &amp;This also solves other uses of & in the HTML. The rest of the HTML is XHTML compliant, so does not require change, which results into this C# conversion method:

        private static string toXml(string inputHtml)
        {
            string result = inputHtml.Replace("&", "&");
            return result;
        }

Generate an XSD for the XML, then amend the XSD

Given my comparison of tools for generating XSD from XML, so I used the XmlForAsp XML Schema generator, with the “Separate Complex Types” option. (Note: I will link to the XSD before/after, as WordPress – yet again – screws the XSD sourcecode in the post; this should do for now). That gives me XSD like this (XML is also at pastebin):

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="select" type="selectType" />
 <xsd:complexType name="selectType">
  <xsd:sequence>
   <xsd:element maxOccurs="unbounded" name="option" type="optionType" />
  </xsd:sequence>
  <xsd:attribute name="name" type="xsd:string" />
  <xsd:attribute name="id" type="xsd:string" />
  <xsd:attribute name="class" type="xsd:string" />
 </xsd:complexType>
 <xsd:complexType name="optionType">
  <xsd:attribute name="value" type="xsd:int" />
 </xsd:complexType>
</xsd:schema>

Which is not complete, but gives a good start. The actual XSD it needs to be like this with a more elaborate optionType complex type that also defines it’s own content as deriving from xsd:string, and adds the class attribute (XML is also at pastebin):

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="select" type="selectType" />
 <xsd:complexType name="selectType">
  <xsd:sequence>
   <xsd:element maxOccurs="unbounded" name="option" type="optionType" />
  </xsd:sequence>
  <xsd:attribute name="name" type="xsd:string" />
  <xsd:attribute name="id" type="xsd:string" />
  <xsd:attribute name="class" type="xsd:string" />
 </xsd:complexType>
 <xsd:complexType name="optionType">
  <xsd:simpleContent>
  <xsd:extension base="xsd:string">
   <xsd:attribute name="class" type="xsd:string" />
   <xsd:attribute name="value" type="xsd:int" />
  </xsd:extension>
 </xsd:simpleContent>
 </xsd:complexType>
</xsd:schema>

Generate C# classes from the XSD

You can generate C# wrapper classes using the XSD.exe tool that ships with Visual Studio, but XSD.exe is hard to use, is hard to integrate into Visual Studio (despite Microsoft Connect request for it), the XSD.exe generated code still needs work for deserializing, and XSD.exe has very limited generation options (heck, after it changed from .NET 1.x to 2.0, it hasn’t been updated for about a decade). XSD2Code has some great reviews, to I used that in stead. And indeed, very well integrates into Visual Studio 2010, and generates very nice C#, especially when you use the options (see also the screenshot on the right):

  • Under Serialization, set Enabled to True
  • Under Serialization, set GenerateXmlAttributes to True

That way, loading the HTML, converting it to XML, then deserializing it into object instances is as simple as this:

                string inputFileName = args[0];
                string inputHtml = getHtml(inputFileName);
                string xml = toXml(inputHtml);
                selectType select = selectType.Deserialize(xml);

More on actually working with the loaded instances in the next episode, including the great benefit of XSD2Code: it generates C# code as partial classes.

–jeroen

Posted in .NET, C#, C# 4.0, C# 5.0, Development, SocialMedia, Software Development, Usability, User Experience (ux), Web Development, WordPress, WordPress, XML, XML escapes, XML/XSD, XSD | 2 Comments »

Which “Posting categories” overview do you like most?

Posted by jpluimers on 2012/04/14

I’m experimenting with the Posting categories overview page as a prequel to a proper tag cloud (and a series of posts on how to get there).

Please let me know in the comments which of the below ones you like most:

  1. Left:
    HTML tree with post count per category
  2. Middle:
    HTML tree with font size indicating post count
  3. Right:
    HTML tree with post count per category and font size indicating post count

(For comparison, you need a big screen; the most popular choice will survive on the Posting categories page).

–jeroen

via: Posting categories « The Wiert Corner – irregular stream of Wiert stuff. Read the rest of this entry »

Posted in CSS, Development, HTML, Power User, SocialMedia, Software Development, Usability, User Experience (ux), Web Development, WordPress, WordPress | Leave a Comment »

Page with my WordPress posting Categories

Posted by jpluimers on 2012/04/02

I’m in the midst of writing a small app that generates trees and clouds of the WordPress categories.

The main reason is that I want to better organize the categories, so I need an overview. The multi-page WordPress Categories editor isn’t of much use as it is very hard to get an overview.

Using the [Category] WordPress tag isn’t of much help as I can’t get things like this to work (I remember seeing something like this on the forums, can’t find it any more though):
[Category]
[Category number='5' method='title' order='asc' id='11,45' orderby='comment_count']

Preliminary output is at the Posting Categories page in the top menu that I will update every once in a while.

I will post the app later, as I intend to create a category cloud in addition to the tree.

–jeroen

Posted in Development, SocialMedia, Software Development, Web Development, WordPress, WordPress | Leave a Comment »

WordPress XML sourcecode help needed; forum posts gets deleted.

Posted by jpluimers on 2012/02/23

Please one of the WordPress.com support people, contact me through my contact form.

I tried posting this question, but as you can see it is marked as ‘Topic Closed, This topic has been closed to new replies’, and looks empty on your forums’:

Please stop deleting the XML from my

</h1>
Since WordPress deletes anything but the most basic XML from 

tags:

See https://wiert.me/wp-content/uploads/2012/02/wordpress-html.doc

When I put that in a WordPress post, it deletes the XML.
It does this for anything but the most basic XML.

Please fix that!

–jeroen

Thanks in advance!

–jeroen

Posted in Development, SocialMedia, Software Development, Web Development, WordPress, WordPress | 2 Comments »