Tutorial by Examples

Catching exceptions in Kotlin looks very similar to Java try { doSomething() } catch(e: MyException) { handle(e) } finally { cleanup() } You can also catch multiple exceptions try { doSomething() } catch(e: FileSystemException) { handle(e) } catch(e: Network...
IF you are using simple categories, with each physics body belonging to only one category, then this alternative form of didBeginContact may be more readable: func didBeginContact(contact: SKPhysicsContact) { let contactMask = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask ...
Here is a simple Sprite-Kit GameScene.swift. Create a new, empty SpriteKit project and replace the GameScene.swift with this. Then build and run. Click on any of the objects on screen to give make them move. Check the logs and the comments to see which ones collide and which ones make contact. // ...
Depth-first search is an algorithm for traversing or searching tree or graph data structures. One starts at the root and explores as far as possible along each branch before backtracking. A version of depth-first search was investigated in the 19th century French mathematician Charles Pierre Trémaux...
If the tables use InnoDB, MySQL automatically uses row level locking so that multiple transactions can use same table simultaneously for read and write, without making each other wait. If two transactions trying to modify the same row and both uses row level locking, one of the transactions waits f...
Dictionaries are great for managing information where multiple entries occur, but you are only concerned with a single value for each set of entries — the first or last value, the mininmum or maximum value, an average, a sum etc. Consider a workbook that holds a log of user activity, with a script ...
Bubble sort is also known as Sinking Sort. It is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. Bubble sort example Implementation of Bubble Sort I used C# language to implement ...
1. Overview In this article we are going to discuss how to get started with Enterprise JavaBeans (EJB). We will use JBoss AS 7.1.1.Final, but you are free to use any server of your choice. 2. Maven Dependencies for Bean In order to use EJB make sure you add the latest version of it to the depende...
Fetching or loading data can be primarily classified into two types: eager and lazy. In order to use Hibernate make sure you add the latest version of it to the dependencies section of your pom.xml file: <dependency> <groupId>org.hibernate</groupId> <artifactId>hi...
The Problem: Given a set of items where each item contains a weight and value, determine the number of each to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. Pseudo code for Knapsack Problem Given: Values(arr...
Counting sort is an integer sorting algorithm for a collection of objects that sorts according to the keys of the objects. Steps Construct a working array C that has size equal to the range of the input array A. Iterate through A, assigning C[x] based on the number of times x appeared in A. Tr...
Cycle Sort is sorting algorithm which uses comparison sort that is theoretically optimal in terms of the total number of writes to original array, unlike any other in-place sorting algorithm. Cycle sort is unstable sorting algorithm. It is based on idea of permutation in which permutations are facto...
;;Recursively print the elements of a list (defun print-list (elements) (cond ((null elements) '()) ;; Base case: There are no elements that have yet to be printed. Don't do anything and return a null list. (t ;; Recursive case ;; Print the next elem...
ASP.NET identity is a membership management system which allows a user to register and login into a web application. ASP.NET identity system can be used in entire ASP.NET framework, like ASP.NET MVC, Web Forms, Web Pages, Web API and SignalR. ASP.NET identity can be used when people are building a w...
You can technically access the Google Analytics APIs using any programing language that can handle a HTTP Post or HTTP Get request. That being said, Google has also created a number of official standard client libraries to help you with this. Using a standard client library for your chosen programm...
For performance reasons, or due to the existence of mature C libraries, you may want to call C code from a Haskell program. Here is a simple example of how you can pass data to a C library and get an answer back. foo.c: #include <inttypes.h> int32_t foo(int32_t a) { return a+1; } F...
Let us assume the following stock market data stored in HDFS. It is a CSV file with fields: Symbol, Date, Open, High, Close & Volume. ABT,20160106,42.310001,42.98,42.209999,42.560001,5906000 BAC,20160201,14.05,14.09,13.8,13.96,105739400 CAS,20160129,1.9,1.97,1.83,1.84,34500 DCA,20160129,3.46...
Find div with id="article" and strip out all the inner script tags. #!/usr/bin/env stack -- stack --resolver lts-7.1 --install-ghc runghc --package text --package lens --package taggy-lens --package string-class --package classy-prelude {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE O...
Here is an example of an Azure Powershell automation runbook that deletes any blobs in an Azure storage container that are older than a number of days. This may be useful for removing old SQL backups to save cost and space. It takes a number of parameters which are self explanatory. Note: I have ...
View tables ActiveRecord::Base.connection.tables Delete any table. ActiveRecord::Base.connection.drop_table("users") ------------OR---------------------- ActiveRecord::Migration.drop_table(:users) ------------OR--------------------- ActiveRecord::Base.connect...

Page 969 of 1336