Tutorial by Examples: pre

An integer will be interpreted as an index lookup. IceCream.objects.filter(metadata__buyer__known_for__0='creating stack overflow') See the note in the "Remarks" section about chaining queries.
It is possible to detect whether an operator or function can be called on a type. To test if a class has an overload of std::hash, one can do this: #include <functional> // for std::hash #include <type_traits> // for std::false_type and std::true_type #include <utility> // for s...
If the mimetype of the HTTP request is application/json, calling request.get_json() will return the parsed JSON data (otherwise it returns None) from flask import Flask, jsonify app = Flask(__name__) @app.route('/api/echo-json', methods=['GET', 'POST', 'DELETE', 'PUT']) ...
You can use curly braces to interpolate expressions into string literals: def f(x: String) = x + x val a = "A" s"${a}" // "A" s"${f(a)}" // "AA" Without the braces, scala would only interpolate the identifier after the $ (in this case f...
Each time WordPress loads the page, it will run main loop. The loop is the way to iterate over all elements related to the page you are currently on. Main loop will work on a global WP_Query object. The query has a globalized method have_posts(), that allows us to loop through all results. Finally...
with pd.ExcelFile('path_to_file.xls) as xl: d = {sheet_name: xl.parse(sheet_name) for sheet_name in xl.sheet_names}
// A simple adder function defined as a lambda expression. // Unlike with regular functions, parameter types often may be omitted because the // compiler can infer their types let adder = |a, b| a + b; // Lambdas can span across multiple lines, like normal functions. let multiplier = |a: i32, ...
C++11 // Include sequence containers #include <vector> #include <deque> #include <list> #include <array> #include <forward_list> // Include sorting algorithm #include <algorithm> class Base { public: // Constructor that set variable to the va...
If the formatting (white space, new lines, indentation) of the code matters, use the pre element in combination with the code element: <pre> <code> x = 42 if x == 42: print "x is … … 42" </code> </pre> You still have to esc...
Using the Android API 23 or higher, very often such situation can be seen: This situation is caused by the structural change of the Android API regarding getting the resources. Now the function: public int getColor(@ColorRes int id, @Nullable Theme theme) throws NotFoundException should ...
The MediaPlayer$prepare() is a blocking call and will freeze the UI till execution completes. To solve this problem, MediaPlayer$prepareAsync() can be used. mMediaPlayer = ... // Initialize it here mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){ @Override public ...
To get started programming with CUDA, download and install the CUDA Toolkit and developer driver. The toolkit includes nvcc, the NVIDIA CUDA Compiler, and other software necessary to develop CUDA applications. The driver ensures that GPU programs run correctly on CUDA-capable hardware, which you'll ...
Solution 1: $('#parent').prepend($('#child')); Solution 2: $('#child').prependTo($('#parent')); Both solutions are prepending the element #child (adding at the beginning) to the element #parent. Before: <div id="parent"> <span>other content</span> </di...
Elements and attributes behave differently with respect to default namespaces. This is often the source of confusion. An attribute whose name has no prefix lives in no namespace, also when a default namespace is in scope. <?xml version="1.0"?> <foo attr="value" xmlns=...
We can use Predefined Constants for Date format in date() instead of the conventional date format strings since PHP 5.1.0. Predefined Date Format Constants Available DATE_ATOM - Atom (2016-07-22T14:50:01+00:00) DATE_COOKIE - HTTP Cookies (Friday, 22-Jul-16 14:50:01 UTC) DATE_RSS - RSS (Fri, 22...
Preconditions allows methods to provide minimum required values for input parameters Example... void DoWork(string input) { Contract.Requires(!string.IsNullOrEmpty(input)); //do work } Static Analysis Result...
Prelude is another popular starter kit. It features good support for various programming languages out-of-the-box including, notably - clojure. On *nix systems it can be installed with the following command: curl -L https://git.io/epre | sh
Let's say we want to replace only numbers with 2 digits: regular expression will find them with (\d\d) SELECT REGEXP_REPLACE ('2, 5, and 10 are numbers in this example', '(\d\d)', '#') FROM dual; Results in: '2, 5, and # are numbers in this example' If I want to swap parts of the text, I us...
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...
using System.Net; ... string serverResponse; try { // Call a method that performs an HTTP request (per the above examples). serverResponse = PerformHttpRequest(); } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse...

Page 6 of 34