Tutorial by Examples

Calling the dependencies task allows you to see the dependencies of the root project: gradle dependencies The results are dependency graphs (taking into account transitive dependencies), broken down by configuration. To restrict the displayed configurations, you can pass the --configuration opti...
You have to point Gradle to the location of your plugins so Gradle can find them. Do this by adding a repositories { ... } to your build.gradle. Here's an example of adding three repositories, JCenter, Maven Repository, and a custom repository that offers dependencies in Maven style. repositories...
This example shows how to open a default dialer (an app that makes regular calls) with a provided telephone number already in place: Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:9988776655")); //Replace with valid phone number. Remember to add the tel: pr...
You can pass latitude, longitude from your app to Google map using Intent String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?q=loc:%f,%f", 28.43242324,77.8977673); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); startActivity(intent);
Rules for creating a dictionary: Every key must be unique (otherwise it will be overridden) Every key must be hashable (can use the hash function to hash it; otherwise TypeError will be thrown) There is no particular order for the keys. # Creating and populating it with values stock = {'egg...
def foobar(foo=None, bar=None): return "{}{}".format(foo, bar) values = {"foo": "foo", "bar": "bar"} foobar(**values) # "foobar"
class A: x = None # type: float def __init__(self, x: float) -> None: """ self should not be annotated init should be annotated to return None """ self.x = x @classmethod def from_int(cls, x: int...
Variables are annotated using comments: x = 3 # type: int x = negate(x) x = 'a type-checker might catch this error' Python 3.x3.6 Starting from Python 3.6, there is also new syntax for variable annotations. The code above might use the form x: int = 3 Unlike with comments, it is also pos...
Double quoteSingle quoteAllows variable expansionPrevents variable expansionAllows history expansion if enabledPrevents history expansionAllows command substitutionPrevents command substitution* and @ can have special meaning* and @ are always literalsCan contain both single quote or double quoteSin...
x = 5 x += 7 for x in iterable: pass Each of the above statements is a binding occurrence - x become bound to the object denoted by 5. If this statement appears inside a function, then x will be function-local by default. See the "Syntax" section for a list of binding statements. ...
One way to mock a function is to use the create_autospec function, which will mock out an object according to its specs. With functions, we can use this to ensure that they are called appropriately. With a function multiply in custom_math.py: def multiply(a, b): return a * b And a function...
You can force deallocate objects even if their refcount isn't 0 in both Python 2 and 3. Both versions use the ctypes module to do so. WARNING: doing this will leave your Python environment unstable and prone to crashing without a traceback! Using this method could also introduce security problems ...
Create User Model rails generate model User email:string password_digest:string Add has_secure_password module to User model class User < ActiveRecord::Base has_secure_password end Now you can create a new user with password user = User.new email: '[email protected]', password: 'Password1', ...
By default PHP will output errors, warnings and notice messages directly on the page if something unexpected in a script occurs. This is useful for resolving specific issues with a script but at the same time it outputs information you don't want your users to know. Therefore it's good practice to ...
To play audio using the Web Audio API, we need to get an ArrayBuffer of audio data and pass it to a BufferSource for playback. To get an audio buffer of the sound to play, you need to use the AudioContext.decodeAudioData method like so: const audioCtx = new (window.AudioContext || window.webkitAud...
User Prompts are methods part of the Web Application API used to invoke Browser modals requesting a user action such as confirmation or input. window.alert(message) Show a modal popup with a message to the user. Requires the user to click [OK] to dismiss. alert("Hello World"); More...
When using prompt a user can always click Cancel and no value will be returned. To prevent empty values and make it more persistent: <h2>Welcome <span id="name"></span>!</h2> <script> // Persistent Prompt modal var userName; while(!userName) { userN...
A way to use confirm() is when some UI action does some destructive changes to the page and is better accompanied by a notification and a user confirmation - like i.e. before deleting a post message: <div id="post-102"> <p>I like Confirm modals.</p> <a data-dele...
Using the dataset property The new dataset property allows access (for both reading and writing) to all data attributes data-* on any element. <p>Countries:</p> <ul> <li id="C1" onclick="showDetails(this)" data-id="US" data-dial-code="1&q...
The code below will prompt for numbers and continue to add them to the beginning of a linked list. /* This program will demonstrate inserting a node at the beginning of a linked list */ #include <stdio.h> #include <stdlib.h> struct Node { int data; struct Node* next; }; ...

Page 417 of 1336