Tutorial by Examples

<script> $( ".inclas").datepicker({ minDate: new Date(2007, 1 - 1, 1) maxDate: new Date(2008, 1 - 1, 1) }); </script> <input type ="text" id="datepick" class="inclas">
The simple answer is that it allows you to evolve an existing interface without breaking existing implementations. For example, you have Swim interface that you published 20 years ago. public interface Swim { void backStroke(); } We did a great job, our interface is very popular, there ar...
Following the Rcpp example in this documentation entry, consider the following tough-to-vectorize function, which creates a vector of length len where the first element is specified (first) and each element x_i is equal to cos(x_{i-1} + 1): repeatedCosPlusOne <- function(first, len) { x <-...
Many-to-One Relationship from django.db import models class Author(models.Model): name = models.CharField(max_length=50) #Book has a foreignkey (many to one) relationship with author class Book(models.Model): author = models.ForeignKey(Author, on_delete=models.CASCADE) publish_...
Django ORM is a powerful abstraction that lets you store and retrieve data from the database without writing sql queries yourself. Let's assume the following models: class Author(models.Model): name = models.CharField(max_length=50) class Book(models.Model): name = models.CharField(max...
This example of the Sortable using a Placeholder is common usage. Sortable is applied to a group of DOM elements, allowing the user to move items around in the list via Drag'n Drop style actions. <!doctype html> <html lang="en"> <head> <meta charset="utf-8&q...
While the math.sqrt function is provided for the specific case of square roots, it's often convenient to use the exponentiation operator (**) with fractional exponents to perform nth-root operations, like cube roots. The inverse of an exponentiation is exponentiation by the exponent's reciprocal. S...
To access entities declared in a module from another program unit (module, procedure or program), the module must be used with the use statement. module shared_data implicit none integer :: iarray(4) = [1, 2, 3, 4] real :: rarray(4) = [1., 2., 3., 4.] end module program test !...
At some point in your use of Django, you may find yourself wanting to interact with tables which have already been created, or with database views. In these cases, you would not want Django to manage the tables through its migrations. To set this up, you need to add only one variable to your model's...
Literal format strings were introduced in PEP 498 (Python3.6 and upwards), allowing you to prepend f to the beginning of a string literal to effectively apply .format to it with all variables in the current scope. >>> foo = 'bar' >>> f'Foo is {foo}' 'Foo is bar' This works wi...
The background-position property is used to specify the starting position for a background image or gradient .myClass { background-image: url('path/to/image.jpg'); background-position: 50% 50%; } The position is set using an X and Y co-ordinate and be set using any of the units used withi...
The most simple example of widget is custom text input. For instance, to create an <input type="tel">, you have to subclass TextInput and set input_type to 'tel'. from django.forms.widgets import TextInput class PhoneInput(TextInput): input_type = 'tel'
You can create widgets composed of multiple widgets using MultiWidget. from datetime import date from django.forms.widgets import MultiWidget, Select from django.utils.dates import MONTHS class SelectMonthDateWidget(MultiWidget): """This widget allows the user to fill in ...
It is possible to configure Django to output log to a local or remote syslog service. This configuration uses the python builtin SysLogHandler. from logging.handlers import SysLogHandler LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'standard':...
This assumes that you have read the documentation about starting a new Django project. Let us assume that the main app in your project is named td (short for test driven). To create your first test, create a file named test_view.py and copy paste the following content into it. from django.test impo...
Detailed instructions on getting couchbase set up or installed.
Getting the Constructor Object You can obtain Constructor class from the Class object like this: Class myClass = ... // get a class object Constructor[] constructors = myClass.getConstructors(); Where the constructors variable will have one Constructor instance for each public constructor decl...
Many C interfaces such as SDL2 have their own deletion functions. This means that you cannot use smart pointers directly: std::unique_ptr<SDL_Surface> a; // won't work, UNSAFE! Instead, you need to define your own deleter. The examples here use the SDL_Surface structure which should be fre...
To demystify Template Haskell, suppose you have data Example a = Example { _foo :: Int, _bar :: a } then makeLenses 'Example produces (more or less) foo :: Lens' (Example a) Int bar :: Lens (Example a) (Example b) a b There's nothing particularly magical going on, though. You can write ...
A Lens' s a means that you can always find an a within any s. A Prism' s a means that you can sometimes find that s actually just is a but sometimes it's something else. To be more clear, we have _1 :: Lens' (a, b) a because any tuple always has a first element. We have _Just :: Prism' (Maybe a) a...

Page 152 of 1336