Express router allows you to create multiple "mini apps" so you can namespace your api, public, auth and other routes into separate routing systems.
var express = require('express');
var app = express();
var router = express.Router();
router.get('/', function(req, res){
...
Here's how to create an Express server and serve index.html by default (empty path /), and page1.html for /page1 path.
Folder structure
project root
| server.js
|____views
| index.html
| page1.html
server.js
var express = require('express');
var path = require('path')...
// Include Nodejs' net module.
const Net = require('net');
// The port on which the server is listening.
const port = 8080;
// Use net.createServer() in your code. This is just for illustration purpose.
// Create a new TCP server.
const server = new Net.Server();
// The server listens to a ...
AppleScript can display dialogs and alerts to the user. Dialogs are for optionally requesting user input.
display dialog "Hello World"
display alert "Hello World"
You can customise the buttons of either using buttons and passing a list of text.
display dialog "Hell...
BrowserStack uses a device cloud for cross-browser testing. The intent is to allow testing of Selenium scripts on every device possible.
{
"selenium" : {
"start_process" : false,
"host" : "hub.browserstack.com",
"port" : 80,
},
...
This example extends the basic example passing parameters in the route in order to use them in the controller
To do so we need to:
Configure the parameter position and name in the route name
Inject $routeParams service in our Controller
app.js
angular.module('myApp', ['ngRoute'])
.contro...
Say you have a table named table or you want to create a table with name which is also a keyword, You have to include the name table in pair of double quotes "table"
Select * from table;
Above query will fail with syntax error, where as below query will run fine.
Select * from "tab...
To enable a CORS policy across all of your MVC controllers you have to build the policy in the AddCors extension within the ConfigureServices method and then set the policy on the CorsAuthorizationFilterFactory
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Cors.Internal;
...
pub...
The Z80 has no Interrupt table like modern processors. The Interrupts all execute the same code. In Interrupt Mode 1, they execute the code in a specific unchangeable location. In Interrupt Mode 2, they execute the code from the Pointer register I points to. The Z80 has got a timer, that triggers t...
Assuming you know the productID:
First
import StoreKit
Then in your code
let productID: Set = ["premium"]
let request = SKProductsRequest(productIdentifiers: productID)
request.delegate = self
request.start()
and in the SKProductsRequestDelegate:
func productsRequest(request: ...
Python
Code
import numpy as np
import cv2
#loading haarcascade classifiers for face and eye
#You can find these cascade classifiers here
#https://github.com/opencv/opencv/tree/master/data/haarcascades
#or where you download opencv inside data/haarcascades
face_cascade = cv2.CascadeClassi...
drop table table01;
drop table table02;
create table table01 (
code int,
name varchar(50),
old int
);
create table table02 (
code int,
name varchar(50),
old int
);
truncate table table01;
insert into table01 values (1, 'A', 10);
insert in...
The simplest approach to parallel reduction in CUDA is to assign a single block to perform the task:
static const int arraySize = 10000;
static const int blockSize = 1024;
__global__ void sumCommSingleBlock(const int *a, int *out) {
int idx = threadIdx.x;
int sum = 0;
for (int i ...
Doing parallel reduction for a non-commutative operator is a bit more involved, compared to commutative version.
In the example we still use a addition over integers for the simplicity sake.
It could be replaced, for example, with matrix multiplication which really is non-commutative.
Note, when ...
Multi-block approach to parallel reduction in CUDA poses an additional challenge, compared to single-block approach, because blocks are limited in communication.
The idea is to let each block compute a part of the input array, and then have one final block to merge all the partial results.
To do t...
Multi-block approach to parallel reduction is very similar to the single-block approach.
The global input array must be split into sections, each reduced by a single block.
When a partial result from each block is obtained, one final block reduces these to obtain the final result.
sumNoncommSin...
Sometimes the reduction has to be performed on a very small scale, as a part of a bigger CUDA kernel.
Suppose for example, that the input data has exactly 32 elements - the number of threads in a warp.
In such scenario a single warp can be assigned to perform the reduction.
Given that warp execut...