Tutorial by Examples

# app.rb require 'sinatra' get '/' do 'Hello, Universe!' end Install Sinatra: gem install sinatra Run the app: ruby app.rb That's it! Access your app at http://localhost:4567
var xhr = $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); //kill the request xhr.abort()
There are two possible ways of including LaTeX preamble commands (e.g. \usepackage) in a RMarkdown document. 1. Using the YAML option header-includes: --- title: "Including LaTeX Preample Commands in RMarkdown" header-includes: - \renewcommand{\familydefault}{cmss} - \usepacka...
A bibtex catalogue cna easily be included with the YAML option bibliography:. A certain style for the bibliography can be added with biblio-style:. The references are added at the end of the document. --- title: "Including Bibliography" author: "John Doe" output: pdf_documen...
To include a database in your app, you typically derive a class from SQLiteOpenHelper: public class HelloDBHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final int DATABASE_NAME = "hello"; HelloDBHelper(Context context) {...
A simple POST request with authentication data is demonstrated below, note that the username and password field will vary depending on the website: final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"; ...
Most websites require a much more complicated process than the one demonstrated above. Common steps for logging into a website are: Get the unique cookie from the initial login form. Inspect the login form to see what the destination url is for the authentication request Parse the login form t...
page.html - source code <html> <head> <script src="loadData.js"></script> </head> <body onLoad="loadData()"> <div class="container"> <table id="data" border="1"> <...
<%@ Language="VBScript" CodePage = 65001 %> <% Option Explicit Response.Charset = "UTF-8" Response.CodePage = 65001 %> <!doctype html> <html> <head> <title>My First Classic ASP Page</title> </head> <body&gt...
For a thick arrow pointing north in a span, add classes ui-icon and ui-icon-arrowthick-1-n: <span class="ui-icon ui-icon-arrowthick-1-n"></span> For a triangle pointing south in a span, add classes ui-icon and ui-icon-triangle-1-s: <span class="ui-icon ui-icon-tria...
To be more clear, let's create a script named showarg: #!/usr/bin/env bash printf "%d args:" $# printf " <%s>" "$@" echo Now let's see the differences: $ var="This is an example" $ showarg $var 4 args: <This> <is> <an> <exa...
VB now allows string literals that split over multiple lines. Old syntax: Dim text As String = "Line1" & Environment.NewLine & "Line2" New syntax: Dim text As String = "Line 1 Line 2"
Enables a code to be statically compiled. Its bytecode will be closer to Java's, thus having better performance, though some dynamic features won't be available. @groovy.transform.CompileStatic class ListMath { def countSize(List<String> strings) { strings.collect { it.size() }...
VB.NET offers default Form instances. The developer does not need to create the instance as it is created behind the scenes. However, it is not preferable to use the default instance all but the simplest programs. Public Class Form1 Public Sub Foo() MessageBox.Show("Bar") ...
The built-in werkzeug server certainly is not suitable for running production servers. The most obvious reason is the fact that the werkzeug server is single-threaded and thus can only handle one request at a time. Because of this we want to use the uWSGI Server to serve our application instead. In...
Now we want to install nginx to serve our application. sudo apt-get install nginx # on debian/ubuntu Then we create a configuration for our website cd /etc/nginx/site-available # go to the configuration for available sites # create a file flaskconfig with your favourite editor flaskconfig...
Flask has that feature which lets you stream data from a view by using generators. Let's change the app.py file add from flask import Response add from datetime import datetime add from time import sleep create a new view: @app.route("/time/") def time(): def streamer(): ...
The example in Visitor Pattern provides a compelling use-case for CRTP: struct IShape { virtual ~IShape() = default; virtual void accept(IShapeVisitor&) const = 0; }; struct Circle : IShape { // ... // Each shape has to implement this method the same way ...
A common mistake for Java beginners is to use the == operator to test if two strings are equal. For example: public class Hello { public static void main(String[] args) { if (args.length > 0) { if (args[0] == "hello") { System.out.println(&q...
System.IO.Compression.ZipFile.CreateFromDirectory("myfolder", "archive.zip") Create archive.zip file containing files which are in myfolder. In example paths are relative to program working directory. You can specify absolute paths.

Page 630 of 1336