Tutorial by Examples

To obtain an instance of an HTTP Request, class Illuminate\Http\Request need to be type hint either in the constructor or the method of the controller. Example code: <?php namespace App\Http\Controllers; /* Here how we illuminate the request class in controller */ use Illuminate\Http\Re...
Sometimes we need to accept route params as well as access the HTTP Request params. We can still type hint the Requests class in laravel controller and achieve that as explained below E.g. We have a route that update a certain post like this (passing post id i route ) Route::put('post/{id}', 'Post...
import xlsxwriter # sample data chart_data = [ {'name': 'Lorem', 'value': 23}, {'name': 'Ipsum', 'value': 48}, {'name': 'Dolor', 'value': 15}, {'name': 'Sit', 'value': 8}, {'name': 'Amet', 'value': 32} ] # excel file path xls_file = 'chart.xlsx' # the workbook w...
Selecting all accounts that have open opportunity records under them SELECT Id, Name FROM Account WHERE AccountId IN (SELECT Id FROM Opportunity WHERE IsClosed = false)
In C, multi-line comments, /* and */, do not nest. If you annotate a block of code or function using this style of comment: /* * max(): Finds the largest integer in an array and returns it. * If the array length is less than 1, the result is undefined. * arr: The array of integers to search....
This test class will test the IsBlank(...) method of SomeClass. Below is the example SomeClass. This class has only the one, basic static method, but you will be unable to deploy it to a production instance for use until you have reached the code coverage threshold. public class SomeClass { ...
XML Data can be written as is in XQuery and will be found in the output. The following code can be considered valid XQuery : <application> <id>MyApp</id> <name>My Application</name> <version>1.0</version> </application> Note that your XQ...
To address data from an XML input, XQuery uses XPath. It makes it easy to filter data and restructure it. Given the following XML input <?xml version="1.0" encoding="UTF-8"?> <applications> <application> <id>MyApp</id> <name>My...
Each signed integer type may be represented in any one of three formats; it is implementation-defined which one is used. The implementation in use for any given signed integer type at least as wide as int can be determined at runtime from the two lowest-order bits of the representation of value -1 ...
Resolving scoped services during application startup can be difficult, because there is no request and hence no scoped service. Resolving a scoped service during application startup via app.ApplicationServices.GetService<AppDbContext>() can cause issues, because it will be created in the sc...
Visual Studio 2013 can be downloaded here The setup is pretty easy.Select features you need and select the disk to install VS13 on.Click install and wait for it to finish.
Various websites provide online access to C++ compilers. Online compiler's feature set vary significantly from site to site, but usually they allow to do the following: Paste your code into a web form in the browser. Select some compiler options and compile the code. Collect compiler and/or pro...
Stream iterators are useful when we need to read a sequence or print formatted data from a container: // Data stream. Any number of various whitespace characters will be OK. std::istringstream istr("1\t 2 3 4"); std::vector<int> v; // Constructing stream iterators and copyi...
from bs4 import BeautifulSoup import requests # Use the requests module to obtain a page res = requests.get('https://www.codechef.com/problems/easy') # Create a BeautifulSoup object page = BeautifulSoup(res.text, 'lxml') # the text field contains the source of the page # Now use a CSS ...
A defer statement consists of a block of code, which will be executed when a function returns and should be used for cleanup. As Swift's guard statements encourage a style of early return, many possible paths for a return may exist. A defer statement provides cleanup code, which then does not need ...
When using a defer-statement, make sure the code remains readable and the execution order remains clear. For example, the following use of the defer-statement makes the execution order and the function of the code hard to comprehend. postfix func ++ (inout value: Int) -> Int { defer { value...
A great existing example of the Adapter pattern can be found in the SWT MouseListener and MouseAdapter classes. The MouseListener interface looks as follows: public interface MouseListener extends SWTEventListener { public void mouseDoubleClick(MouseEvent e); public void mouseDown(MouseE...
functions.php: function rm_init_js() { wp_enqueue_script( 'custom-ajax-script', get_template_directory_uri() . '/js/ajax.js', array( 'jquery', 'wp-util' ), '1.0', true ); // pass custom variables to JS wp_localize_script( 'custom-ajax-script', 'BEJS', array( 'action' => ...
The image contained in the ImageView may not fit the exact size given to the container. In that case, the framework allows you to resize the image in a number of ways. Center <ImageView android:layout_width="20dp" android:layout_height="20dp" andr...
Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). Official Docs When the image matches the proportions of the container: When the image is...

Page 675 of 1336