Tutorial by Examples: c

class Digit { public Digit(double d) { val = d; } public double val; // User-defined conversion from Digit to double public static implicit operator double(Digit d) { Console.WriteLine("Digit to double implict conversion called"); return d.val;...
Above I noticed an example to remove items from a List within a Loop and I thought of another example that may come in handy this time using the Iterator interface. This is a demonstration of a trick that might come in handy when dealing with duplicate items in lists that you want to get rid of. N...
Customer Model package org.bookmytickets.model; import org.springframework.data.annotation.Id; public class Customer { @Id private String id; private String firstName; private String lastName; public Customer() {} public Customer(String firstName, String la...
package org.bookmytickets.controller; import java.util.List; import org.bookmytickets.model.Customer; import org.bookmytickets.repository.CustomerRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import o...
package org.bookmytickets.repository; import java.util.List; import org.bookmytickets.model.Customer; import org.springframework.data.mongodb.repository.MongoRepository; public interface CustomerRepository extends MongoRepository<Customer, String> { public Customer findByFirstNa...
For testing our application, I'm using advance rest client which is chrome extension: So, here is the snapshot for inserting the data:
A Intersection Type combines the member of two or more types. interface Knife { cut(); } interface BottleOpener{ openBottle(); } interface Screwdriver{ turnScrew(); } type SwissArmyKnife = Knife & BottleOpener & Screwdriver; function use(tool: SwissArmyKnife){ ...
Within a LOOP, you can use the Common Lisp (return) form in any expression, which will cause the LOOP form to immediately evaluate to the value given to return. LOOP also has a return clause which works almost identically, the only difference being that you don't surround it with parentheses. The c...
CSS and JS files should be reside under 'static' directory in the root directory of module (the rest of subdirectory tree under 'static' is an optional convention): static/src/css/your_file.css static/src/js/your_file.js Then add links to these files unsing one of the 3 ways listed in the fol...
Odoo v8.0 way is to add corresponding record in the XML file: ​Add XML file to the manifest (i.e. __openerp__.py file.): ... 'data' : [ 'your_file.xml' ], ​... Then add following record in 'your_file.xml': <openerp> <data> <template id="...
Note: you should use this way if you've installed a "website" module and you have a public website available. Add following record in 'your_file.xml': <openerp> <data> <template id="assets_frontend" name="your_module_name assets" inherit...
Add following record in 'your_file.xml': <openerp> <data> <template id="assets_common" name="your_module_name assets" inherit_id="web.assets_common"> <xpath expr="." position="inside"> <link rel...
With the Class Based generic Views, it is very simple and easy to create the CRUD views from our models. Often, the built in Django admin is not enough or not preferred and we need to roll our own CRUD views. The CBVs can be very handy in such cases. The CreateView class needs 3 things - a model, t...
Starting with a three-dimensional list: alist = [[[1,2],[3,4]], [[5,6,7],[8,9,10], [12, 13, 14]]] Accessing items in the list: print(alist[0][0][1]) #2 #Accesses second element in the first list in the first list print(alist[1][1][2]) #10 #Accesses the third element in the second list in...
Introduction and motivation Expression templates (denoted as ETs in the following) are a powerful template meta-programming technique, used to speed-up calculations of sometimes quite expensive expressions. It is widely used in different domains, for example in implementation of linear algebra ...
There are two different types of descriptors. Data descriptors are defined as objects that define both a __get__() and a __set__() method, whereas non-data descriptors only define a __get__() method. This distinction is important when considering overrides and the namespace of an instance's dictiona...
The widely used combination of tic and toc can provide a rough idea of the execution time of a function or code snippets. For comparing several functions it shouldn't be used. Why? It is almost impossible to provide equal conditions for all code snippets to compare within a script using above solu...
{-# LANGUAGE OverloadedStrings #-} import qualified Data.Text as T myText :: T.Text myText = "\n\r\t leading and trailing whitespace \t\r\n" strip removes whitespace from the start and end of a Text value. ghci> T.strip myText "leading and trailing whitespace" ...
Encoding and decoding functions for a variety of Unicode encodings can be found in the Data.Text.Encoding module. ghci> import Data.Text.Encoding ghci> decodeUtf8 (encodeUtf8 "my text") "my text" Note that decodeUtf8 will throw an exception on invalid input. If you wa...
Type ghci at a shell prompt to start GHCI. $ ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Prelude>

Page 278 of 826