Tutorial by Examples: al

If you want to check that a string contains only a certain set of characters, in this case a-z, A-Z and 0-9, you can do so like this, import re def is_allowed(string): characherRegex = re.compile(r'[^a-zA-Z0-9.]') string = characherRegex.search(string) return not bool(string) ...
Detailed instructions on getting domain-driven-design set up or installed.
Grand Central Dispatch works on the concept of "Dispatch Queues". A dispatch queue executes tasks you designate in the order which they are passed. There are three types of dispatch queues: Serial Dispatch Queues (aka private dispatch queues) execute one task at a time, in order. They a...
3.0 To run tasks on a dispatch queue, use the sync, async, and after methods. To dispatch a task to a queue asynchronously: let queue = DispatchQueue(label: "myQueueName") queue.async { //do something DispatchQueue.main.async { //this will be called in main t...
// Obtain an instance of JavaScript engine ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); //String to be evaluated String str = "3+2*4+5"; //Value after doing Arithmetic operation with operator preceden...
Suppose you have a simple Customer model: class Customer(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) is_premium = models.BooleanField(default=False) You register it in the Django admin and add search field by first_name...
In this example we aim to accomplish one of the most common tasks: I have a small DC motor laying around, how do I use my Arduino to control it? Easy, with PWM and serial communication, using the function analogWrite() and the Serial library. The basics Pulse Width Modulation or PWM for short is a...
Detailed instructions on getting nhibernate set up or installed.
If you want to calculate with BigDecimal you have to use the returned value because BigDecimal objects are immutable: BigDecimal a = new BigDecimal("42.23"); BigDecimal b = new BigDecimal("10.001"); a.add(b); // a will still be 42.23 BigDecimal c = a.add(b); // c will be ...
Module Pattern The Module pattern is a creational and structural design pattern which provides a way of encapsulating private members while producing a public API. This is accomplished by creating an IIFE which allows us to define variables only available in its scope (through closure) while return...
To compare strings alphabetically, use localeCompare(). This returns a negative value if the reference string is lexicographically (alphabetically) before the compared string (the parameter), a positive value if it comes afterwards, and a value of 0 if they are equal. var a = "hello"; va...
Detailed instructions on getting stripe-payments set up or installed.
The base package parallel allows parallel computation through forking, sockets, and random-number generation. Detect the number of cores present on the localhost: parallel::detectCores(all.tests = FALSE, logical = TRUE) Create a cluster of the cores on the localhost: parallelCluster <- para...
The .GetValueOrDefault() method returns a value even if the .HasValue property is false (unlike the Value property, which throws an exception). class Program { static void Main() { int? nullableExample = null; int result = nullableExample.GetValueOrDefault(); C...
When filtering an email address filter_var() will return the filtered data, in this case the email address, or false if a valid email address cannot be found: var_dump(filter_var('[email protected]', FILTER_VALIDATE_EMAIL)); var_dump(filter_var('notValidEmail', FILTER_VALIDATE_EMAIL)); Results: ...
When filtering a value that should be an integer filter_var() will return the filtered data, in this case the integer, or false if the value is not an integer. Floats are not integers: var_dump(filter_var('10', FILTER_VALIDATE_INT)); var_dump(filter_var('a10', FILTER_VALIDATE_INT)); var_dump(filt...
When validating that an integer falls in a range the check includes the minimum and maximum bounds: $options = array( 'options' => array( 'min_range' => 5, 'max_range' => 10, ) ); var_dump(filter_var('5', FILTER_VALIDATE_INT, $options)); var_dump(filter_var('...
When filtering a URL filter_var() will return the filtered data, in this case the URL, or false if a valid URL cannot be found: URL: example.com var_dump(filter_var('example.com', FILTER_VALIDATE_URL)); var_dump(filter_var('example.com', FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)); var_du...
Single node Installation Pre-install NodeJS, Python and Java Select your installation document based on your platform http://docs.datastax.com/en/cassandra/3.x/cassandra/install/installTOC.html Download Cassandra binaries from http://cassandra.apache.org/download/ Untar the downloaded file to ...
One common use case for generators is reading a file from disk and iterating over its contents. Below is a class that allows you to iterate over a CSV file. The memory usage for this script is very predictable, and will not fluctuate depending on the size of the CSV file. <?php class CsvReade...

Page 41 of 269