Tutorial by Examples: c

Weak references are... references, to other objects (aka "targets"), but "weak" as they do not prevent those objects from being garbage-collected. In other words, weak references do not count when the Garbage Collector evaluates objects as "live" or "dead". T...
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 ...
Server Side example Create Listener for server Start of with creating an server that will handle clients that connect, and requests that will be send. So create an Listener Class that will handle this. class Listener { public Socket ListenerSocket; //This is the socket that will listen ...
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 ...
Example of how to calculate the output shape and overcome the difficulties of using tf.nn.conv2d_transpose with unknown batch size (when input.get_shape() is (?, H, W, C) or (?, C, H, W)). def upconvolution (input, output_channel_size, filter_size_h, filter_size_w, stride_h, str...
public class DependentScopedClass { //This class has no scoping annotations, so a new instance gets created at every injection point. @Inject public DependentScopedClass(SomeDependency someDependency) { doSomethingWith(someDependency); } } The default scope for...
@RequestScoped public class RequestScopedClass { //This class gets constructed once per Servlet request, and is shared among all CDI-managed classes within that request. @Inject public RequestScopedClass(SomeDependency someDependency) { doSomethingWith(someDependency); ...
@ApplicationScoped public class ApplicationScopedClass { //This class gets constructed once for the entire life of the application, and is shared among all CDI-managed classes throughout the life of the application. @Inject public ApplicationScopedClass(SomeDependency someDependenc...
@SessionScoped public class SessionScopedClass implements Serializable { //This class gets constructed once per session, and is shared among all CDI-managed classes within that session. Notice that it implements Serializable, since the instance will get put on the session. @Inject ...
SCRIPT_DEBUG is a related constant that will force WordPress to use the "dev" versions of core CSS and JavaScript files rather than the minified versions that are normally loaded. This is useful when you are testing modifications to any built-in .js or .css files. Default is false. //enab...
The following code, inserted in your wp-config.php file, will log all errors, notices, and warnings to a file called debug.log in the wp-content directory. It will also hide the errors so they do not interrupt page generation. // Enable WP_DEBUG mode define( 'WP_DEBUG', true ); // Enable Debug...
Once you have installed Visual Studio from https://www.visualstudio.com/downloads/, start a new project. Select 'Windows Forms Application' from Visual Basic Tab. You can rename it here if you need to. Once you click 'OK', you will see this window: Click on the 'Toolbo...
Bridge Mode $ docker run –d –-name my_app -p 10000:80 image_name Note that we did not have to specify --net=bridge because this is the default working mode for docker. This allows to run multiple containers to run on same host without any assignment of dynamic port. So BRIDGE mode avoids the por...
Dialog dlg; DialogGroup dGrp; DialogField dfCustomer; dlg = new Dialog("Simple Dialog"); dGrp = dlg.addGroup("A Group"); dfCustomer = dlg.addField(extendedTypeStr(CustAccount)); if (dlg.run()) { info(dfCustomer.value()); } Because CustAccount is linked to the ...
Dialog dlg; DialogGroup dGrp; DialogField dfGender; dlg = new Dialog("Enum Dialog"); dGrp = dlg.addGroup("A Group"); dfGender = dlg.addField(enumStr(Gender), "Your Gender"); if (dlg.run()) { info(dfGender.value()); } Enums have to be wrapped inside a...
Dialog dlg; DialogGroup dGrp; DialogField dialogField; dlg = new Dialog("Evil Dialog"); dGrp = dlg.addGroup("A Group"); dialogField = dlg.addFieldValue(extendedTypeStr(NoYesId), NoYes::Yes, "I hereby sell my soul"); if (dlg.run()) { info(dialogField.valu...
In C++, you may not skip initializations with goto or switch. The following is valid in C, but not C++: goto foo; int skipped = 1; foo; These bugs may require redesign.
// 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...
Create a new rails app hello-world from command in Windows and Terminal in Linux. rails new hello-world Now move to new app directory cd hello-world Now generate a controller rails generate controller hello_world index Here index is the name of method in hello_world controller. You can c...

Page 750 of 826