Tutorial by Examples: amp

Query to create table on db CREATE TABLE `user` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL, `course` smallint(5) unsigned DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB; CREATE TABLE `course` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `nam...
Unlike other middleware functions error-handling middleware functions have four arguments instead of three: (err, req, res, next). Sample: app.use(function(err, req, res, next) { console.error(err.stack); res.status(500).send('Error found!'); });
Directives, as the name suggests, are direction or instructions for the container to follow when translating a JSP to a servlet. There are 3 directives namely page, include and taglib which you can use in your JSP. Below is a simple example of using page directive: <%@ page isErrorPage="tr...
package { import flash.events.TimerEvent; import flash.utils.Timer; public class CountdownTimer extends Timer { public var time:Number = 0; public function CountdownTimer(time:Number = Number.NEGATIVE_INFINITY, delay:Number = 1000) { super(delay, repeatCount); ...
ga('create', 'UA-XXXX-Y', {'sampleRate': 5}); Optional. This may only be set in the create method. Specifies what percentage of users should be tracked. This defaults to 100 (no users are sampled out) but large sites may need to use a lower sample rate to stay within Google Analytics processing ...
Callbacks offer a way to extend the functionality of a function (or method) without changing its code. This approach is often used in modules (libraries / plugins), the code of which is not supposed to be changed. Suppose we have written the following function, calculating the sum of a given array ...
By default, all the .panel does is apply some basic border and padding to contain some content. <div class="panel panel-default"> <div class="panel-body"> Basic panel example </div> </div>
The fundamental concept of the customizer is that admins can live preview changes to their site, and then permanently add them. The following can be copied and pasted into a theme's functions.php file to Add a customizer section called My First Section Add a customizer setting called Hello Worl...
import java.io.*; import java.net.Socket; public class Main { public static void main(String[] args) throws IOException {//We don't handle Exceptions in this example //Open a socket to stackoverflow.com, port 80 Socket socket = new Socket("stackoverflow.com",8...
This example is a basic setup for unittesting the StringBuilder.toString() using junit. import static org.junit.Assert.assertEquals; import org.junit.Test; public class StringBuilderTest { @Test public void stringBuilderAppendShouldConcatinate() { StringBuilder stringBui...
Strategy: Strategy is a behavioural pattern, which allows to change the algorithm dynamically from a family of related algorithms. UML of Strategy pattern from Wikipedia : import java.util.*; /* Interface for Strategy */ interface OfferStrategy { public String getName(); public dou...
Cryptography is something very hard and after spending a lot of time reading different examples and seeing how easy it is to introduce some form of vulnerability I found an answer originally written by @jbtule that I think is very good. Enjoy reading: "The general best practice for symmetric e...
Throughout this example it is assumed that the 'root' object that is being serialized to JSON is an instance of the following class : public class MyJson { }   Example 1 : An example of an instance of MyJson, as is: {} i.e. since the class has no fields, only curly brackets are serialized...
This is a script saved as .Rmd, on the contrary of r scripts saved as .R. To knit the script, either use the render function or use the shortcut button in Rstudio. --- title: "Rstudio exemple of a rmd file" author: 'stack user' date: "22 July 2016" output: html_document -...
The CSS multi-column layout makes it easy to create multiple columns of text. Code <div id="multi-columns">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation...
@input is useful to bind data between components First, import it in your component import { Input } from '@angular/core'; Then, add the input as a property of your component class @Input() car: any; Let's say that the selector of your component is 'car-component', when you call the compone...
+ dictionaryWithCapacity: Creates and returns a mutable dictionary, initially giving it enough allocated memory to hold a given number of entries. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:1]; NSLog(@"%@",dict); - init Initializes a newly allocated mut...
ListView - A core component designed for efficient display of vertically scrolling lists of changing data. The minimal API is to create a ListView.DataSource, populate it with a simple array of data blobs, and instantiate a ListView component with that data source and a renderRow callback which take...
angular.module('app', []) .controller('myController', ['$scope', function($scope){ $scope.person = { name: 'John Doe' }; }]); <div ng-app="app" ng-conroller="myController"> <input ng-model="person.name" /> <div ng-repeat="number i...
CSS resets take separate approaches to browser defaults. Eric Meyer’s Reset CSS has been around for a while. His approach nullifies many of the browser elements that have been known to cause problems right off the back. The following is from his version (v2.0 | 20110126) CSS Reset. html, body, di...

Page 8 of 46