Tutorial by Examples: c

Add the following dependency to your project level build.gradle file. dependencies { classpath "io.realm:realm-gradle-plugin:3.1.2" } Add the following right at the top of your app level build.gradle file. apply plugin: 'realm-android' Complete a gradle sync and you now have ...
(defun fn (x) (cond (test-condition1 the-value1) (test-condition2 the-value2) ... ... ... (t (fn reduced-argument-x)))) CL-USER 2788 > (defun my-fib (n) (cond ((= n 1) 1) ((= n...
(defun fn (x) (cond (test-condition the-value) (t (fn reduced-argument-x))))
Quicksort is a common sorting algorithm with an average case complexity of O(n log n) and a worst case complexity of O(n^2). Its advantage over other O(n log n) methods is that it can be executed in-place. Quicksort splits the input on a chosen pivot value, separating the list into those values tha...
Ruby has an or-equals operator that allows a value to be assigned to a variable if and only if that variable evaluates to either nil or false. ||= # this is the operator that achieves this. this operator with the double pipes representing or and the equals sign representing assigning of a valu...
Given a string, strspn calculates the length of the initial substring (span) consisting solely of a specific list of characters. strcspn is similar, except it calculates the length of the initial substring consisting of any characters except those listed: /* Provided a string of "tokens&quo...
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 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...
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', ...
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...
This example shows how to use two audio sources, and alter one of them based on the other. In this case we create an audio Ducker, that will lower the volume of the primary track if the secondary track produces sound. The ScriptProcessorNode will send regular events to its audioprocess handler. In ...
Matrix multiplication can be done in two equivalent ways with the dot function. One way is to use the dot member function of numpy.ndarray. >>> import numpy as np >>> A = np.ones((4,4)) >>> A array([[ 1., 1., 1., 1.], [ 1., 1., 1., 1.], [ 1., 1.,...

Page 257 of 826