Tutorial by Examples: amp

The keyword auto provides the auto-deduction of type of a variable. It is especially convenient when dealing with long type names: std::map< std::string, std::shared_ptr< Widget > > table; // C++98 std::map< std::string, std::shared_ptr< Widget > >::iterator i = table.fin...
In this example a custom LAMP project development environment is created with Vagrant. First of all you will need to install Virtual Box and Vagrant. Then, create a vagrant folder in your home directory, open your terminal and change the current directory to the new vagrant directory. Now, execute...
app.js angular.module('myApp', ['ui.router']) .controller('controllerOne', function() { this.message = 'Hello world from Controller One!'; }) .controller('controllerTwo', function() { this.message = 'Hello world from Controller Two!'; }) .controller('controllerThree', funct...
Syntax Syntax: log_format name string ...; Syntax: access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]]; access_log off; Using them together log_format compression '$remote_addr - $remote_user [$time_local] ' '"$request" $status...
Filters format the value of an expression for display to the user. They can be used in view templates, controllers or services. This example creates a filter (addZ) then uses it in a view. All this filter does is add a capital 'Z' to the end of the string. example.js angular.module('main', []) ...
This example is a snippet taken from the Extending Django User Profile like a Pro from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save class UserProfile(models.Model): user = models.OneToOneField(User, related_name='user'...
RoboGuice is a framework that brings the simplicity and ease of Dependency Injection to Android, using Google's own Guice library. @ContentView(R.layout.main) class RoboWay extends RoboActivity { @InjectView(R.id.name) TextView name; @InjectView(R.id.thumbnail) Image...
User input Imagine you want a user to enter a number via input. You want to ensure that the input is a number. You can use try/except for this: Python 3.x3.0 while True: try: nb = int(input('Enter a number: ')) break except ValueError: print('This is not a num...
This is an example of what a simple Arduino sketch looks like after being imported into Atmel Studio. Atmel Studio added the auto generated sections at the top. The rest is identical to the original Arduino code. If you expand the ArduinoCore project that was created and look in the src -> cor...
This is a simple but robust core-data set-up for iOS 10+. There are exactly two way to access core-data: viewContext. The viewContext can only be used from the main thread, and only for reading. strong enqueueCoreDataBlock. All writing should be done using enqueueCoreDataBlock. There is no ne...
// Core Data stack lazy var applicationDocumentsDirectory: NSURL = { let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) return urls[urls.count-1] }() lazy var managedObjectModel: NSManagedObjectModel = { let modelURL = NSB...
lazy var persistentContainer: NSPersistentContainer = { let container = NSPersistentContainer(name: "ProjectName") container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error { fatalError("Unreso...
For Python, Guido van Rossum based the grouping of statements on indentation. The reasons for this are explained in the first section of the "Design and History Python FAQ". Colons, :, are used to declare an indented code block, such as the following example: class ExampleClass: #Eve...
First, references will be added to the CLR assemblies that will be used. import clr clr.AddReference('System.Windows.Forms') Next the names we will use are imported. from System.Windows.Forms import Application, Form A class will be created for the Hello World form using Form as its subclas...
x = tf.constant(1.) bool = tf.constant(True) res = tf.cond(bool, lambda: tf.add(x, 1.), lambda: tf.add(x, 10.)) # sess.run(res) will give you 2.
Below won't work on a Windows machine $file = $request->file('file_upload'); $sampleName = 'UserUpload'; $destination = app_path() . '/myStorage/'; $fileName = $sampleName . '-' . date('Y-m-d-H:i:s') . '.' . $file->getClientOriginalExtension(); $file->move($destination, $fileName); ...
<form asp-action="create" asp-controller="Home"> <!--Your form elements goes here--> </form>
wikipedia definition: Command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time UML diagram from dofactory: Basic components and workflow: Command declares an interface for abst...
Let's say we need to add a button for each piece of loadedData array (for instance, each button should be a slider showing the data; for the sake of simplicity, we'll just alert a message). One may try something like this: for(var i = 0; i < loadedData.length; i++) jQuery("#container&q...
The following example is an introduction to: Template compilation using underscore Accessing variables in a template Creating a view Rendering a view Showing a view <html> <head> <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script> ...

Page 7 of 46