Tutorial by Examples: ce

In this example, base class Singleton provides getMessage() method that returns "Hello world!" message. It's subclasses UppercaseSingleton and LowercaseSingleton override getMessage() method to provide appropriate representation of the message. //Yeah, we'll need reflection to pull this ...
The below example uses Android.Runtime.InputStreamInvoker and Android.Runtime.OutputStreamInvoker types obtain Java.IO.InputStream and Java.IO.OutputStream. Once we have a Java.IO.InputStream instance, we can use its .Available() method to get the number of available response bytes which we can use...
Many argue that Java is ONLY pass-by-value, but it's more nuanced than that. Compare the following C++ and Java examples to see the many flavors of pass-by-value (aka copy) and pass-by-reference (aka alias). C++ Example (complete code) // passes a COPY of the object static void passByCopy(Pa...
C++ & Java are both object-oriented languages, thus the following diagram applies to both.
Step 1: Make a design of GridView for displaying your data (HTML Code): <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField HeaderText="ID"> <ItemTemplate> ...
Design of Nested-GridView (HTML Code): <asp:GridView ID="gvParent" runat="server" AutoGenerateColumns="false" OnRowDataBound="gvParent_RowDataBound"> <Columns> <asp:TemplateField HeaderText="Parent Column"> ...
After installing perforce and setup your workspace through p4v, you could set up your workspace in Windows cmd. The command you need is: p4 set Set your server p4 set P4PORT= xx.xxx.xx.xxx:xxxxx Set your user name p4 set P4USER=username Set your password In terms of setting your passwo...
Room require four parts: Database class, DAO classes, Entity classes and Migration classes (now you may use only DDL methods): Entity classes // Set custom table name, add indexes @Entity(tableName = "videos", indices = {@Index("title")} ) public final class VideoIt...
PSR-8 is a spoof PSR (currently in Draft) proposed by Larry Garfield as an April Fools joke on 1 April 2014. The draft outlines how to define an interface to make an object Huggable. Excert from the code outline: <?php namespace Psr\Hug; /** * Defines a huggable object. * * A hugga...
So the most used functions on Clojure map and filter have been modified to return transducers (composable algorithmic transformations), if not called with a collection. That means: (map inc) returns a transducer and so does (filter odd?) The advantage: the functions can be composed into a single f...
Here, we have created a user-defined exception called CustomError which is derived from the Exception class. This new exception can be raised, like other exceptions, using the raise statement with an optional error message. class CustomError(Exception): pass x = 1 if x == 1: rais...
This example shows how to catch custom Exception class CustomError(Exception): pass try: raise CustomError('Can you catch me ?') except CustomError as e: print ('Catched CustomError :{}'.format(e)) except Exception as e: print ('Generic exception: {}'.format(e)) Output:...
To remove whitespace (spaces, tabs, newlines…) between HTML tags use spaceless tag: {% spaceless %} <div> <span>foo bar </span> </div> {% endspaceless %} {# produces output <div><strong>foo bar </strong></div> #} If you need ...
Consider Kotlin's Null Type system and WeakReference<T>. So let's say we have to save some sort of reference and we wanted to avoid memory leaks, here is where WeakReference comes in. take for example this: class MyMemoryExpensiveClass { companion object { var reference: WeakR...
Using Intents to Load the Image from Gallery. Initially you need to have the permission <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> Use the Following Code to have the layout as designed follows. <?xml version="1.0" enco...
/***************************** login user @required : username and password via post method only @return user data if login successfull otherwise error message ****************************/ public function login(){ $username=$this->input->post('username'); $password=$this->input-...
Acknowledgement This example is adapted from this article on type inference What is type Inference? Type Inference is the mechanism that allows the compiler to deduce what types are used and where. This mechanism is based on an algorithm often called “Hindley-Milner” or “HM”. See below some of th...
Please me mindful of importing all necessary libraries required. This example uses InMemoryDbService from angular-in-memory-web-api to provide the JSON data from mock API. Live demo service.ts: import { Injectable } from '@angular/core'; import { Headers, Http } from '@angular/http'; import...
The machine has to automatically determine the ideal behavior to maximize its performance. For example: Using reinforcement learning you can also make a computer program that can complete a Mario level (MarI/O - Machine Learning for Video Games).
import { Injectable } from '@angular/core'; import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; import { UserService } from '../services/user.service'; import { Observable } from 'rxjs/Observable'; @Injectable() export class AuthHeaderInterceptor imple...

Page 133 of 134