Tutorial by Examples: e

# Roll a 6 sided die, rand(6) returns a number from 0 to 5 inclusive dice_roll_result = 1 + rand(6)
# ruby 1.92 lower_limit = 1 upper_limit = 6 Random.new.rand(lower_limit..upper_limit) # Change your range operator to suit your needs
public class NetworkConnection : IDisposable { string _networkName; public NetworkConnection(string networkName, NetworkCredential credentials) { _networkName = networkName; var netResource = new NetResource() {...
The hslogger module provides a similar API to Python's logging framework, and supports hierarchically named loggers, levels and redirection to handles outside of stdout and stderr. By default, all messages of level WARNING and above are sent to stderr and all other log levels are ignored. import ...
The first instrument you’ll look at is the Time Profiler. At measured intervals, Instruments will halt the execution of the program and take a stack trace on each running thread. Think of it as pressing the pause button in Xcode’s debugger.Here’s a sneak preview of the Time Profiler :- This scree...
apm is Atom's native package manager. It allows the user to manage packages and themes without having to initialise Atom itself. apm comes with the official installation and is automatically added to %PATH% if you're on Windows. To use apm, go to Command Prompt and type $ apm <command> He...
Generally, most of the data that is to be analyzed will be produced by various data sources like applications servers, social networking sites, cloud servers, and enterprise servers. This data will be in the form of log files and events. Log file − In general, a log file is a file that lists events...
cf logs AppName --recent Note, depending on who is hosting your CF app, the size of this log may be limited.
CF keeps you logged in. I sometimes have to switch between regions and don't always know where I am #Where am I? cf target #Login. This is logging in to the UK region of bluemix. Replace eu-gb with ng to go to the US. cf login -a https://api.eu-gb.bluemix.net #List spaces cf spaces #C...
The If control statement allows different code to be executed depending upon the evaluation of a conditional (Boolean) statement. A conditional statement is one that evaluates to either True or False, e.g. x > 2. There are three patterns that can be used when implementing an If statement, which ...
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...
CDI is a Java EE specification. It specifies how things should be done, and which features must be provided, but it isn't actually a specific library or set of code. In order to use CDI, you will need to use a CDI implementation. The reference implementation of the CDI spec is a set of libraries kn...
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 = ...
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...

Page 1076 of 1191