Tutorial by Examples: def

A generic class is a class who adapts to a later-given type so that the same functionality can be offered to different types. In this basic example a generic class is created. It has a sub who uses the generic type T. While programming this class, we don't know the type of T. In this case T has ...
add_shortcode is wp keyword. // recent-posts is going to be our shortcode. add_shortcode('recent-posts', 'recent_posts_function'); // This function is taking action when recent post shortcode is called. function recent_posts_function() { query_posts(array('orderby' => 'date', 'order' =&...
This functions takes parameter for how many recent posts you want to display. Ex : you want to display only five recent posts. Just passed the arguments with posts="5" (you can pass any number of recent posts that you want to display). Function fetch only five recent posts from database....
There are four predefined markup extensions in XAML: x:Type supplies the Type object for the named type. This facility is used most frequently in styles and templates. <object property="{x:Type prefix:typeNameValue}" .../> x:Static produces static values. The values come from va...
When the user goes to the authorization endpoint, they will be asked to give your application permission to the scopes that you've requested. They can decline this, so you must make sure to take that into consideration in your code. After they've allowed your application access, the user will be red...
Now that you have an authorization code, you can make a POST to the token endpoint (https://api.twitch.tv/kraken/oauth2/token) to get an OAuth token. You will receive a JSON-encoded access token, refresh token, and a list of the scopes approved by the user. You can now use that token to make authent...
You can make a URI parameter optional by adding a question mark to the route parameter. You can also specify a default value by using the form parameter=value. public class BooksController : Controller { // eg: /books // eg: /books/1430210079 [Route(“books/{isbn?}”)] public Act...
You can also apply the [Route] attribute on the controller level, capturing the action as a parameter. That route would then be applied on all actions in the controller, unless a specific [Route] has been defined on a specific action, overriding the default set on the controller. [RoutePrefix(“prom...
The simplest manner of defining custom behavior for individual routes would be fairly easy. In this example we use it to authenticate a user : 1) routes.js: create a new property (like requireAuth) for any desired route angular.module('yourApp').config(['$routeProvider', function($routeProvider) ...
Lets say you have a simple ApiController like this: [HttpGet] [Route("test")] public dynamic Test() { dynamic obj = new ExpandoObject(); obj.prop1 = "some string"; obj.prop2 = 11; obj.prop3 = "another string"; ...
A ThreadPool is an ExecutorService that executes each submitted task using one of possibly several pooled threads, normally configured using Executors factory methods. Here is a basic code to initialize a new ThreadPool as a singleton to use in your app: public final class ThreadPool { priv...
If you browse your app's Assets folder you will notice that all resources are qualified by their scales (As you are required to put seperate files for each scaling in the package manifest). SplashScreen.scale-100.png SplashScreen.scale-125.png SplashScreen.scale-150.png SplashScreen.scale-200.pn...
You may have heard that everything in Python is an object. It is true, and all objects have a class: >>> type(1) int The literal 1 is an instance of int. Lets declare a class: >>> class Foo(object): ... pass ... Now lets instantiate it: >>> bar = Foo() Wh...
Before Auto Layout, you always had to tell buttons and other controls how big they should be, either by setting their frame or bounds properties or by resizing them in Interface Builder. But it turns out that most controls are perfectly capable of determining how much space they need, based on their...
With the below commands, user's default search_path can be set. Check search path before set default schema. postgres=# \c postgres user1 You are now connected to database "postgres" as user "user1". postgres=> show search_path; search_path ---------------- &q...
You can define your own behaviour by adding -callback directives in your module. For example, if modules implementing your behaviour need to have a foo function that takes an integer and returns an atom: -module(my_behaviour). -callback foo(integer()) -> atom(). If you use this behaviour in...
If you add default mask on the column, instead of actual value in SELECT statement will be shown mask: ALTER TABLE Company ALTER COLUMN Postcode ADD MASKED WITH (FUNCTION = 'default()')
// Default UINavigationBar appearance throughout the app [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-CondensedBold...
SASS gives you the ability to omit any parameter except the ones you want to overwrite of course. Let's take again the default-box example: @mixin default-box ($color: red, $borderColor: blue) { color: $color; border: 1px solid $borderColor; clear: both; display: block; mar...
Deferred execution enables combining different operations to build the final query, before evaluating the values: var list = new List<int>() {1,1,2,3,5,8}; var query = list.Select(x => x + 1); If we execute the query at this point: foreach (var x in query) { Console.Write($"...

Page 19 of 27