Category Archives: Software Development

Emulating the Linux tail Command Using Windows PowerShell

This post is still in progress.

If you’ve ever developed software on a Linux system, you’ve no doubt used the tail command to print out lines as they are added to the end of a log file. The tail command is used something like this:

$ tail -f /var/log/mylogfile.log

You can accomplish the same task using Windows PowerShell. At the shell prompt, use the Get-Content cmdlet. (Cmdlets are what commands are called in the PowerShell environment). The syntax is fairly simple.

> get-content mylogfile.log –wait

Get-Content is …

mylogfile.log is the name of the log file.

-wait is …

You can also use gc, cat, and type as aliases for Get-Content.

> gc mylogfile.log –wait
> cat mylogfile.log –wait
> type mylogfile.log –wait

You can also filter the log right at the command line using regular expressions:

> get-content mylogfile.log -wait | where { $_ -match "ERROR" }

More Information

Using the Get-Content Cmdlet”. Microsoft Technet.

Cool Characters for Facebook, Etc.

𝕃𝕠𝕠𝕜 𝕒𝕥 𝕨𝕙𝕒𝕥 𝕀 𝕔𝕒𝕟 𝕕𝕠!   Lᴏᴏᴋ ᴀᴛ ᴡʜᴀᴛ I ᴄᴀɴ ᴅᴏ!   Lоок дт шндт Ї cди dо!

I can make fancy characters to put in Facebook posts and other places where I’m limited to characters with no formatting options.

This is your basic set of alphanumeric characters: the capital letters A–Z, the lower-case letters a–z, and the digits 0–9. The conversions only work on alphanumeric characters.

ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789

Most of the double struck letters are mathematical symbols, but they look cool.

𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ 𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫 𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡

With the conversion to small caps letters, only the lower-case letters get converted to small capital letters.

ABCDEFGHIJKLMNOPQRSTUVWXYZ ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ 0123456789

The fake Cyrillic writing is just what it says: fake Cyrillic writing. It doesn’t really mean anything in Russian, Ukrainian, or any other language.

ДBCDЄFБHЇJКLMИОPQЯЅTЦVШЖЏZ двcdєfgнїjкlмиоpqяšтцvшжуz 012З456789

Type your message in the box below and click the Convert My Message button. Your message will be converted to all three styles.


 

Double Struck:

Small Caps:

Fake Cyrillic:

Windows: How to Enter Unicode Characters via the Keypad

If you’ve used Windows for any length of time you’re probably familiar with entering special characters with the ALT+ method. For example, to enter “É” — Latin Capital Letter E with Acute, Unicode code point U+00C9 — you can hold down the ALT key and while continuing to hold it down, type 0201 on the numeric keypad, then release the ALT key. It doesn’t take long before you’ve memorized the characters you use frequently.

There are some problems with this method. The original PCs used CP437 (code page 437) keyboard mapping for English. When Windows came along, CP1252 (code page 1252) began to be used for keyboard mapping. If you use the ALT+ method with a three-digit code (the first digit non-zero), for example, ALT+201, you get “╔”— Box Drawings Double Down and Right, Unicode code point U+2554 — the character at CP437’s code point 201. If you add a leading zero (0) and then the number, ALT+0201, you get “É”, the character at CP1252’s code point 201. Confusing, right?

Continue reading

Navigator.Geolocation

The Navigator.Geolocation post has been moved to its own page in the Software Development » Web Development section. The original post has been expanded to include more information. You can find it here.

In the meantime, here’s where your browser thinks you are. Sometimes it takes a few seconds to return the geolocation information. Please be patient.

The geolocation information is calculated on YOUR device. IX23 does not have access to this information.

Converting Between Julian Dates and Gregorian Calendar Dates in Fortran (and JavaScript)

When looking through some of my old papers I found at my father’s house after he died, I found some old Fortran code for converting Gergorian calendar dates to and from Julian dates. I haven’t used Fortran since the 1970s, so the code looked a little strange.

Some examples of Julian dates:

Julian Date Equivalent Gregorian Date
2369916.0 July 4, 1776 12:00:00.0 UT
2436911.509722 December 9, 1959 00:14:00.0 UT (the time of my birth)
2457533.5 May 25, 2016 00:00:00.0 UT

Julian dates are a continuous count of days since Greenwich Mean Noon on January 1, 4713 BCE. January 1, 4713 BCE is also known as -4712 January 1 when used for astronomical calculations. The apparent one year difference is due to there being no year 0—the day after December 31, 1 BCE was January 1, 1 CE. It makes adding and subtracting dates easier.

Greenwich Mean Noon is 12:00 noon UT (Universal Time). UT is a time standard based on Earth’s rotation. It is a modern continuation of Greenwich Mean Time (GMT), i.e., the mean solar time on the Prime Meridian at Greenwich, London, UK. In fact, the expression “Universal Time” is ambiguous when accuracy of better than a few seconds is required, as there are several versions of it, the most commonly used being Coordinated Universal Time (UTC) and UT1. All of these versions of UT, except for UTC, are based on Earth’s rotation relative to distant celestial objects (stars and quasars), but with a scaling factor and other adjustments to make them closer to solar time. UTC, on the other hand, is based on International Atomic Time, with leap seconds added to keep it within 0.9 second of UT1.

Continue reading

Truncating Numbers in JavaScript

I needed a function to truncate a number. Math.floor() worked … until I tried it on a negative number.

So I had to write my own truncate function. Even though I needed to truncate numbers to the integer portion only, I figured sooner or later I would need to truncate to a given number of decimal places. This function does that.

<script>// <![CDATA[
function ccTruncate(number, places) {
    var shift = Math.pow(10, places);
    return ((number * shift) | 0) / shift;
};
// ]]></script>

If you find this useful, let me know in the comments below.

JavaScript Browser Properties

Originally published on May 25, 2016.

This post discusses some of the browser properties that can be found through JavaScript.

C = Google Chrome
S = Mozilla SeaMonkey 2.40

window
Property B Value
window.navigator S
navigator
Property B Value
navigator.userAgent CS
navigator.appName S
navigator.appCodeName S
navigator.appVersion S
navigator.buildID S
navigator.product S
navigator.productSub S
navigator.vendor S
navigator.vendorSub S
navigator.oscpu S
navigator.platform S
navigator.language S
navigator.languages S
navigator.doNotTrack S
navigator.cookieEnabled S
navigator.onLine S
navigator.battery S
navigator.mediaDevices S
navigator.geolocation S
navigator.mozApps S
navigator.mozContacts S
navigator.mimeTypes S
navigator.plugins S
navigator.getBattery S
navigator.vibrate S
navigator.javaEnabled S
navigator.getGamepads S
navigator.mozGetUserMedia S
navigator.sendBeacon S
navigator.registerProtocolHandler S
navigator.registerContentHandler S
navigator.taintEnabled S
screen
Property B Value
screen.width S
screen.height S
screen.availWidth S
screen.availHeight S
screen.top S
screen.left S
screen.availTop S
screen.availLeft S
screen.colorDepth S
screen.pixelDepth S
screen.mozOrientation S
screen.mozLockOrientation S
screen.mozUnlockOrientation S
location
Property B Value
location.href CS
location.hostname CS
location.pathname CS
location.protocol CS
Window Inner Width CS  pixels
Window Inner Height CS  pixels
window.innerHeight CS
document.documentElement.clientHeight CS
document.body.clientHeight CS
See also document.documentElement.clientHeight and window.innerHeight.
screen.colorDepth CS -bit
screen.pixelDepth CS -bit
screen.colorDepth CS -bit
document
Property B Value
document.lastModified CS
document.head
Property B Value
document.head.lang
document.head.title

Window Object

<script>// <![CDATA[
    document.write(window);
// ]]></script>
<script>// <![CDATA[ for (x in window) {     document.write("<b>" + x + " :</b> " + window[x].toSource() + "
"); } // ]]></script>

Navigator Object

It is not necessary to specify window before the navigator object. Either window.navigator and navigator will produce the same result.

<script>// <![CDATA[
    document.write(navigator);
// ]]></script>
<script>// <![CDATA[
for (x in navigator) {
    document.write("<b>" + x + " :</b> " + navigator[x].toSource() + "
"); } // ]]></script>

navigator.userAgent

It is not necessary to specify window before the navigator object. Either window.navigator and navigator will produce the same result.

123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789- ↩
<script>// <![CDATA[
    document.write(navigator.userAgent);
// ]]></script>

navigator.geolocation

getCurrentPosition : function getCurrentPosition() { [native code] }
watchPosition : function watchPosition() { [native code] }
clearWatch : function clearWatch() { [native code] }

<script>// <![CDATA[
if ("geolocation" in navigator) {
    /* Geolocation is available. */
    var latitude, longitude, accuracy;
    var options = {
        enableHighAccuracy: true,
        timeout: 5000,
        maximumAge: 0
    }
    for (x in navigator.geolocation) {
            document.write("<b>" + x + " :</b> "
                + navigator.geolocation[x] + "<br />");
    }
    function success(pos) {
        var crd = pos.coords;
        latitude = crd.latitude;
        longitude = crd.longitude;
        accuracy = crd.accuracy;
        var googleMapsLink = "http://maps.google.com/?q="
            + latitude + "," + longitude + "&t=k&z=20";
        document.getElementById("geolocation-demo").innerHTML =
            "It looks like you are at "
            + latitude + " "
            + longitude + ", ±"
            + accuracy + " meters.<br />See it on <a href=\""
            + googleMapsLink + "\" target=\"_blank\">Google Maps</a>.<br />";
    }
    function error(err) {
        document.getElementById("geolocation-demo").innerHTML =
            "ERROR(" + err.code + "): " + err.message + "<br />";
    }
    navigator.geolocation.getCurrentPosition(success, error, options);
} else {
    /* Geolocation is not available. */
    document.getElementById("geolocation-demo").innerHTML =
        "Geolocation is not available.<br />";
}
// ]]></script>
<p id="geolocation-demo"></p>

Screen Object

<script>// <![CDATA[
for (x in screen) {
    document.write("<b>" + x + " :</b> " + screen[x].toSource() + "
"); } // ]]></script>p

screen.width

screen.height

screen.availWidth

screen.availHeight

screen.top

screen.left

screen.availTop

screen.availLeft

screen.colorDepth

screen.pixelDepth

screen.mozOrientation

screen.mozLockOrientation()

screen.mozUnlockOrientation()

Location Object

History Object

Document Object

document.lastModified

<script>// <![CDATA[
    document.write(document.lastModified);
// ]]></script>

document.head Object

<script>// <![CDATA[
    document.write(document.head);
// ]]></script>

Dump of document.head Object

<script>// <![CDATA[
for (x in document.head) {
    document.write("<b>" + x + ":</b> " + document.head[x].toSource() + "<br />");
}
// ]]></script>


WordPress Issue: Characters Replaced By Images (Solved)

When I was creating the “Unicode Character Code Chart: Arrows (2190–21FF)” page, I found that WordPress had replaced some of the characters in the code chart with some kind of images.

Screenshot 2016-05-22 1

Screenshot 1: Some of the characters had been replaced by images.

I looked the page’s source code and saw the HTML that I was expecting to see. In the glyph column for the UP DOWN ARROW (&#x2195;) code point, the characters was displayed as ↕. I tried retyping a couple of the problem glyphs to see if I had inadvertently added some hidden characters. No luck.

After a little bit of searching on Google I found that WordPress has a new “feature” that automatically replaces some characters with emojis.

After a quick search I found the “Disable Emojis” plugin. The plugin’s description says, “This plugin disables the new emoji functionality in WordPress 4.2.” That sounded like just what I was looking for, so I installed it, refreshed the page, and it fixed the problem.

Screenshot 2016-05-22 2

Screenshot 2: Problem solved.

What Is the Difference Between <button> and <input type="button">?

Question

What is the difference between <button> and <input type="button">?

Answer

From “17.5 The BUTTON element” in the HTML 4.01 Specification:

Buttons created with the button element function just like buttons created with the input element, but they offer richer rendering possibilities: the button element may have content. For example, a button element that contains an image functions like and may resemble an input element whose type is set to “image”, but the button element type allows content.

References

Raggett, Dave, ed. “HTML 4.01 Specification”. W3C Recommendation. World Wide Web Consortium (W3C). December 24, 1999.