Tutorial by Examples: f

An example of "before" middleware would be as follows: <?php namespace App\Http\Middleware; use Closure; class BeforeMiddleware { public function handle($request, Closure $next) { // Perform action return $next($request); } } while &quot...
For functions that need to take a collection of objects, slices are usually a good choice: fn work_on_bytes(slice: &[u8]) {} Because Vec<T> and arrays [T; N] implement Deref<Target=[T]>, they can be easily coerced to a slice: let vec = Vec::new(); work_on_bytes(&vec); le...
The following output equivalent results: class IfElseExample { public string DebugToString(object a) { if (a is StringBuilder) { return DebugToStringInternal(a as StringBuilder); } else if (a is List<string>) { ...
The following method call enables usage of many advanced features such as sorting, filtering, and exporting data. alv->get_functions( )->set_all( ).
By default, when an ALV is displayed, the title at the top is just the program name. This method allows the user to set a title of up to 70 characters. The following example shows how a dynamic title can be set that displays the number of records displayed. alv->get_display_settings( )->set_l...
Suppose you have a parentView into which you want to insert a new subView programmatically (eg. when you want to insert an UIImageView into a UIViewController's view), than you can do it as below. Objective-C [parentView addSubview:subView]; Swift parentView.addSubview(subView) You can also...
Formats results of SELECT query as JSON text. FOR JSON PATH clause is added after query: SELECT top 3 object_id, name, type, principal_id FROM sys.objects FOR JSON PATH Column names will be used as keys in JSON, and cell values will be generated as JSON values. Result of the query would be an a...
FOR JSON PATH enables you to control format of the output JSON using column aliases: SELECT top 3 object_id as id, name as [data.name], type as [data.type] FROM sys.objects FOR JSON PATH Column alias will be used as a key name. Dot-separated column aliases (data.name and data.type) will be gen...
WITHOUT_ARRAY_WRAPPER option enables you to generate a single object instead of the array. Use this option if you know that you will return single row/object: SELECT top 3 object_id, name, type, principal_id FROM sys.objects WHERE object_id = 3 FOR JSON PATH, WITHOUT_ARRAY_WRAPPER Single obje...
Automatically nests values from the second table as a nested sub-array of JSON objects: SELECT top 5 o.object_id, o.name, c.column_id, c.name FROM sys.objects o JOIN sys.columns c ON o.object_id = c.object_id FOR JSON AUTO Result of the query would be array of JSON objects: [ { &...
Select all columns from some table (system table in this case): SELECT * FROM sys.objects Or, select just some specific columns: SELECT object_id, name, type, create_date FROM sys.objects
WHERE clause filters only those rows that satisfy some condition: SELECT * FROM sys.objects WHERE type = 'IT'
HAVING clause removes groups that do not satisfy condition: SELECT type, count(*) as c FROM sys.objects GROUP BY type HAVING count(*) < 10 typecSQ3PK1U5
TOP clause returns only first N rows in the result: SELECT TOP 10 * FROM sys.objects
OFFSET FETCH clause is more advanced version of TOP. It enables you to skip N1 rows and take next N2 rows: SELECT * FROM sys.objects ORDER BY object_id OFFSET 50 ROWS FETCH NEXT 10 ROWS ONLY You can use OFFSET without fetch to just skip first 50 rows: SELECT * FROM sys.objects ORDER BY obj...
SELECT statement can be executed without FROM clause: declare @var int = 17; SELECT @var as c1, @var + 2 as c2, 'third' as c3 In this case, one row with values/results of expressions are returned.
This example shows a helper class that contains methods useful, when executing the queries for data. Every method here uses Java Generic's in order to be very flexible. public <T> List<T> selectElements(AbstractDao<T, ?> dao) { if (dao == null) { return null; } ...
@Singleton @Component(modules = AppModule.class) public interface AppComponent { void inject(App app); Context provideContext(); Gson provideGson(); MainActivityComponent mainActivityComponent(ActivityModule activityModule); } @ActivityScope @Subcomponent(modules = Act...
This technique details how to ensure that your .apk has been signed with your developer certificate, and leverages the fact that the certificate remains consistent and that only you have access to it. We can break this technique into 3 simple steps: Find your developer certificate signature. Em...
The following are some of the more common/useful shortcuts. These are based on the default IntelliJ shortcut map. You can switch to other common IDE shortcut maps via File -> Settings -> Keymap -> <Choose Eclipse/Visual Studio/etc from Keymaps dropdown> ActionShortcutFormat codeCTRL...

Page 212 of 457