Tutorial by Examples: amp

The following example shows how to use a QTimer to call a slot every 1 second. In the example, we use a QProgressBar to update its value and check the timer is working properly. main.cpp #include <QApplication> #include "timer.h" int main(int argc, char *argv[]) { QApp...
Instead of struct IShape { virtual ~IShape() = default; virtual void print() const = 0; virtual double area() const = 0; virtual double perimeter() const = 0; // .. and so on }; Visitors can be used: // The concrete shapes struct Square; struct Circle; // The v...
First thing to do is enable the mod rewrite on wamp go to Apache modules and scroll down the list If not showing tick enable it and then restart all servers. Linux users can also use below terminal command to enable rewrite module sudo a2enmod rewrite Then restart apache using: sudo service...
Dictionaries map keys to values. car = {} car["wheels"] = 4 car["color"] = "Red" car["model"] = "Corvette" Dictionary values can be accessed by their keys. print "Little " + car["color"] + " " + car["model&q...
Here is a class (Dog) creating its own dependency (Food): class Dog { public Dog() { var food = new Food(); this.eat(food); } } Here is the same class being injected with its dependency using constructor injection: class Dog { public Dog(Food food) { ...
Polymorphism is one of the pillar of OOP. Poly derives from a Greek term which means 'multiple forms'. Below is an example which exhibits Polymorphism. The class Vehicle takes multiple forms as a base class. The Derived classes Ducati and Lamborghini inherits from Vehicle and overrides the base cl...
Amp harnesses Promises [another name for Awaitables] and Generators for coroutine creation. require __DIR__ . '/vendor/autoload.php'; use Amp\Dns; // Try our system defined resolver or googles, whichever is fastest function queryStackOverflow($recordtype) { $requests = [ Dns\qu...
Anonymous class listener Before Java 8, it’s very common that an anonymous class is used to handle click event of a JButton, as shown in the following code. This example shows how to implement an anonymous listener within the scope of btn.addActionListener. JButton btn = new JButton("My Butto...
<style> input:in-range { border: 1px solid blue; } </style> <input type="number" min="10" max="20" value="15"> <p>The border for this value will be blue</p> The :in-range CSS pseudo-class matches when an element...
The following example shows the declaration of a property (StringProperty in this case) and demonstrates how to add a ChangeListener to it. import java.text.MessageFormat; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.beans.value.Ch...
This example shows how to use a readonly wrapper property to create a property that cannot be written to. In this case cost and price can be modified, but profit will always be price - cost. import java.text.MessageFormat; import javafx.beans.property.IntegerProperty; import javafx.beans.property...
Summary: MVVM is an architectural pattern that is represented by three distinct components, the Model, View and ViewModel. In order to understand these three layers, it is necessary to briefly define each, followed by an explanation of how they work together. Model is the layer that drives the bus...
This is an simple example to create a mysql server with docker 1.- create docker-compose.yml: Note: If you want to use same container for all your projects, you should create a PATH in your HOME_PATH. If you want to create it for every project you could create a docker directory in your project. ...
Depending on the version of Chart.JS you are using (the current one being 2.X), the syntax is different to create a minimal example of a bar chart (JSFiddle Demo for 2.X). Chart.js 2.X <html> <body> <canvas id="myChart" width="400" height="400&...
The 'Golden' method minimizes a unimodal function by narrowing the range in the extreme values import numpy as np from scipy.optimize import _minimize from scipy import special import matplotlib.pyplot as plt x = np.linspace(0, 10, 500) y = special.j0(x) optimize.minimize_scalar(special.j0,...
Brent's method is a more complex algorithm combination of other root-finding algorithms; however, the resulting graph isn't much different from the graph generated from the golden method. import numpy as np import scipy.optimize as opt from scipy import special import matplotlib.pyplot as plt ...
public class ShakeDetector implements SensorEventListener { private static final float SHAKE_THRESHOLD_GRAVITY = 2.7F; private static final int SHAKE_SLOP_TIME_MS = 500; private static final int SHAKE_COUNT_RESET_TIME_MS = 3000; private OnShakeListener mListener; pri...
Make a simple GUI application in 3 easy steps. 1. Design Open Qt Creator, create a new project and make your design. Save your result as .ui file (here: mainwindow.ui). 2. Generate corresponding .py file Now you can create a .py file from your .ui file that you generated in the previous step. ...
Facade is structural design pattern. It hides the complexities of large system and provides a simple interface to client. Client uses only Facade and it's not worried about inter dependencies of sub-systems. Definition from Gang of Four book: Provide a unified interface to a set of interfaces i...
An example cannot be associated with a version number directly. Parts of it can however be declared to apply only for certain versions. <!-- if version [eq Java SE 1.3] --> This content is for Java SE 1.3 <!-- end version if -->

Page 12 of 46