Tutorial by Examples: c

First the setup for the example: import datetime as dt from sqlalchemy import Column, Date, Integer, Text, create_engine, inspect from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() Session = sessionmaker() class User(B...
An overload without conversions needed for parameter types or only conversions needed between types that are still considered exact matches is preferred over an overload that requires other conversions in order to call. void f(int x); void f(double x); f(42); // calls f(int) When an argument b...
In SQLAlchemy core, the result is RowProxy. In cases where you want an explicit dictionary, you can call dict(row). First the setup for the example: import datetime as dt from sqlalchemy import ( Column, Date, Integer, MetaData, Table, Text, create_engine, select) metadata = MetaData() u...
Let's suppose we have a reference to the JQuery type definition and we want to extend it to have additional functions from a plugin we included and which doesn't have an official type definition. We can easily extend it by declaring functions added by plugin in a separate interface declaration with ...
Declare public variables and methods type in the interface to define how other typescript code can interact with it. interface ISampleClassInterface { sampleVariable: string; sampleMethod(): void; optionalVariable?: string; } Here we create a class that implements the interface. ...
Installation npm install -D webpack typescript ts-loader webpack.config.js module.exports = { entry: { app: ['./src/'], }, output: { path: __dirname, filename: './dist/[name].js', }, resolve: { extensions: ['', '.js', '.ts'], }, module: { loaders: [...
You can open a connection (i.e. request one from the pool) using a context manager: with engine.connect() as conn: result = conn.execute('SELECT price FROM products') for row in result: print('Price:', row['price']) Or without, but it must be closed manually: conn = engine.co...
If you only want to execute a single statement, you can use the engine directly and it will open and close the connection for you: result = engine.execute('SELECT price FROM products') for row in result: print('Price:', row['price'])
You can use engine.begin to open a connection and begin a transaction that will be rolled back if an exception is raised, or committed otherwise. This is an implicit way of using a transaction, since you don't have the option of rolling back manually. with engine.begin() as conn: conn.execute(...
JSON data can also be read from files. Let's assume we have a file called data.json with the following content: [ { "Name" : "John Doe", "Standard" : 4 }, { "Name" : "Peter Parker", "Standard" : ...
Implicit parameters can be useful if a parameter of a type should be defined once in the scope and then applied to all functions that use a value of that type. A normal function call looks something like this: // import the duration methods import scala.concurrent.duration._ // a normal method...
To retrieve a list of all servers registered on the instance: EXEC sp_helpserver;
Smoothing, also known as blurring, is one of the most commonly used operation in Image Processing. The most common use of the smoothing operation is to reduce noise in the image for further processing. There are many algorithms to perform smoothing operation. We'll look at one of the most commonl...
With the shape-outside CSS property one can define shape values for the float area so that the inline content wraps around the shape instead of the float's box. CSS img:nth-of-type(1) { shape-outside: circle(80px at 50% 50%); float: left; width: 200px; } img:nth-of-type(2) { shape-ou...
If you need to get a specific language or version of an item, you can use these overloads of GetItem() Sitecore.Context.Database.GetItem("/sitecore/content/Sitecore", Language.Current, new Version(5));
A hexadecimal number is a value in base-16. There are 16 digits, 0-9 and the letters A-F (case does not matter). A-F represent 10-16. An octal number is a value in base-8, and uses the digits 0-7. A binary number is a value in base-2, and uses the digits 0 and 1. All of these numbers result in ...
A resource is a special type of variable that references an external resource, such as a file, socket, stream, document, or connection. $file = fopen('/etc/passwd', 'r'); echo gettype($file); # Out: resource echo $file; # Out: Resource id #2 There are different (sub-)types of resource. Y...
Given a JList like JList myList = new JList(items); the selected items in the list can be modified through the ListSelectionModel of the JList: ListSelectionModel sm = myList.getSelectionModel(); sm.clearSelection(); // clears the selection sm.setSelectionInterval(inde...
Constructor overloading is not available in As3. In order to provide a different way to retrieve an instance of a class, a public static method can be provided to serve as an alternative "constructor". An example for that is flash.geom.Point, which represents a 2D point object. The coor...
To ensure encapsulation, member variables of a class should be private and only be accessible to public via public get/set access methods. It is a common practice to prefix private fields with _ public class Person { private var _name:String = ""; public function get name():S...

Page 155 of 826