using System.Net.NetworkInformation;

public static bool PingHost(string nameOrAddress)
    bool pingable = false;
    Ping pinger = null;

        pinger = new Ping();
        PingReply reply = pinger.Send(nameOrAddress);
        pingable = reply.Status == IPStatus.Success;

Jeff Atwood posted about natural sorting. This is all about making sure that strings that contain numbers sort numerically. I’m slightly surprised to see that he wants to call it alphabetical sorting. Surely by definition, alphabetical sorting is defined by, well, the alphabet. This is an issue about numbers, not letters.

Anyway, he says he tried and gave up on a succinct C# version. He suggests that it will take 40+ lines of code. I believe that’s misleading, because as far as I can tell, the Python versions are only able to be so succinct because Python already appears to know how to sort an array. Both examples he shows rely on this. In .NET, collections aren’t intrinsically sortable.

I'm trying to bind my elements in a datatemplate that is define in dictionary. Let's make it simple.

I have a simple class

public class A { public string Data { get; set; } }

I have a simple view that contains a ListBox, with ItemSources is a list of class A:

<ListBox ItemsSource="{Binding AList}">

The point is, when I define Itemplate in view directly, bind works:

   <DataTemplate >
      <TextBlock Text="{Binding Data}" />
      <Rectangle Fill="Red" Height="10" Width="10"/>

This works great.

But when I define this ItemTemplate in ResourceDictionary, binding doesn't work?

I've got a program that adds to a log file while it's running. Over time that log file gets huge. I'd like to create a startup script which will rename and move the log file before each run, effectively creating separate log files for each run of the program.

Is it possible to limit a text length to "n" lines using CSS (or cut it when overflows vertically)?

text-overflow: ellipsis; only works for 1 line text.

Original text

Ultrices natoque mus mattis, aliquam, cras in pellentesque tincidunt elit purus lectus, vel ut aliquet, elementum nunc nunc rhoncus placerat urna! Sit est sed! Ut penatibus turpis mus tincidunt! Dapibus sed aenean, magna sagittis, lorem velit

Wanted output (2 lines)

Ultrices natoque mus mattis, aliquam, cras in pellentesque tincidunt elit purus lectus, vel ut aliquet, elementum...

How do I construct this piece of XAML programatically?

<Grid Name="gridMarkets">
        <RowDefinition Height="10" />
        <RowDefinition Height="*" MinHeight="16" />
        <ColumnDefinition Width="10" />
        <ColumnDefinition Width="Auto" />

Is it any elegant solution for parse and construct controls dynamically?

I was trying to do something:

RowDefinition newRow = new RowDefinition();
newRow.Height = new GridLength(10);

But how do I assign a * sign?

I have this code:

string m_strFilePath = "";

XmlDocument myXmlDocument = new XmlDocument();

foreach (XmlNode RootNode in myXmlDocument.ChildNodes)

but when I try to execute it, I get this error :

Exception Details: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

Why? Where am I wrong? And how can I fix this problem on C#?

Also tried with :


but I get :

Exception Details: System.Xml.XmlException: Invalid character in the given encoding. Line 1, position 503.

How can you enumerate an enum in C#?

public enum Suit

I am getting the k_BackingField in my returned json after serializing a xml file to a .net c# object.

I've added the DataContract and the DataMember attribute to the .net c# object but then I get nothing on the json, client end.

public class LinkedIn
   public string ID { get; set; }

    public string Industry { get; set; }

    public string FirstName { get; set; }

    public string LastName { get; set; }

Example of the returned json:

home: Object
<FirstName>k__BackingField: "Storefront"
<LastName>k__BackingField: "Doors"

I have a collection of person objects (IEnumerable) and each person has an age property.

I want to generate stats on the collection such as Max, Min, Average, Median, etc on this age property.

What is the most elegant way of doing this using LINQ?

I am coding a C# application where the user can specify a name and the program will return the name without the vowels. But how does the program understand that if the name contains A, E, I, O, U, Y, then the letters shall be removed.

There are several ways on how to check what version of CentOS is running on your system. The simplest way to check for the CentOS version number is to execute the cat /etc/centos-release command. Identifying the accurate CentOS version may be required to help you or your support team to troubleshoot your CentOS system.

Exposing a server to the internet might be pretty scary. You would like to limit the number of exposed services to a minimum. Probably the most powerful service on any Linux machine would be the ssh server. With it you can control the computer and let it perform literally any task. If you want to be able to control your Linux based computer, from any place on the internet you may want to guard yourself against unauthorized access.

I know that the following is true

int i = 17; //binary 10001
int j = i << 1; //decimal 34, binary 100010

But, if you shift too far, the bits fall off the end. Where this happens is a matter of the size of integer you are working with.

Is there a way to perform a shift so that the bits rotate around to the other side? I'm looking for a single operation, not a for loop.

I have the following:

window.setTimeout(function() {
    window.location.href = 'file.php';
}, 115000);

How can I, via a .click function, reset the counter midway through the countdown?

This tutorial is for setting up a MikroTik router hap-ac2, to setup to the modem/router provided by my ISP, and use the latter as just a modem.

Text diagram of network

ISP Modem (public IP) - > MikroTik on ether1 (client dhcp set to grab public IP from ISP) - > ether2-ether5 will be bridge switch offering DHCP to my lan.

In PuTTY configuration window, take Terminal > Keyboard. Change the "Function keys and keypad" setting to "Xterm R6".

Debian Linux is known for being stable and unchanging. For most, this philosophy is pretty great. Everything works well, and nothing breaks down. However, this stability comes at a cost. Often, users are stuck on an old, outdated Linux kernel.

This tutorial helps you guide setting up DHCP reservations on a Mikrotik RouterOS.

Hex: 00807f

RGB Decimal: 0, 128, 127

This page concerns on how to pass parameters on angular-translate.

SSH stands for Secure Shell. SSH is used for connecting to a remote computer accessing files and perform administrative tasks.

In this tutorial, learn how to enable SSH on Debian 9 (Stretch) or Debian 10 (Buster).

This article is dedicated to people who love to play around with there XFCE desktop (Xubuntu, Ubuntu Studio, Voyager Linux, Manjaro Linux, etc). In case you guys get stuck with any problem for xfce 4 which is not that customizable compared to the older version you can always reset it to the initial parameters.