For a while I decided to stop sharing code using “text” in my blog. I used to share a screen shoot of the code and then a link to the full example on GitHub. This seemed like a good idea, because on several occasions I had had unfortunate comments from people who performed a “copy & paste” portions of code from my blog, without even reading the complete sample.
Well, a while ago, a blind developer complained about those who shared code with images. And of course, after meeting a blind person who shared with me how he program every day, I did an evaluation and decided that it was best to go back to share code in text mode. (BTW: I wrote about this a while ago)
One of the best platforms for this is the Gists from GitHub, which gives us all the experience and appearance of GitHub. Yes, if you look for the option of doing it from the IDE, the next extension is more than useful Gists for Visual Studio.
The way to use it is quite simple, the Code Editor displays the context menu and you will see the new option “Create a new gist”
The first time we use the extension, we must authenticate in Gists. After this, the next step is to define the name of the file, a description and if we want to share all the code of the file we are working on or just the selected text.
The extension will create the Gist and share back the Url of the created one.
Sample output for the post:
|public async Task ConnectAsync()|
|_client = new TcpClient();|
|await _client.ConnectAsync(_address, 5555);|
|_stream = _client.GetStream();|
|// unlock the brick (doesn't actually need serial number?)|
|byte buff = Encoding.UTF8.GetBytes(UnlockCommand);|
|await _stream.WriteAsync(buff, 0, buff.Length);|
|// read the "Accept:EV340\r\n\r\n" response|
|int read = await _stream.ReadAsync(buff, 0, buff.Length);|
|string response = Encoding.UTF8.GetString(buff, 0, read);|
|throw new Exception("LEGO EV3 brick did not respond to the unlock command.");|
Greetings @ VSLive en Austin