C++11
The type_traits header contains a set of template classes and helpers to transform and check properties of types at compile-time.
These traits are typically used in templates to check for user errors, support generic programming, and allow for optimizations.
Most type traits are used to c...
Here is a simple JsonArray which you would like to convert to a Java ArrayList:
{
"list": [
"Test_String_1",
"Test_String_2"
]
}
Now pass the JsonArray 'list' to the following method which returns a corresponding...
Sometimes in a development or testing environment, the SSL certificate chain might not have been fully established (yet).
To continue developing and testing, you can turn off SSL verification programmatically by installing an "all-trusting" trust manager:
try {
// Create a trust mana...
Emacs uses the terms point, mark, and region to provide more precision about the selected text and position of the cursor. By understanding these terms, it'll help you understand and use other operations and functions.
The point is the place in a buffer where editing (i.e. insertion) is currently t...
Exceptions are powerful, but a single overzealous except clause can take it all away in a single line.
try:
res = get_result()
res = res[0]
log('got result: %r' % res)
except:
if not res:
res = ''
print('got exception')
This example demonstrates 3 symptoms of t...
Download
Use Firebird site to download the correct "server package" for your system.
First, select the version of Firebird that you would like to install.
Next, select the appropriated installer for your system. Example, for almost any version of Windows 32 bits, you would select under ...
The Scala Collections framework, according to its authors, is designed to be easy to use, concise, safe, fast, and universal.
The framework is made up of Scala traits that are designed to be building blocks for creating collections. For more information on these building blocks, read the official S...
The ToString() method is present on all reference object types. This is due to all reference types being derived from Object which has the ToString() method on it. The ToString() method on the object base class returns the type name. The fragment below will print out "User" to the console....
GetHashCode has major performance effects on Dictionary<> and HashTable.
Good GetHashCode Methods
should have an even distribution
every integer should have a roughly equal chance of returning for a random instance
if your method returns the same integer (e.g. the constant '999') for e...
/*add this code to your function.php file
now your api will include transaction_id
*/
add_action( 'woocommerce_api_order_response', 'my_woocommerce_api_order', 10, 2);
function my_woocommerce_api_order( $data ) {
//you can do anything with the $data here lets add the transaction id
...
The following are instructions to setup latest version of Varnish on various Linux distros.
CentOS 7
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish5/script.rpm.sh | sudo bash
Ubuntu
apt-get install apt-transport-https
curl https://repo.varnish-cache.org/GPG-key.txt ...
Setters and Getters allow for an object to contain private variables which can be accessed and changed with restrictions. For example,
public class Person {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
i...
In this example, we'll create a simple echo server that will listen on the specified port, and being able to handle new connections:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h&...
The SUBDIRS ability of qmake can be used to compile a set of libraries, each of which depend on another. The example below is slightly convoluted to show variations with the SUBDIRS ability.
Directory Structure
Some of the following files will be omitted in the interest of brevity. They can be a...
A simple example to make a library (rather than an executable, which is the default). TEMPLATE variable specifies type of the project you are making. lib option allows makefile to build a library.
library.pro
HEADERS += library.h
SOURCES += library.cpp
TEMPLATE = lib
# By default, qmake wil...
<ImageView
android:id="@+id/imgExample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
/>
set a drawable as content of ImageView using XML attribute:
android:src="@drawable/android2"
set a drawable program...
If you want to show local notification immediately, you should call:
Swift 3
UIApplication.shared.presentLocalNotificationNow(notification)
Swift 2
UIApplication.sharedApplication().presentLocalNotificationNow(notification)
Objective-C
[[UIApplication sharedApplication] presentLocalNotific...