cheat.sh icon indicating copy to clipboard operation
cheat.sh copied to clipboard

Default intro page for programming language sections (e.g. /csharp/)

Open davidlfox opened this issue 7 years ago • 3 comments
trafficstars

e.g. https://cheat.sh/csharp shows the following:

image

davidlfox avatar Jul 17 '18 14:07 davidlfox

You mean this for Python?

# Python is a high-level programming language
# and python is a Python interpreter.

# Basic example of server with python
# Will start a Web Server in the current directory on port 8000
# go to http://127.0.0.1:8000
#
# Python v2.7
python -m SimpleHTTPServer
# Python 3
python -m http.server 8000

# SMTP-Server for debugging, messages will be discarded, and printed on stdout.
python -m smtpd -n -c DebuggingServer localhost:1025

# Pretty print a json
python -mjson.tool

# See also:
#   Python language cheat sheets at /python/
#   list of pages:      /python/:list
#   learn python:       /python/:learn
#   search in pages:    /python/~keyword

Yes, currently it shows nothing, but we soon special "menu" page will be shown for all languages including csharp.

What command line C#-related commands would you include in this menu? Do you have any ideas? What would you like to see there?

chubin avatar Jul 17 '18 20:07 chubin

I guess I was just pinging some different URL's and nothing C# was working. Is C# implemented?

davidlfox avatar Aug 02 '18 14:08 davidlfox

I have checked a couple of queries, and everything works like a charm:

$ curl cht.sh/csharp/copy+file
// C# Copy a file to another location with a different name

System.IO.File.Copy(oldPathAndName, newPathAndName);

// [Marc Gravell] [so/q/3881450] [cc by-sa 3.0]

$ curl cht.sh/csharp/sort+list
/*
 * c# - How to Sort a List<T> by a property in the object
 * 
 * The easiest way I can think of is to use Linq:
 */

List<Order> SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();

// [Lazarus] [so/q/3309188] [cc by-sa 3.0]

$ curl cht.sh/csharp/create+file
/*
 * c# - Create a .txt file if doesn't exist, and if it does append a ...
 * 
 * Use the correct constructor (http:msdn.microsoft.com/en-
 * us/library/36b035cb.aspx):
 */

else if (File.Exists(path))
{
    using(var tw = new StreamWriter(path, true))
    {
        tw.WriteLine("The next line!");
    }
}

// [Daniel Hilgarth] [so/q/9907682] [cc by-sa 3.0]

All queries were just random, first things I thought about. And all of them were 100% hit. Please try you too

chubin avatar Aug 02 '18 19:08 chubin