Tutorial by Examples

Say you have the string s = 'AAAABBBCCDAABBB' and you would like to split it so all the 'A's are in one list and so with all the 'B's and 'C', etc. You could do something like this s = 'AAAABBBCCDAABBB' s_dict = {} for i in s: if i not in s_dict.keys(): s_dict[i] = [i] els...
This example illustrates how the default key is chosen if we do not specify any c = groupby(['goat', 'dog', 'cow', 1, 1, 2, 3, 11, 10, ('persons', 'man', 'woman')]) dic = {} for k, v in c: dic[k] = list(v) dic Results in {1: [1, 1], 2: [2], 3: [3], ('persons', 'man', 'woman'): [('...
Notice in this example that mulato and camel don't show up in our result. Only the last element with the specified key shows up. The last result for c actually wipes out two previous results. But watch the new version where I have the data sorted first on same key. list_things = ['goat', 'dog', 'do...
In this example we see what happens when we use different types of iterable. things = [("animal", "bear"), ("animal", "duck"), ("plant", "cactus"), ("vehicle", "harley"), \ ("vehicle", "speed b...
package MyHiveUDFs; import org.apache.commons.lang.StringUtils; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; public class Strip extends UDF { private Text result = new Text(); public Text evaluate(Text str) { if(str == null) { return null; } resul...
class ParentClass { [string] $Message = "Its under the Parent Class" [string] GetMessage() { return ("Message: {0}" -f $this.Message) } } # Bar extends Foo and inherits its members class ChildClass : ParentClass { } $Inherit = [ChildClass...
Algorithm BFS(G) Input graph G Output labeling of the edges and partition of the vertices of G for all u ∈ G.vertices() setLabel(u, UNEXPLORED) for all e ∈ G.edges() setLabel (e, UNEXPLORED) for all v ∈ G.vertices() if getLabel(v) = UNEXPLORED ...
From Java 8 onwards, the Lambda operator ( -> ) is the operator used to introduce a Lambda Expression. There are two common syntaxes, as illustrated by these examples: Java SE 8 a -> a + 1 // a lambda that adds one to its argument a -> { return a + 1; } // an equivalen...
Naturally, being able to install hard drive cloning utilities can be an important aspect of installing and maintaining your operating system. Getting set up with Clonezilla is surprisingly less straightforward than I'd have expected. The wealth of options, while valuable, also makes each part of id...
index.html: <html ng-app="masterAngularMaterial"> <head> <!-- This is important (meta) --> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Angular and other dependencies --> ...
Make sure you link the Angular and Angular Material libraries! index.html: <html ng-app="mdButtonApp"> <head> <!-- Import Angular --> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script&gt...
This example will be using the class md-icon-button, which must be applied to <md-button> in order to get an icon button. It is also recommended to add an aria-label attribute to <md-button> for accessibility purpose or the ARIA provider will throw a warning that there is no aria-labe...
Reference the ArcGIS JavaScript API from our CDN and you are ready to get started:
require(["esri/map", "dojo/domReady!"], function(Map) { var map = new Map("map", { center: [-118, 34.5], zoom: 8, basemap: "topo" }); });
Starting with version 3.2 of the ArcGIS API for JavaScript, developers must include an additional Cascading Style Sheet (CSS) file: esri.css. The URL for this file is: // versions 3.11 and forward <link rel="stylesheet" href="https://js.arcgis.com/API-VERSION/esri/css/esri.css&...
The esri.css file does not include the CSS for various Dojo widgets or themes like tundra or claro; those files must be included separately. Exceptions are the Grid and RangeSlider, which are used by widgets in the API. Grid styles must be explicitly included. For instance, this CSS file would be i...
Let's take this example without using generics protocol JSONDecodable { static func from(_ json: [String: Any]) -> Any? } The protocol declaration seems fine unless you actually use it. let myTestObject = TestObject.from(myJson) as? TestObject Why do you have to cast the result to T...
import { BrowserModule } from '@angular/platform-browser'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { Component, DebugElement } from '@angular/core'; import { dispatchEvent } from "@an...
Introduction When working with various libraries and their associated requirements, it is often necessary to know the version of current PHP parser or one of it's packages. This function accepts a single optional parameter in the form of extension name: phpversion('extension'). If the extension in...
/* Define a query named q1 for the Customer table */ DEFINE QUERY q1 FOR Customer. /* Open the query for all Customer records where the state is "tx" */ OPEN QUERY q1 FOR EACH Customer WHERE Customer.state ='TX'. ...

Page 1092 of 1336