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...
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...
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:...
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...
Implement Dispose() method (and declare the containing class as IDisposable) as a means to ensure any memory-heavy resources are freed as soon as the object is no longer used. The "catch" is that there is no strong guarantee the the Dispose() method would ever be invoked (unlike finalizers...
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...
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 ...
A MultiTrigger is similar to a standard Trigger in that it only applies to properties within the same control. The difference is that a MultiTrigger has multiple conditions which must be satisfied before the trigger will operate. Conditions are defined using the <Condition> tag.
<TextBlock...
The SAVEQUERIES definition saves the database queries to an array and that array can be displayed to help analyze those queries. The constant defined as true causes each query to be saved, how long that query took to execute, and what function called it.
NOTE: This will have a performance impact on...
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 dfName;
dlg = new Dialog("Trivial Dialog");
dGrp = dlg.addGroup("A Group");
dfName = dlg.addField(extendedTypeStr(Name));
if (dlg.run())
{
info(dfName.value());
}
Extended data types have to be wrapped in a call to ext...
Analysis in elasticsearch comes into context when you are willing to analyze the data in your index.
Analyzers allow us to perform following:
Abbreviations
Stemming
Typo Handling
We will be looking at each of them now.
Abbreviations:
Using analyzers, we can tell elasticsearch how to t...
The first example are keywords that have a special purpose in C++: the following is legal in C, but not C++.
int class = 5
These errors are easy to fix: just rename the variable.
In C, pointers can be cast to a void*, which needs an explicit cast in C++. The following is illegal in C++, but legal in C:
void* ptr;
int* intptr = ptr;
Adding an explicit cast makes this work, but can cause further issues.