Some HTTP requests may contain a message body. This is additional data that the server will use to process the request. Message bodies are most often used in POST or PATCH and PUT requests, to provide new data that the server should apply to a resource.
Requests that include a message body should a...
implode() combines all the array values but looses all the key info:
$arr = ['a' => "AA", 'b' => "BB", 'c' => "CC"];
echo implode(" ", $arr); // AA BB CC
Imploding keys can be done using array_keys() call:
$arr = ['a' => "AA", 'b'...
To make a class a subclass of another class, use parent pragma:
package Point;
use strict;
...
1;
package Point2D;
use strict;
use parent qw(Point);
...
1;
package Point3D;
use strict;
use parent qw(Point);
...
1;
Perl allows for multiple inheritance:
package Point2D;
use stri...
In Perl, the difference between class (static) and object (instance) methods is not so strong as in some other languages, but it still exists.
The left operand of the arrow operator -> becomes the first argument of the method to be called. It may be either a string:
# the first argument of new ...
To add a method to a button, first create an action method:
Objective-C
-(void) someButtonAction{
NSLog(@"Button is tapped");
}
Swift
func someButtonAction() {
print("Button is tapped")
}
Now to add this action method to your button, you have to wri...
The dot product between two tensors can be performed using:
tf.matmul(a, b)
A full example is given below:
# Build a graph
graph = tf.Graph()
with graph.as_default():
# A 2x3 matrix
a = tf.constant(np.array([[1, 2, 3],
[2, 4, 6]]),
...
Set MONGO_URL to any arbitrary value except for a database URL and ensure no collections are defined in your Meteor project (including collections defined by Meteor packages) to run Meteor without MongoDB.
Note that without MongoDB, server/client methods alongside any packages related to Meteor's u...
A linked list is a linear collection of data elements, called nodes, which are linked to other node(s) by means of a "pointer." Below is a singly linked list with a head reference.
┌─────────┬─────────┐ ┌─────────┬─────────┐
HEAD ──▶│ data │"pointer"│──▶...
Production deployments will vary in many ways, but a standard convention when deploying in production is to define an environment variable called NODE_ENV and set its value to "production".
Runtime flags
Any code running in your application (including external modules) can check the valu...
NodeJS executes the module only the first time you require it.
Any further require functions will re-use the same Object, thus not executing the code in the module another time. Also Node caches the modules first time they are loaded using require. This reduces the number of file reads and helps to...
F# allows functions to be added as "members" to types when they are defined (for example, Record Types). However F# also allows new instance members to be added to existing types - even ones declared elsewhere and in other .net languages.
The following example adds a new instance method D...
Modules can be used to add new functions to existing Modules and Types.
namespace FSharp.Collections
module List =
let pair item1 item2 = [ item1; item2 ]
The new function can then be called as if it was an original member of List.
open FSharp.Collections
module Testing =
le...
Cryptography is something very hard and after spending a lot of time reading different examples and seeing how easy it is to introduce some form of vulnerability I found an answer originally written by @jbtule that I think is very good. Enjoy reading:
"The general best practice for symmetric e...
Math.sin and Math.cos are cyclic with a period of 2*PI radians (360 deg) they output a wave with an amplitude of 2 in the range -1 to 1.
Graph of sine and cosine function: (courtesy Wikipedia)
They are both very handy for many types of periodic calculations, from creating sound waves, to animati...
Python's string module provides constants for string related operations. To use them, import the string module:
>>> import string
string.ascii_letters:
Concatenation of ascii_lowercase and ascii_uppercase:
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ...
Gradle has the ability to add a wrapper to projects. This wrapper alleviates the need for all users or continuous integration systems to have Gradle installed. It also prevents version issues where there is some incompatibility between the version the project uses and that which users have installed...
Let's say you have class with generic methods. And you need to call its functions with reflection.
public class Sample
{
public void GenericMethod<T>()
{
// ...
}
public static void StaticMethod<T>()
{
//...
}
}
Let's say we want to...