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...
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
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? ...
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...
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...
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"...
Range sliders provide 2 draggable handles to select numeric values. The slider's initialization must provide a range option set to true to create a range slider:
<script>
$(function() {
$( "#range-slider" ).slider({
range: true
});
});
</script>
<...
A slider element can have its value set on initialization by providing a value option. This option is a number:
$( "#slider" ).slider({
value: 5
});
A range slider can also have its values set in this way by providing a values option. This option is an array of numbers:
$( &qu...
The slider provides an event called slide that will trigger whenever the mouse moves during a slider handle drag. This function holds a reference to the slide event and a reference to the slider ui object. The ui object holds a jQuery object for the handle being moved and the value(s) of the slide...
The slider provides an event called change that will trigger after the mouse completes a slider handle drag or if the value(s) have been changed programmatically. This function holds a reference to the slide event and a reference to the slider ui object. The ui object holds a jQuery object for the ...
The @Header and @Body annotations can be placed into the method signatures and Retrofit will automatically create them based on your models.
public interface MyService {
@POST("authentication/user")
Call<AuthenticationResponse> authenticateUser(@Body AuthenticationReques...
The background-origin property specifies where the background image is positioned.
Note: If the background-attachment property is set to fixed, this property has no effect.
Default value: padding-box
Possible values:
padding-box - The position is relative to the padding box
border-box - The p...
Definition and Usage: The background-clip property specifies the painting area of the background.
Default value: border-box
Values
border-box is the default value. This allows the background to extend all the way to the outside edge of the element's border.
padding-box clips the background at ...
Import in your gradle root file
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Import in your gradle app file
apt 'com.google.auto.value:auto-value:1.2'
apt 'com.ryanharter.auto.value:auto-value-gson:0.3.1'
provided 'com.jakewharton.auto.value:auto-value-annotations:1.2-update...
When you need to set a pixel value for something like Paint.setTextSize but still want it be scaled based on the device, you can convert dp and sp values.
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12f, m...