Tutorial by Examples: ti

This topic demonstrates how to use functions like withColumn, lead, lag, Level etc using Spark. Spark dataframe is an sql abstract layer on spark core functionalities. This enable user to write SQL on distributed data. Spark SQL supports hetrogenous file formats including JSON, XML, CSV , TSV etc. ...
In this very first example, a basic serial write operation is started from an Arduino device. void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: Serial.println("Hello World!"); dela...
If you want to append a series of values [1,2] to the column of dataframe df, you will get NaNs: import pandas as pd series=pd.Series([1,2]) df=pd.DataFrame(index=[3,4]) df['col']=series df col 3 NaN 4 NaN because setting a new column automatically aligns the data by the inde...
Luminus is a Clojure micro-framework based on a set of lightweight libraries. It aims to provide a robust, scalable, and easy to use platform. With Luminus you can focus on developing your app the way you want without any distractions. It also has very good documentation that covers some of the majo...
Scenario: You need to select an implementation of address validation when a sales order is submitted, and the validator is determined by the country to which the order is shipping. The factory needs to inspect some value passed as an argument to select the correct implementation. First, write an in...
const Promise = require('bluebird'), fs = require('fs') Promise.promisifyAll(fs) // now you can use promise based methods on 'fs' with the Async suffix fs.readFileAsync('file.txt').then(contents => { console.log(contents) }).catch(err => { console.error('error reading', er...
Example of map: Promise.resolve([ 1, 2, 3 ]).map(el => { return Promise.resolve(el * el) // return some async operation in real world }) Example of filter: Promise.resolve([ 1, 2, 3 ]).filter(el => { return Promise.resolve(el % 2 === 0) // return some async operation in real world...
const promiseReturningFunction = Promise.coroutine(function* (file) { const data = yield fs.readFileAsync(file) // this returns a Promise and resolves to the file contents return data.toString().toUpperCase() }) promiseReturningFunction('file.txt').then(console.log)
function somethingThatReturnsADisposableResource() { return getSomeResourceAsync(...).disposer(resource => { resource.dispose() }) } Promise.using(somethingThatReturnsADisposableResource(), resource => { // use the resource here, the disposer will automatically close it when ...
Promise.resolve([1, 2, 3]) .mapSeries(el => Promise.resolve(el * el)) // in real world, use Promise returning async function .then(console.log)
Unlike var, const/let are bound to lexical scope rather than function scope. { var x = 1 // will escape the scope let y = 2 // bound to lexical scope const z = 3 // bound to lexical scope, constant } console.log(x) // 1 console.log(y) // ReferenceError: y is not defined console.log(z...
Arrow functions automatically bind to the 'this' lexical scope of the surrounding code. performSomething(result => { this.someVariable = result }) vs performSomething(function(result) { this.someVariable = result }.bind(this))
Before starting work with scrapy you have to start a project where you want to store your code. Enter the directory and run this code scrapy startproject helloProject The third part of this code is project name. This code will create a "helloProject" directory with the following conten...
Multidimensional arrays follow the same rules as single-dimensional arrays when passing them to a function. However the combination of decay-to-pointer, operator precedence, and the two different ways to declare a multidimensional array (array of arrays vs array of pointers) may make the declaratio...
This ability was added to the Bind markup extension after v1607 (Redstone 1). You can specify a function path, as well as arg paths and constant args. Let's assume we have a function defined in our backcode: public string Translate(string text, string from, string to) Now we can use bind to eva...
You should have the basic express-generator template In app.js, add(you can add it anywhere after var app = express.app()): app.post(function(req, res, next){ next(); }); Now in your index.js file (or its respective match), add: router.get('/ajax', function(req, res){ res.render('aj...
It is nessecary to have .NET or a mono-aspnet package. It is important to understand the importance of dockerization. Install dotnet on ubuntu or the OS you are working on. Installing DOTNET $ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty m...
At first, You should create database with mysql, phpMyAdmin, HeidiSQL or another instruments to work with Database and let user create new one. After that procedure, You should provide access to database for project. You need to go into file /path/to/your/project/config/app.php,then look up for Da...
Let's say we have two tables (A and B) and some of their rows match (relative to the given JOIN condition, whatever it may be in the particular case): We can use various join types to include or exclude matching or non-matching rows from either side, and correctly name the join by picking the cor...
Suppose you have a button in your Java program that counts down a time. Here is the code for 10 minutes timer. private final static long REFRESH_LIST_PERIOD=10 * 60 * 1000; //10 minutes Timer timer = new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEve...

Page 341 of 505