Tutorial by Examples: code

While System.Diagnostics.Contracts is included within the .Net Framework. To use Code Contracts you must install the Visual Studio extensions. Under Extensions and Updates search for Code Contracts then install the Code Contracts Tools After the tools are installed you must enable Code Contract...
Microsoft.CSharp.CSharpCodeProvider can be used to compile C# classes. var code = @" public class Abc { public string Get() { return ""abc""; } } "; var options = new CompilerParameters(); options.GenerateExecutable = false; options.GenerateInMe...
Visual Studio Code is an open-source and feature-rich code editor from Microsoft. To set it up it for NativeScript development, open the Command Palette (F1 or ⌘+Shift+P) and type ext install NativeScript. Once the NativeScript extension is installed, the debugger should allow you to set breakpoint...
Two popular options are to use: ipython notation: In [11]: df = pd.DataFrame([[1, 2], [3, 4]]) In [12]: df Out[12]: 0 1 0 1 2 1 3 4 Alternatively (this is popular over in the python documentation) and more concisely: df.columns # Out: RangeIndex(start=0, stop=2, step=1) df[0...
We know that 'best practise' dictates that a range object should have its parent worksheet explicitly referenced. A worksheet can be referred to by its .Name property, numerical .Index property or its .CodeName property but a user can reorder the worksheet queue by simply dragging a name tab or rena...
Suppose you have complex code that creates and returns a list by starting with a blank list and repeatedly appending to it: def create(): result = [] # logic here... result.append(value) # possibly in several places # more logic... return result # possibly in several places...
To implement the hashCode method of an object easily you could use the HashCodeBuilder class. Selecting the fields: @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); builder.append(field1); builder.append(field2); builder.append(field3); ...
You can save your code snippets for use later simply by drag and drop. For eg: if you have an NSLog statement that used for so many places somewhere else in the project, then you can save the NSLog statements to code snippets library. Drag the NSLog statement to code snippet library. Now you c...
Code source View the output here using System; using System.Diagnostics; using System.IO; using PdfSharp; using PdfSharp.Drawing; using PdfSharp.Pdf; using PdfSharp.Pdf.IO; namespace HelloWorld { /// <summary> /// This sample is the obligatory Hello World program. /// &l...
The #Const directive is used to define a custom preprocessor constant. These can later be used by #If to control which blocks of code get compiled and executed. #Const DEBUGMODE = 1 #If DEBUGMODE Then Const filepath As String = "C:\Users\UserName\Path\To\File.txt" #Else Cons...
// thecontroller.js $scope.sendVerifyEmail = function() { console.log('Email sent, whaaaaam!'); currentAuth.sendEmailVerification(); } // where currentAuth came from something like this: // routerconfig .... templateUrl: 'bla.html', resolve: { currentAuth:['Auth', functio...
Step 1 GET /authorize?response_type=code&client_id=[APP_KEY]&state=[RANDOM_STRING] &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb &scope=[OPTIONAL_SCOPES] HTTP/1.1 Host: server.example.com Step 2 POST /token HTTP/1.1 Host: server.example.com Content-Type: a...
The normal obj.save() method will use the default database, or if a database router is used, it will use the database as specified in db_for_write. You can override it by using: obj.save(using='other_db') obj.delete(using='other_db') Similarly, for reading: MyModel.objects.using('other_db').al...
You create new ScriptableObject instances through ScriptableObject.CreateInstance<T>() T obj = ScriptableObject.CreateInstance<T>(); Where T extends ScriptableObject. Do not create ScriptableObjects by calling their constructors, ie. new ScriptableObject(). Creating ScriptableO...
Avoid code repetition in constructors by setting a tuple of variables with a one liner: class Contact: UIView { private var message: UILabel private var phone: UITextView required init?(coder aDecoder: NSCoder) { (message, phone) = self.dynamicType.setUp() su...
The contents of files and network messages may represent encoded characters. They often need to be converted to unicode for proper display. In Python 2, you may need to convert str data to Unicode characters. The default ('', "", etc.) is an ASCII string, with any values outside of ASCII ...
Categories provide the ability to add some extra functionality to an object without subclassing or changing the actual object. For example we want to set some custom fonts. Let's create a category that add functionality to UIFont class. Open your XCode project, click on File -> New -> File a...
There are three types of code swaps that Instant run enables to support faster debugging and running app from your code in Android Studio. Hot Swap Warm Swap Cold Swap When are each of these swaps triggered? HOT SWAP is triggered when an existing method's implementation is changed. WARM SW...
There are a few changes where instant won't do its trick and a full build and reinstall fo your app will happen just like it used to happen before Instant Run was born. Change the app manifest Change resources referenced by the app manifest Change an Android widget UI element (requires a Clean ...
One way to calculate the Big-O value of a procedure you've written is to determine which line of code runs the most times in your function, given your input size n. Once you have that number, take out all but the fastest-growing terms and get rid of the coefficents - that is the Big-O notation of yo...

Page 5 of 21