Tutorial by Examples: au

Add gem to the Gemfile: gem 'devise' Then run the bundle install command. Use command $ rails generate devise:install to generate required configuration file. Set up the default URL options for the Devise mailer in each environment In development environment add this line: config.action_mailer...
To separate a URL into its individual components, use parse_url(): $url = 'http://www.example.com/page?foo=1&bar=baz#anchor'; $parts = parse_url($url); After executing the above, the contents of $parts would be: Array ( [scheme] => http [host] => www.example.com [path...
Rails files - and Ruby files in general - should be named with lower_snake_case filenames. E.g. app/controllers/application_controller.rb is the file that contains the ApplicationController class definition. Note that while PascalCase is used for class and module names, the files in which they r...
Alamofire.request("https://httpbin.org/get").validate().responseJSON { response in switch response.result { case .success: print("Validation Successful") case .failure(let error): print(error) } }
You can also receive regular updates of the user's location; for example, as they move around while using a mobile device. Location tracking over time can be very sensitive, so be sure to explain to the user ahead of time why you're requesting this permission and how you'll use the data. if (naviga...
Optional Parameters In TypeScript, every parameter is assumed to be required by the function. You can add a ? at the end of a parameter name to set it as optional. For example, the lastName parameter of this function is optional: function buildName(firstName: string, lastName?: string) { // ...
Value Type (where T : struct) The built-in primitive data types, such as char, int, and float, as well as user-defined types declared with struct, or enum. Their default value is new T() : default(int) // 0 default(DateTime) // 0001-01-01 12:00:00 AM default(char) // '...
The default namespace is the namespace corresponding to the absence of any prefix. It can be declared with the special xmlns attribute. <?xml version="1.0"?> <foo xmlns="http://www.example.com/my-namespace"> <!-- the element foo is in the namespace htt...
This example will show you how to quickly get a hello world Aurelia application up and running using the Aurelia CLI. Prerequisites The Aurelia CLI is a Node.js based application, so make sure you install it first before proceeding. You will need Node.js 4.4.7 or later. You will also need a Git c...
Technically, autoloading works by executing a callback when a PHP class is required but not found. Such callbacks usually attempt to load these classes. Generally, autoloading can be understood as the attempt to load PHP files (especially PHP class files, where a PHP source file is dedicated for a ...
Imagine you have the following HTML: <div> <label>Name:</label> John Smith </div> And you need to locate the text "John Smith" after the label element. In this case, you can locate the label element by text and then use .next_sibling property: from ...
BeautifulSoup has a limited support for CSS selectors, but covers most commonly used ones. Use select() method to find multiple elements and select_one() to find a single element. Basic example: from bs4 import BeautifulSoup data = """ <ul> <li class="item&quo...
Sample Data: CREATE TABLE table_name ( id, list ) AS SELECT 1, 'a,b,c,d' FROM DUAL UNION ALL -- Multiple items in the list SELECT 2, 'e' FROM DUAL UNION ALL -- Single item in the list SELECT 3, NULL FROM DUAL UNION ALL -- NULL list SELECT 4, 'f,,g' FROM DUAL; -- NULL item...
Good unit tests are independent, but code often has dependencies. We use various kinds of test doubles to remove the dependencies for testing. One of the simplest test doubles is a stub. This is a function with a hard-coded return value called in place of the real-world dependency. // Test that ...
This example shows how to use the default logging api. import java.util.logging.Level; import java.util.logging.Logger; public class MyClass { // retrieve the logger for the current class private static final Logger LOG = Logger.getLogger(MyClass.class.getName()); pub...
Smoothing, also known as blurring, is one of the most commonly used operation in Image Processing. The most common use of the smoothing operation is to reduce noise in the image for further processing. There are many algorithms to perform smoothing operation. We'll look at one of the most commonl...
Use the HTML or <audio> element to embed video/audio content in a document. The video/audio element contains one or more video/audio sources. To specify a source, use either the src attribute or the <source> element; the browser will choose the most suitable one. Audio tag example: &...
When Oracle implicitly converts from a DATE to a string or vice-versa (or when TO_CHAR() or TO_DATE() are explicitly called without a format model) the NLS_DATE_FORMAT session parameter will be used as the format model in the conversion. If the literal does not match the format model then an excepti...
HTML5 provides a new standard for embedding an audio file on a web page. You can embed an audio file to a page using the <audio> element: <audio controls> <source src="file.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audi...
Similar to the built-in function zip(), itertools.zip_longest will continue iterating beyond the end of the shorter of two iterables. from itertools import zip_longest a = [i for i in range(5)] # Length is 5 b = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] # Length is 7 for i in zip_longest(a, b): x...

Page 7 of 37