Tutorial by Examples: e

To generalise what we've demonstrated above: individual things contain a fixed margin of "half-the-whitespace", and the container they are held in should have a padding of "half-the-whitespace". You can apply these styles in your application resource dictionary, and then you won'...
Sometimes Android's logcat is running infinitely with errors coming from some process not own by you, draining battery or just making it hard to debug your code. A convenient way to fix the problem without restarting the device is to locate and kill the process causing the problem. From Logcat 03...
// This is a more complex MIDI THRU. This version uses a queue. Queues are important because some // MIDI messages can be interrupted for real time events. If you are generating your own messages, // you may need to stop your message to let a "real time" message through and then resum...
// This is a MiDI clk generator. This takes a #defined BPM and // makes the appropriate clk rate. The queue is used to let other messages // through, but allows a clock to go immediately to reduce clock jitter #define QUEUE_DEPTH 128 #define BPM 121 #define MIDI_SYSRT_CLK 0xF8 // clock...
Let's first create a simple "Hello world!" MailboxProcessor which processes one type of message and prints greetings. You'll need the message type. It can be anything, but Discriminated Unions are a natural choice here as they list all the possible cases on one place and you can easily us...
Mailbox processors can be used to manage mutable state in a transparent and thread-safe way. Let's build a simple counter. // Increment or decrement by one. type CounterMessage = | Increment | Decrement let createProcessor initialState = MailboxProcessor<CounterMessage>.Sta...
You can asynchronously return a value for each processed message if you send an AsyncReplyChannel<'a> as part of the message. type MessageWithResponse = Message of InputData * AsyncReplyChannel<OutputData> Then the mailbox processor can use this channel when processing the message to...
You can use Scan or TryScan methods to look for specific messages in the queue and process them regardless of how many messages are before them. Both methods look at the messages in the queue in the order they arrived and will look for a specified message (up until optional timeout). In case there i...
Blocking Operation Example let loop = (i, max) => { while (i < max) i++ return i } // This operation will block Node.js // Because, it's CPU-bound // You should be careful about this kind of code loop(0, 1e+12) Non-Blocking IO Operation Example let i = 0 const step = max =...
The root process scatters the contents in sendbuf to all processes (including itself) using the MPI_Scatter operation. int rank; int size; int sendcount = 1; int recvcount = sendcount; int sendbuf[3]; int recvbuf; int root = 0; MPI_Comm_size (MPI_COMM_WORLD, &size); if (size != 3) ...
#!/bin/bash deploy=false uglify=false while (( $# > 1 )); do case $1 in --deploy) deploy="$2";; --uglify) uglify="$2";; *) break; esac; shift 2 done $deploy && echo "will deploy... deploy = $deploy" $uglify && echo "will...
Starting from a sequence of static images (for example called frame01.jpg, frame02.jpg and so on) an animated gif can be created using the following command: magick -delay 10 -loop 0 frame*.jpg animation.gif -delay 10 sets the interval between the frames to 0.1 seconds -loop 0 creates a...
So let's say again that you have the following model: public class Person { public int PersonId { get; set; } public string Name { get; set; } } public class Car { public int CarId { get; set; } public string LicensePlate { get; set; } } public class MyDemoContext : DbContext ...
Mapping one-to-one (when both sides are required) is also a tricky thing. Let's imagine how this could be represented with foreign keys. Again, a CarId in People that refers to CarId in Car, and a PersonId in Car that refers to the PersonId in People. Now what happens if you want to insert a car r...
And to finish off, let's briefly look at the case when both sides are optional. By now you should be really bored with these examples :), so I'm not going into the details and play with the idea of having two FK-s and the potential problems and warn you about the dangers of not enforcing these rule...
Basics require('http').globalAgent.maxSockets = 25 // You can change 25 to Infinity or to a different value by experimenting Node.js by default is using maxSockets = Infinity at the same time (since v0.12.0). Until Node v0.12.0, the default was maxSockets = 5 (see v0.11.0). So, after more tha...
const http = require('http') const fs = require('fs') const zlib = require('zlib') http.createServer((request, response) => { const stream = fs.createReadStream('index.html') const acceptsEncoding = request.headers['accept-encoding'] let encoder = { hasEncoder ...
""" CannyTrackbar function allows for a better understanding of the mechanisms behind Canny Edge detection algorithm and rapid prototyping. The example includes basic use case. 2 of the trackbars allow for tuning of the Canny function and the other 2 help with understanding h...
So let's say you have two different entities, something like this: public class Person { public int PersonId { get; set; } public string Name { get; set; } } public class Car { public int CarId { get; set; } public string LicensePlate { get; set; } } public class MyDemoCon...
In the last example, you can see that EF figures out which column is the foreign key and where should it point to. How? By using conventions. Having a property of type Person that is named Person with a PersonId property leads EF to conclude that PersonId is a foreign key, and it points to the prima...

Page 1053 of 1191