Tutorial by Examples: ect

It's possible to have multiple .NET Core SDKs and Runtimes available on disk. You can select the versions for each separately. To select the version of the SDK to use, use global.json. To select the version of the shared framework to use, target the specified framwork in the .csproj file (or proj...
Like iOS where you use @IBOutlet and @IBAction, here you could use them too. Let's say we have a button which when clicked changes the label's text to something else. To get started: Add a WKInterfaceLabel and a WKInterfaceLabel to the InterfaceController. Ctrl-Drag from the WKInterfaceL...
package main import ( "fmt" "time" log "github.com/Sirupsen/logrus" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) var mongoConn *mgo.Session type MongoDB_Conn struct { Host string `json:"Host"` ...
When applied on a map, returns a new map with new or updated key val pairs. It can be used to add new information in existing map. (def userData {:name "Bob" :userID 2 :country "US"}) (assoc userData :age 27) ;; { :name "Bob" :userID 2 :country "US&qu...
/** * Add meta box to post types. * * @since 1.0.0 */ function myplugin_add_meta_box() { // Set up the default post types/ $types = array( 'post', ); // Optional filter for adding the meta box to more types. Uncomment to use. // $types = apply_filters( 'mypl...
Go to File -> Project Structure -> Modules. Add new Hibernate module. Right click on the desired module -> Add -> Hibernate. Select the newly created Hibernate configuration option, and click the (+) sign in the right pane to create hibernate.cfg.xml file. Go to File -> Project ...
Object1 := nil; Object2 := nil; try Object1 := TMyObject.Create; Object2 := TMyObject.Create; finally Object1.Free; Object2.Free; end; If you do not initialize the objects with nil outside the try-finally block, if one of them fails to be created an AV will occur on the finally bl...
Let's say you use Webpack for front end bundling. You can add webpack-dev-middleware to serve your statics through tiny and fast server. It allows you to automatically reload your assets when content has changed, serve statics in memory without continuously writing intermediate versions on disk. Pr...
You can create a New Project in Android Studio and then add Kotlin support to it or modify your existing project. To do it, you have to: Add dependency to a root gradle file - you have to add the dependency for kotlin-android plugin to a root build.gradle file. buildscript { repositorie...
This is the simplest way to connect. First, the driver has to be registered with java.sql.DriverManager so that it knows which class to use. This is done by loading the driver class, typically with java.lang.Class.forname(<driver class name>). /** * Connect to a PostgreSQL database. *...
Instead of specifying connection parameters like user and password (see a complete list here) in the URL or a separate parameters, you can pack them into a java.util.Properties object: /** * Connect to a PostgreSQL database. * @param url the JDBC URL to connect to. Must start with "jdbc:...
It is common to use javax.sql.DataSource with JNDI in application server containers, where you register a data source under a name and look it up whenever you need a connection. This is code that demonstrates how data sources work: /** * Create a data source with connection pool for PostgreSQL c...
Given the following class: public class FinalizableObject { public FinalizableObject() { Console.WriteLine("Instance initialized"); } ~FinalizableObject() { Console.WriteLine("Instance finalized"); } } A program that create...
Rule of thumb: when garbage collection occurs, "live objects" are those still in use, while "dead objects" are those no longer used (any variable or field referencing them, if any, has gone out of scope before the collection occurs). In the following example (for convenience, Fi...
What if two (or several) otherwise dead objects reference one another? This is shown in the example below, supposing that OtherObject is a public property of FinalizableObject: var obj1 = new FinalizableObject1(); var obj2 = new FinalizableObject2(); obj1.OtherObject = obj2; obj2.OtherObject = ...
As Dispose() and finalizers are aimed to different purposes, a class managing external memory-heavy resources should implement both of them. The consequence is writing the class so that it handles well two possible scenarios: When only the finalizer is invoked When Dispose() is invoked first and...
The common case for injecting dependencies into a class is with constructor injection. This involves annotating a constructor on the class with @Inject. The CDI manager will look for a constructor with the @Inject annotation when creating an instance of the class. When it finds an @Inject-annotated ...
The same example from above can also be done using what is known as field injection. Instead of annotating the constructor with @Inject, we annotate the fields we wish to have injected public class Spaceship { @Inject private PropulsionSystem propulsionSystem; @Inject private ...
// db.js const mysql = require('mysql'); const pool = mysql.createPool({ connectionLimit : 10, host : 'example.org', user : 'bob', password : 'secret', database : 'my_db' }); module.export = { getConnection: (callback) => { retu...
Now open the document using OpenXML, you must add an imagePart that references the picture object to the MainDocumentPart object by using a file stream, and get the ID of the image string temp; MainDocumentPart mainPart = document.MainDocumentPart; ImagePart ima...

Page 90 of 99