Tutorial by Examples: sin

Stacks are often used for parsing. A simple parsing task is to check whether a string of parentheses are matching. For example, the string ([]) is matching, because the outer and inner brackets form pairs. ()<>) is not matching, because the last ) has no partner. ([)] is also not matching, be...
Once loaded you can generate a captcha like this: $vals = array( 'word' => 'Random word', 'img_path' => './captcha/', 'img_url' => 'http://example.com/captcha/', 'font_path' => './path/to/fonts/texb.ttf', 'img_width' => '150', 'img_height'...
Packages are collections of R functions, data, and compiled code in a well-defined format. Public (and private) repositories are used to host collections of R packages. The largest collection of R packages is available from CRAN. Some of the most popular R machine learning packages are the following...
from sklearn import svm X = [[1, 2], [3, 4]] #Training Samples y = [1, 2] #Class labels model = svm.SVC() #Making a support vector classifier model model.fit(X, y) #Fitting the data clf.predict([[2, 3]]) #After fitting, new data can be classified by using predict()
These three map functions are equivalent, so use the variation that your team finds most readable. val numberNames = Map(1 -> "One", 2 -> "Two", 3 -> "Three") // 1. No extraction numberNames.map(it => s"${it._1} is written ${it._2}" ) // 2....
Let's say, we have an array: Item = {-1, 0, 3, 6}. We want to construct SegmentTree array to find out the minimum value in a given range. Our segment tree will look like: The numbers below the nodes show the indices of each values that we'll store in our SegmentTree array. We can see that, to sto...
type Props = { posts: Array<Article>, dispatch: Function, children: ReactElement } const AppContainer = ({ posts, dispatch, children }: Props) => ( <div className="main-app"> <Header {...{ posts, dispatch }} /> {children} </...
XmlView: <mvc:View controllerName="sap.m.sample.ListCounter.List" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"> <List headerText="Products" items="{products>/Products}"> <!-- Template of ...
Redis has a Windows port provided by 'Microsoft Open Technologies'. You can use the msi installer found on: https://github.com/MSOpenTech/redis/releases After installation completes you can see 'Redis' is a Windows service (and it's status should be "Started") To write an 'Hello world'...
1. $_ : The default input and pattern-searching space. Example 1: my @array_variable = (1 2 3 4); foreach (@array_variable){ print $_."\n"; # $_ will get the value 1,2,3,4 in loop, if no other variable is supplied. } Example 2: while (<FH>){ chomp($_); # $_ re...
Most Rx operators take an optional scheduler on which to schedule their future iterations. If not supplied they will use their default configured scheduler. Supplying a scheduler can be useful for testing purposes in which we like to talk about virtual time instead of real time for speed of test exe...
Create a folder where you would like to have your game live, and move into that mkdir my-new-game cd my-new-game Initialize the directory using npm. npm init -y Install phaser as a node package. npm install phaser Install http-server as a global module, to be used on the...
In the view file In the base html (index.html) where we usually include the angular scripts or the html that is shared across the app, leave an empty div element, the flash messages will be appearing inside this div element <div class="flashmessage" ng-if="isVisible"> ...
Part I : Setup the Mac machine to use shenzhen Go to terminal Install Shenzhen sudo gem install shenzhen sudo gem install nomad-cli Download XCode command line utility xcode-select --install Popup shows up with the below text The xcode-select command requires the command line d...
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'], 'D': [True, False, True]}) In [2]: df Out[2]: A B C D 0 1 1.0 a True 1 2 2.0 b False 2 3 3.0 c True Getting a python list from a series: In [3]: df['...
The task is to find the length of the longest subsequence in a given array of integers such that all elements of the subsequence are sorted in ascending order. For example, the length of the longest increasing subsequence(LIS) for {15, 27, 14, 38, 26, 55, 46, 65, 85} is 6 and the longest increasing ...
This chapter describes how to set up a Docker Container with Jenkins inside, which is capable of sending Docker commands to the Docker installation (the Docker Daemon) of the Host. Effectively using Docker in Docker. To achieve this, we have to build a custom Docker Image which is based on an arbitr...
$a1 = array("red","green"); $a2 = array("blue","yellow"); print_r(array_merge($a1,$a2)); /* Array ( [0] => red [1] => green [2] => blue [3] => yellow ) */ Associative array: $a1=array("a"=>"red","b"=&...
Converting a java.util.Calendar object: Calendar rightNow = Calendar.getInstance(); LocalDate today = LocalDate.fromCalendarFields(rightNow); Converting a java.util.Date object: Date rightNow = new Date(); LocalDate today = LocalDate.fromDateFields(rightNow); Converting a string: String d...
The Proxy :: k -> * type, found in Data.Proxy, is used when you need to give the compiler some type information - eg, to pick a type class instance - which is nonetheless irrelevant at runtime. {-# LANGUAGE PolyKinds #-} data Proxy a = Proxy Functions which use a Proxy typically use Scoped...

Page 125 of 161