// Set up Express
var express = require('express');
var app = express();
// Serve files from the absolute path of the directory
app.use(express.static(__dirname + '/public'));
// Start Express server
app.listen(3030);
// Set up Express
var express = require('express');
var app = express();
/* Serve from the absolute path of the directory that you want to serve with a
*/ virtual path prefix
app.use('/static', express.static(__dirname + '/public'));
// Start Express server
app.listen(3030);
Joins in Spark:
Read textFile 1
val txt1=sc.textFile(path="/path/to/input/file1")
Eg:
A B
1 2
3 4
Read textFile 2
val txt2=sc.textFile(path="/path/to/input/file2")
Eg:
A C
1 5
3 6
Join and print the result.
txt1.join(txt2).foreach(p...
Two of the most fundamental higher-order functions included in the standard library are map and filter. These functions are generic and can operate on any iterable. In particular, they are well-suited for computations on arrays.
Suppose we have a dataset of schools. Each school teaches a particular...
You can use the IFA for measuring ad clicks and the IFV for measuring
app installs.
IFA has built-in privacy mechanisms that make it
perfect for advertising. In contrast, the IFV is for developers to
use internally to measure users who install their apps.
IFA
ASIdentifierManager class pr...
A lot of example code posted on StackOverflow includes snippets like this:
if ("A".equals(someString)) {
// do something
}
This does "prevent" or "avoid" a possible NullPointerException in the case that someString is null. Furthermore, it is arguable that
...
This example shows how to deploy the "Hello World" program as a library and how to link it with other targets.
Say we have the same set of source/header files as in the http://www.riptutorial.com/cmake/example/22391/-hello-world--with-multiple-source-files example. Instead of building fro...
A bit-field is used to club together many variables into one object, similar to a structure. This allows for reduced memory usage and is especially useful in an embedded environment.
e.g. consider the following variables having the ranges as given below.
a --> range 0 - 3
b --> range 0 -...
- Without quotes:
You can just
split a long piece of text like this.
- With quotes:
"[But be careful:
if you \"need\" punctuation, put double quotes around it. You can ev\
en split without spaces by using backslashes."
- Or single quotes:
'This wor...
This is a simple trigger function.
CREATE OR REPLACE FUNCTION my_simple_trigger_function()
RETURNS trigger AS
$BODY$
BEGIN
-- TG_TABLE_NAME :name of the table that caused the trigger invocation
IF (TG_TABLE_NAME = 'users') THEN
--TG_OP : operation the trigger was fired
IF (TG_O...
// PixelAccessTutorial.cpp : Defines the entry point for the console
// Environment: Visual studio 2015, Windows 10
// Assumptions: Opecv is installed configured in the visual studio project
// Opencv version: OpenCV 3.1
#include "stdafx.h"
#include<opencv2/core/core.hpp>
#i...
For live plnkr click...
<!doctype html>
<html>
<head>
<title>ng for loop in angular 2 with ES5.</title>
<script type="text/javascript" src="https://code.angularjs.org/2.0.0-alpha.28/angular2.sfx.dev.js"></script>
<scr...
It's also possible to use selectors together. This is done by using the OpenQA.Selenium.Support.PageObjects.ByChained object:
element = driver.FindElement(new ByChained(By.TagName("input"), By.ClassName("class"));
Any number of Bys can be chained and are used as an AND type ...
Below is an usage of canny algorithm in c++. Note that the image is first converted to grayscale image, then Gaussian filter is used to reduce the noise in the image. Then Canny algorithm is used for edge detection.
// CannyTutorial.cpp : Defines the entry point for the console application.
// En...
This class open a .gz file (usual format of compressed log files) and will return a line at each call of .NextLine()
There is no memory usage for temporary decompression, very useful for large file.
Imports System.IO
Class logread_gz
Private ptr As FileStream
Private UnGZPtr As Compress...
Here is the JSON Structure we are going to use.
{
"employees": [
{
"firstName": "John",
"lastName": "Doe",
"skills": [
{
"name": "javascript",
"rating&quo...
Taggy-lens allows us to use lenses to parse and inspect HTML documents.
#!/usr/bin/env stack
-- stack --resolver lts-7.0 --install-ghc runghc --package text --package lens --package taggy-lens
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text.Lazy as TL
import qualified Data.Tex...
Overview
Android Studio's built-in update mechanism can be set to receive updates through any one of these four channels:
Canary: Bleeding edge, released about weekly. These are early previews released in order to obtain real-world feedback during development. The canary channel will always have...