Tutorial by Examples: amp

Create a ModelForm from an existing Model class, by subclassing ModelForm: from django import forms class OrderForm(forms.ModelForm): class Meta: model = Order fields = ['item', 'order_date', 'customer', 'status']
The jQuery UI framework helps to extend and increase the User Interface controls for jQuery JavaScript library. When you wish to use jQuery UI, you will need to add these libraries to your HTML. A quick way to start is using the Content Delivery Network available code sources: jQuery Libraries ht...
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...
This type of tests make sure that your code compiles properly and will appear in the generated documentation for your project. In addition to that, the example tests can assert that your test produces proper output. sum.go: package sum // Sum calculates the sum of two integers func Sum(a, b in...
Tensorflow is more than just a deep learning framework. It is a general computation framework to perform general mathematical operations in a parallel and distributed manner. An example of such is described below. Linear Regression A basic statistical example that is commonly utilized and is r...
Ajax Get: Solution 1: $.get('url.html', function(data){ $('#update-box').html(data); }); Solution 2: $.ajax({ type: 'GET', url: 'url.php', }).done(function(data){ $('#update-box').html(data); }).fail(function(jqXHR, textStatus){ alert('Error occured: ' + te...
Server side: import socket serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversocket.bind(('localhost', 8089)) serversocket.listen(5) # become a server socket, maximum 5 connections while True: connection, address = serversocket.accept() buf = connection.recv(6...
You can validate request data using the validate method (available in the base Controller, provided by the ValidatesRequests trait). If the rules pass, your code will keep executing normally; however, if validation fails, an error response containing the validation errors will automatically be se...
Quote is a special operator that prevents evaluation of its argument. It returns its argument, unevaluated. CL-USER> (quote a) A CL-USER> (let ((a 3)) (quote a)) A
Meteor has several sample apps built-in. You can create a project with one of them and learn from how it was built. To create a sample app, install Meteor (see Getting Started) and then type: meteor create --example <app name> For example to create a sample todos app, write: meteor create...
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" <!-- etc --> > <!-- Internet is required. READ_LOGS are to ensure that the Logcat is transmitted--> <uses-perm...
This will show the user location on the map Objective-C [self.map setShowsUserLocation:YES]; Swift self.map?.showsUserLocation = true This will track the user location on the map, updating regions according Objective-C [self.map setUserTrackingMode:MKUserTrackingModeFollow]; Swift s...
views.py: from django.http import HttpResponse from django.views.generic import View class MyView(View): def get(self, request): # <view logic> return HttpResponse('result') urls.py: from django.conf.urls import url from myapp.views import MyView urlpatterns...
For full description of patterns, see SimpleDateFormat reference Date now = new Date(); long timestamp = now.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.US); String dateStr = sdf.format(timestamp);
docopt turns command-line argument parsing on its head. Instead of parsing the arguments, you just write the usage string for your program, and docopt parses the usage string and uses it to extract the command line arguments. """ Usage: script_name.py [-a] [-b] <path> ...
Have a table NameAgeCityBob10ParisMat20BerlinMary24Prague select Name from table where Age>10 AND City='Prague' Gives NameMary select Name from table where Age=10 OR City='Prague' Gives NameBobMary
Take any list and add an identifier to the outer wrapper (ul, div) <ul id="sortable"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> In your jquery: $(function(){ $('#sortable').sortable({ ...
An algorithmic problem is specified by describing the complete set of instances it must work on and of its output after running on one of these instances. This distinction, between a problem and an instance of a problem, is fundamental. The algorithmic problem known as sorting is defined as follows:...
This filter is very useful. One of the common problems for developers is how to include templates in plugins they develop. The filter is applied immediately after wordpress locates the appropriate template in the active child/parent theme using the wp hierarchy. Be careful to define when you want ...
add_filter('template_include', 'custom_function'); function custom_function($template){ /* * This example is a little more advanced. * It will check to see if $template contains our post-type in the path. * If it does, the theme contains a high level templat...

Page 3 of 46