Tutorial by Examples

A whole circle is 360 degrees or Math.PI * 2 radians. Half of those values follows to be 180 degrees or Math.PI radians. A quarter is then 90 degrees or Math.PI / 2 radians. To get a segment as a percentage of a whole circle in radians: function getSegment(percent:Number):Number { retur...
Assuming you have the angle you'd like to move in and an object with x and y values you want to move: var position:Point = new Point(10, 10); var angle:Number = 1.25; You can move along the x axis with Math.cos: position.x += Math.cos(angle); And the y axis with Math.sin: position.y += Mat...
You can test whether a point is inside a rectangle using Rectangle.containsPoint(): var point:Point = new Point(5, 5); var rectangle:Rectangle = new Rectangle(0, 0, 10, 10); var contains:Boolean = rectangle.containsPoint(point); // true
Prerequesites Grunt requires Node.js and npm to be installed. If you don’t have Node.js and/or npm installed on your machine, go to https://nodejs.org and download the installer or package for your operating system. First-time install If you're installing Grunt for the first time, you'll first ha...
A string can reversed using the built-in reversed() function, which takes a string and returns an iterator in reverse order. >>> reversed('hello') <reversed object at 0x0000000000000000> >>> [char for char in reversed('hello')] ['o', 'l', 'l', 'e', 'h'] reversed() can ...
In addition to predicates functioning as specs, you can register a spec globally using clojure.spec/def. def requires that a spec being registered is named by a namespace-qualified keyword: (clojure.spec/def ::odd-nums odd?) ;;=> :user/odd-nums (clojure.spec/valid? ::odd-nums 1) ;;=> tru...
clojure.spec/and & clojure.spec/or can be used to create more complex specs, using multiple specs or predicates: (clojure.spec/def ::pos-odd (clojure.spec/and odd? pos?)) (clojure.spec/valid? ::pos-odd 1) ;;=> true (clojure.spec/valid? ::pos-odd -3) ;;=> false or works similarl...
You can spec a record as follows: (clojure.spec/def ::name string?) (clojure.spec/def ::age pos-int?) (clojure.spec/def ::occupation string?) (defrecord Person [name age occupation]) (clojure.spec/def ::person (clojure.spec/keys :req-un [::name ::age ::occupation])) (clojure.spec/valid? ...
You can spec a map by specifying which keys should be present in the map: (clojure.spec/def ::name string?) (clojure.spec/def ::age pos-int?) (clojure.spec/def ::occupation string?) (clojure.spec/def ::person (clojure.spec/keys :req [::name ::age ::occupation])) (clojure.spec/valid? ::perso...
You can spec collections in a number of ways. coll-of allows you to spec collections and provide some additional constraints. Here's a simple example: (clojure.spec/valid? (clojure.spec/coll-of int?) [1 2 3]) ;; => true (clojure.spec/valid? (clojure.spec/coll-of int?) '(1 2 3)) ;; => tru...
spec can describe and be used with arbitrary sequences. It supports this via a number of regex spec operations. (clojure.spec/valid? (clojure.spec/cat :text string? :int int?) ["test" 1]) ;;=> true cat requires labels for each spec used to describe the sequence. cat describes a seq...
Sometimes you may only need to simulate an event with two outcomes, maybe with different probabilities, but you may find yourself in a situation that calls for many possible outcomes with different probabilities. Let's imagine you want to simulate an event that has six equally probable outcomes. T...
Consider a production table called questions_mysql and a table iwtQuestions (imported worktable) representing the last batch of imported CSV data from a LOAD DATA INFILE. The worktable is truncated before the import, the data is imported, and that process is not shown here. Update our production da...
9 Patches are stretchable images in which the areas which can be stretched are defined by black markers on a transparent border. There is a great tutorial here. Despite being so old, it's still so valuable and it helped many of us to deeply understand the 9 patch gear. Unfortunately, recently tha...
This example demonstrates creating a basic application in ExtJS using Sencha Cmd to bootstrap the process - this method will automatically generate some code and a skeleton structure for the project. Open a console window and change the working directory to an appropriate space in which to work. ...
A While loop starts by evaluating a condition. If it is true, the body of the loop is executed. After the body of the loop is executed, the While condition is evaluated again to determine whether to re-execute the body. Dim iteration As Integer = 1 While iteration <= 10 Console.Writeline(ite...
A package.json file, usually present in the project root, contains metadata about your app or module as well as the list of dependencies to install from npm when running npm install. To initialize a package.json type npm init in your command prompt. To create a package.json with default values use...
2.3-2.3.2 An enclosing CoordinatorLayout can be used to achieve Material Design Scrolling Effects when using inner layouts that support Nested Scrolling, such as NestedScrollView or RecyclerView. For this example: app:layout_scrollFlags="scroll|enterAlways" is used in the Toolbar pro...
Any time you instantiate a class that Implements IDisposable, you should call .Dispose1 on that class when you have finished using it. This allows the class to clean up any managed or unmanaged dependencies that it may be using. Not doing this could cause a memory leak. The Using keyword ensures th...
Sometimes, you have to create two Disposable objects in a row. There is an easy way to avoid nesting Using blocks. This code Using File As New FileStream("MyFile", FileMode.Append) Using Writer As New BinaryWriter(File) 'You code here Writer.Writer("Hello&quot...

Page 419 of 1336