Tutorial by Examples: c

SQL injection is a kind of attack that allows a malicious user to modify the SQL query, adding unwanted commands to it. For example, the following code is vulnerable: // Do not use this vulnerable code! $sql = 'SELECT name, email, user_level FROM users WHERE userID = ' . $_GET['user']; $conn->...
// Create a block with an asynchronous action var block = new ActionBlock<string>(async hostName => { IPAddress[] ipAddresses = await Dns.GetHostAddressesAsync(hostName); Console.WriteLine(ipAddresses[0]); }); block.Post("google.com"); // Post items to the block's ...
var httpClient = new HttpClient(); // Create a block the accepts a uri and returns its contents as a string var downloaderBlock = new TransformBlock<string, string>( async uri => await httpClient.GetStringAsync(uri)); // Create a block that accepts the content and prints it to t...
If you have several objects of monadic types, we can achieve combinations of the values using a 'for comprehension': for { x <- Option(1) y <- Option("b") z <- List(3, 4) } { // Now we can use the x, y, z variables println(x, y, z) x // the last expre...
There are two Dockerfile directives to specify what command to run by default in built images. If you only specify CMD then docker will run that command using the default ENTRYPOINT, which is /bin/sh -c. You can override either or both the entrypoint and/or the command when you start up the built im...
Requirements: 64-bit version of Windows 7 or higher on a machine which supports Hardware Virtualization Technology, and it is enabled. While the docker binary can run natively on Windows, to build and host containers you need to run a Linux virtual machine on the box. 1.12.0 Since version 1.12 y...
Docker is supported on the following 64-bit versions of Ubuntu Linux: Ubuntu Xenial 16.04 (LTS) Ubuntu Wily 15.10 Ubuntu Trusty 14.04 (LTS) Ubuntu Precise 12.04 (LTS) A couple of notes: The following instructions involve installation using Docker packages only, and this ensures obtaining...
HandleFunc registers the handler function for the given pattern in the server mux (router). You can pass define an anonymous function, as we have seen in the basic Hello World example: http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Hello, w...
The simplest way to create an error is by using the errors package. errors.New("this is an error") If you want to add additional information to an error, the fmt package also provides a useful error creation method: var f float64 fmt.Errorf("error with some additional informatio...
In Go, an error is represented by any value that can describe itself as string. Any type that implement the built-in error interface is an error. // The error interface is represented by a single // Error() method, that returns a string representation of the error type error interface { Erro...
The getAll() method retrieves all values from the preferences. We can use it, for instance, to log the current content of the SharedPreferences: private static final String PREFS_FILE = "MyPrefs"; public static void logSharedPreferences(final Context context) { SharedPreferences s...
/// <summary> /// This interface can do Foo /// </summary> public interface ICanDoFoo { // ... } /// <summary> /// This Bar class implements ICanDoFoo interface /// </summary> public class Bar : ICanDoFoo { // ... } Result Interface summary Clas...
Rename the branch you have checked out: git branch -m new_branch_name Rename another branch: git branch -m branch_you_want_to_rename new_branch_name
A Table View is a list of rows that can be selected. Each row is populated from a data source. This example creates a simple table view in which each row is a single line of text. Add a UITableView to your Storyboard Although there are a number of ways to create a UITableView, one of the easiest...
Boilerplate code example override func viewDidLoad() { super.viewDidLoad() let myView = UIView() myView.backgroundColor = UIColor.blueColor() myView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(myView) // Add constraints code here // ... ...
Select your button (or whatever view you want to center) on the storyboard. Then click the align button on the bottom right. Select Horizontally in Container and Vertically in Container. Click "Add 2 Constraints". If it wasn't perfectly centered already, you may need to do one more thin...
The CREATE TABLE statement is used to create a table in a MySQL database. CREATE TABLE Person ( `PersonID` INTEGER NOT NULL PRIMARY KEY, `LastName` VARCHAR(80), `FirstName` VARCHAR(80), `Address` TEXT, `City` VARCHAR(100) ) Engine=InnoDB; Ev...
CREATE TABLE Person ( PersonID INT UNSIGNED NOT NULL, LastName VARCHAR(66) NOT NULL, FirstName VARCHAR(66), Address VARCHAR(255), City VARCHAR(66), PRIMARY KEY (PersonID) ); A primary key is a NOT NULL single or a multi-column identifier whic...
CREATE TABLE Account ( AccountID INT UNSIGNED NOT NULL, AccountNo INT UNSIGNED NOT NULL, PersonID INT UNSIGNED, PRIMARY KEY (AccountID), FOREIGN KEY (PersonID) REFERENCES Person (PersonID) ) ENGINE=InnoDB; Foreign key: A Foreign Key (FK) is either a single col...
Instantiate a XMLWriter object: $xml = new XMLWriter(); Next open the file to which you want to write. For example, to write to /var/www/example.com/xml/output.xml, use: $xml->openUri('file:///var/www/example.com/xml/output.xml'); To start the document (create the XML open tag): $xml-&gt...

Page 65 of 826