Category: CopyPaste

Smart Copy and Paste from StackOverflow–part 6 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

Congratulations!

If you reached this step, that means your code[1] is tested and performs well. That also means that you are now ready for the next challenge: find again a code to solve everyday problems.


[1]yes, this is now YOUR code!

 

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Smart Copy and Paste from StackOverflow–part 5 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

Copying code into the program

If it does not compile at first attempt, see if you are missing some reference / namespaces / others.

If again does not compile, repeat previous step:" searching " and take next links. Do not bother to improve the code . Codes are everywhere – and, if it is not written well, you will discover another one that is easy to copy / paste.

Verifying code

This is the tricky part. And this is the part that you should always have , if you copy paste other people code. And never test in production[1]

Sorting

For sorting you can create a List<Person> with some real names, taken from your colleagues / acquaintances . Then you will pass through the sorting function and see if it function.

Encrypting

For this you will create 2 functions: Encrypt and Decrypt. And ensure Encrypt(Decrypt( variable )) = variable. ( Again, you can use your name or any other site url)

If again this step does not work , see if you have caused some error when coding the test. If not, repeat step:" searching " and take next links .

if the code works as needed , I think that you should add some automatic test code.


[1] http://www.digitaljournal.com/technology/man-deletes-his-entire-company-with-a-single-line-of-code/article/462851

 

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Smart Copy and Paste from StackOverflow–part 4 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

How to search for information

Sort a collection

First I want to go to our favorite search engine I will use Google[1]. I will enter "list sort"

(image in the book here)

As you see you have already some help – so a no brainer. I use "list sort <program name>"

(image in the book here)

As you see from the above image we already have some results of searching

i. The help file on MSDN

ii. The StackOverflow link

iii.Two links in dotnetperls

iv. A CodeProject link ( usually provided with source code)

Now the problem seems pretty simple – and we see that the MSDN link have also an example – and we rather copy this than going to StackOverflow. However, I do recommend reading the links – it may be beneficial.

Store encrypted data in a file

First , we want to know how to encrypt the data. Searching for "encrypt string " + language

(image in the book here)

As you see , again Stack Overflow is among the first results.

Looking at the first link, we discover some other links with a gist (https://gist.github.com/jbtule/4336842 )that we may want (or no) to copy. It looks as an advanced cryptography – so depends on our time.

1. If we have plenty of time, we may want to take the gist and understand what’s there .

2. If we do not have plenty of time, then we might as simple as copy the simplest code that do the work

Then the programmer discovers that what he has is not enough: the file that he want to wrote is an ANSI file – so he can not write bytes. Time for another searching ( Base64 , https://en.wikipedia.org/wiki/Base64 ) and to combine the solutions .

Let the browser open – it may be beneficial for next steps, if something does not function .


[1]You can also Bing – or other search engine

 

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Smart Copy and Paste from StackOverflow–part 3 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

How to solve the examples

Please put the book aside, think of the examples and consider yourself solving it.

What did you do ? Then read next pages .

Read Help

We should read help about the component ( for example , the definition of List<T> ) . No one does this . So go to next step.

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Smart Copy and Paste from StackOverflow–part 2 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

Examples in this book

1. Sort a collection

Let’s suppose we have a class Person with FirstName and LastName as properties. Also we have a collection ( List<Person>) that contains multiple persons( loaded from a database[1]). We want to let the user sort this collection for FirstName or LastName at his choice.

2. Store encrypted data in a file

Let’s suppose that we have a connection string[2] ( with user and password) to connect to a database. We want to be able change this – to accommodate software for the buyer. But we do not want to let the user know the connection string – to protect lazy database administrators. A solution is to encrypt the connection string , store it and later retrieve and decrypt it.


[1]by database I understand any physical support of storing data that can be retrieved later. It does not matter if Relational or No-SQL or text file

[2]do you know http://www.connectionstrings.com/ ?

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Smart Copy and Paste from StackOverflow–part 1 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

Introduction

When I started programming for a living (1997+), there were no sites to learn from. The access to internet was not affordable . The search engines were bad( Altavista+ Yahoo) There were some frameworks available – but mostly for graphical components( such as buttons) , PC functions( e.g. sending TPC IP messages, DDE messaging / OLE function ) and databases ( remember ISAM ?) . But for sorting a collection of elements you must learn from a book of algorithms and then make your function ( that you will re-use after in other projects). In these days you have List<T>.Sort (https://msdn.microsoft.com/en-us/library/b0zbh7b6(v=vs.110).aspx ) and you should not bothering about Quick Sort , Merge Sort, Bubble Sort or the differences between them.

The book will feature a good programmer that has to solve a problem and like to code the solution( as opposed to download some nuget/npm package[1]) . I will give two examples in order to exemplify how to do the smart copy / paste from Stack Overflow.

All I have written here is taken from my personal experience – that I consider valuable and helped me a lot in time.If you have some ideas to improve this book, please feel free to wrote to ignatandrei@yahoo.com or via my site , http://msprogrammer.serviciipeweb.ro/

Thank you to Stefan Petrini for reviewing the book.


[1]See http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.