Tutorial by Examples: ces

<?php namespace App; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * Get the user's first name. * * @param string $value * @return string */ public function getFirstNameAttribute($value) { return ucfirst($v...
my @letters = ( 'a' .. 'z' ); # English ascii-bet print $letters[ rand @letters ] for 1 .. 5; # prints 5 letters at random How it works rand EXPR expects a scalar value, so @letters is evaluated in scalar context An array in scalar context returns the number of elements it ...
The example reads the first line from a file. It uses an instance of BufferedReader to read data from the file. BufferedReader is a resource that must be closed after the program is finished with it: static String readFirstLineFromFile(String path) throws IOException { try (BufferedReader br = n...
Not everything in a bindings library will have the same name in C# as it does in Java. In C#, interface names start with "I", but Java has no such convention. When you import a Java library, an interface named SomeInterface will become ISomeInterface. Similarly, Java doesn't have propert...
For simple cases, you can filter data directly. a = np.random.normal(size=10) print(a) #[-1.19423121 1.10481873 0.26332982 -0.53300387 -0.04809928 1.77107775 # 1.16741359 0.17699948 -0.06342169 -1.74213078] b = a[a>0] print(b) #[ 1.10481873 0.26332982 1.77107775 1.16741359 0.176999...
Expanding the parameter pack of indices in a comma expression with a value creates a copy of the value for each of the indices. Sadly, gcc and clang think the index has no effect and warn about it (gcc can be silenced by casting the index to void): #include <algorithm> #include <array>...
To generate schema, view, controller, migration file for the repository, default CRUD templates and test files for a model (like a scaffolding in Rails) one can use phoenix.gen.html mix task like this: mix phoenix.gen.html Book books title note:text pages:integer author_id:references:authors Wh...
The query string is the part of a request following the URL, preceded by a ? mark. Example: https://encrypted.google.com/search?hl=en&q=stack%20overflow For this example, we are making a simple echo webserver that echos back everything submitted to it via the echo field in GET requests. Examp...
You can access the form data submitted via a POST or PUT request in Flask via the request.form attribute. from flask import Flask, request app = Flask(import_name=__name__) @app.route("/echo", methods=["POST"]) def echo(): name = request.form.get("name"...
The plugin can, among others, access information about the current Maven project being built. @Mojo(name = "project") public final class ProjectNameMojo extends AbstractMojo { @Parameter(defaultValue = "${project}", readonly = true, required = true) private MavenPro...
In Twig templates variables can be accessed using double curly braces notation {{ variableName }}. Basic example of greeting user <!DOCTYPE html> <html> <body> <span>Hello {{ name }}</span> </body> </html> Accessing array elements Twig as ...
RunTime Type Services (short: RTTS) are used either for: creating types (RunTime Type Creation; short: RTTC) analysing types (RunTime Type Identification; short: RTTI) Classes CL_ABAP_TYPEDESCR | |--CL_ABAP_DATADESCR | | | |--CL_ABAP_ELEMDESCR | |--CL_ABAP_REFDESCR ...
The primary reason to use interfaces to achieve polymorphism and provide developers to implement on their own way in future by implementing interface's methods. Suppose we have an interface and three classes: interface Connector{ doConnect(): boolean; } This is connector interface. Now we...
To use standard location services while the application is in the background you need first turn on Background Modes in the Capabilities tab of the Target settings, and select Location updates. Or, add it directly to the Info.plist. <key>NSLocationAlwaysUsageDescription</key> <st...
[DscResource()] class File { } This example demonstrates how to build the outer section of a PowerShell class, that declares a DSC Resource. You still need to fill in the contents of the class definition.
[DscResource()] class Ticket { [DscProperty(Key)] [string] $TicketId } A DSC Resource must declare at least one key property. The key property is what uniquely identifies the resource from other resources. For example, let's say that you're building a DSC Resource that represents a ticket...
Create separate files for header and footer(as they are common for all the pages and it does not make sense to make them a part of a single page) Keep common elements(Like Search/Back/Next etc) in separate file(The idea is to remove any kind of duplication and keeping the segregation logical) Fo...
A Reference in C++ is just an Alias or another name of a variable. Just like most of us can be referred using our passport name and nick name. References doesn't exist literally and they don't occupy any memory. If we print the address of reference variable it will print the same address as that of...
We can create Singleton class in such a way that developers are forced to used the shared instance (singleton object) instead of creating their own instances. @implementation MySingletonClass + (instancetype)sharedInstance { static MySingletonClass *_sharedInstance = nil; static dispa...
The first step for coding for localization is to create default resources. This step is so implicit that many developers do not even think about it. However, creating default resources is important because if the device runs on an unsupported locale, it would load all of its resources from the defau...

Page 33 of 40