Tutorial by Examples

This is an example of an attribute that I created to validate that required parameters have been assigned in the request object receive in a POST route. I decided on this approach because the standard ModelState.IsValid approach was not valid. This is because the required attributes vary based on wh...
[HttpPost] [Route("api/Fitbit/Activity/Stats")] public async Task<HttpResponseMessage> ActivityStats(FitbitRequestDTO request) { if (string.IsNullOrEmpty(request.PatientId) || string.IsNullOrEmpty(request.DeviceId)) ret...
public async Task<HttpResponseMessage> ActivityStats(FitbitRequestDTO request) { try { var tokenErrorResponse = await EnsureToken(request); if (tokenErrorResponse != null) return tokenErrorRespons...
In LR Classifier, he probabilities describing the possible outcomes of a single trial are modeled using a logistic function. It is implemented in the linear_model library from sklearn.linear_model import LogisticRegression The sklearn LR implementation can fit binary, One-vs- Rest, or multinomia...
New Java programmers often forget, or fail to fully comprehend, that the Java String class is immutable. This leads to problems like the one in the following example: public class Shout { public static void main(String[] args) { for (String s : args) { s.toUpperCase(); ...
Apache Kafka™ is a distributed streaming platform. Which means 1-It lets you publish and subscribe to streams of records. In this respect it is similar to a message queue or enterprise messaging system. 2-It lets you store streams of records in a fault-tolerant way. 3-It lets you process streams...
K-fold cross-validation is a systematic process for repeating the train/test split procedure multiple times, in order to reduce the variance associated with a single trial of train/test split. You essentially split the entire dataset into K equal size "folds", and each fold is used once fo...
This tool let you list, create, alter and describe topics. List topics: kafka-topics --zookeeper localhost:2181 --list Create a topic: kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test creates a topic with one partition and no replication....
This tool lets you produce messages from the command-line. Send simple string messages to a topic: kafka-console-producer --broker-list localhost:9092 --topic test here is a message here is another message ^D (each new line is a new message, type ctrl+D or ctrl+C to stop) Send messages with...
This tool let's you consume messages from a topic. to use the old consumer implementation, replace --bootstrap-server with --zookeeper. Display simple messages: kafka-console-consumer --bootstrap-server localhost:9092 --topic test Consume old messages: In order to see older messages, you...
This consumer is a low-level tool which allows you to consume messages from specific partitions, offsets and replicas. Useful parameters: parition: the specific partition to consume from (default to all) offset: the beginning offset. Use -2 to consume messages from the beginning, -1 to consume ...
This tool allows you to list, describe, or delete consumer groups. Have a look at this article for more information about consumer groups. if you still use the old consumer implementation, replace --bootstrap-server with --zookeeper. List consumer groups: kafka-consumer-groups --bootstrap-s...
On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token by extending FirebaseInstanceIdService. The onTokenRefresh callback fires whenever a new token is g...
// PHYSICS CONSTANTS struct PhysicsCategory { static let None : UInt32 = 0 static let All : UInt32 = UInt32.max static let player : UInt32 = 0b1 // 1 static let bullet : UInt32 = 0b10 // 2 } var nodesToRemove = [SKNode]() /...
This example uses the gson library to map java objects to json strings. The (de)serializers are generic, but they don't always need to be ! Serializer Code public class GsonSerializer<T> implements Serializer<T> { private Gson gson = new GsonBuilder().create(); @Over...
import gzip import os outfilename = 'example.txt.gz' output = gzip.open(outfilename, 'wb') try: output.write('Contents of the example file go here.\n') finally: output.close() print outfilename, 'contains', os.stat(outfilename).st_size, 'bytes of compressed data' os.system('file...
A very common use-case in web applications is performing multiple asynchronous (eg. HTTP) requests and gathering their results as they arrive or all of them at once (eg. in Angular2 with the HTTP service). 1. Gathering async responses one by one as they arrive This is typically done with mergeMap(...
Make a simple Hello World Example using your django. let's make sure that you have django installed on your PC first. open a terminal and type: python -c "import django" -->if no error comes that means django is already installed. Now lets create a project in django. For that write ...
In Unit Test layer we usually test the Business Layer functionalities. And in order to do this, we will remove the Data Layer (Entity Framework) dependencies. And the question now is: How can I remove the Entity Framework dependencies in order to unit test the Business Layer functions? And the ans...
class GuestsCleanupJob < ApplicationJob queue_as :default def perform(*guests) # Do something later end end

Page 1130 of 1336