Tutorial by Examples

In build.sbt, make sure you include (here for Mysql and PostGreSQL): "mysql" % "mysql-connector-java" % "5.1.20", "org.postgresql" % "postgresql" % "9.3-1100-jdbc4", "com.typesafe.slick" %% "slick" % "3.1.1&...
The whole point of using slick is to write as little SQL code as possible. After you have written your table definition, you will want to create the table in your database. If you have val table = TableQuery[MyModel] You can get the table definition (SQL code - DDL) running the following command: ...
First, make your class comply with the UISearchResultsUpdating protocol. class MyTableViewController: UITableViewController, UISearchResultsUpdating {} Add the search controller property: class MyTableViewController: UTableViewController, UISearchResultsUpdating { let searchController = UI...
import { Component } from '@angular/core'; import { Router , ROUTER_DIRECTIVES} from '@angular/router'; import { NgForm } from '@angular/forms'; @Component({ selector: 'login', template: ` <h2>Login</h2> <form #f="ngForm" (ngSubmit)="login(f.value,f....
First, you have to request authorization of location services let locationManager = CLLocationManager() locationManager.delegate = self locationManager.requestWhenInUseAuthorization() // OR locationManager.requestAlwaysAuthorization() Then you can get all iBeacons' information inside didRange...
Sometimes you may want to perform some additional actions to Auto Layout calculations done by UIKit itself. Example: when you have a UIView that has a maskLayer, you may need to update maskLayer as soon as Auto Layout changes UIView's frame // CustomView.m - (void)layoutSubviews { [super la...
Git shortlog is used to summarize the git log outputs and group the commits by author. By default, all commit messages are shown but argument --summary or -s skips the messages and gives a list of authors with their total number of commits. --numbered or -n changes the ordering from alphabetical (...
git log --pretty=format:"%ai" | awk '{print " : "$1}' | sort -r | uniq -c
git log --pretty=oneline |wc -l
for k in `git branch -a | sed s/^..//`; do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k --`\\t"$k";done | sort
git ls-tree -r HEAD | sed -Ee 's/^.{53}//' | \ while read filename; do file "$filename"; done | \ grep -E ': .*text' | sed -E -e 's/: .*//' | \ while read filename; do git blame --line-porcelain "$filename"; done | \ sed -n 's/^author //p' | \ sort | uniq -c | sort -rn
class Example { void method(boolean error) { if (error) { Log.error("Error occurred!"); System.out.println("Error!"); } else { // Use braces since the other block uses braces. System.out.println("No error"); ...
To validate arguments to methods called on a mock, use the ArgumentCaptor class. This will allow you to extract the arguments into your test method and perform assertions on them. This example tests a method which updates the name of a user with a given ID. The method loads the user, updates the na...
NSURL *url = [NSURL URLWithString:@"http://www.example.com/images/apple-tree.jpg"]; NSString *fileName = [url lastPathComponent]; // fileName = "apple-tree.jpg"
Given a DataFrame: s1 = pd.Series([1,2,3]) s2 = pd.Series(['a','b','c']) df = pd.DataFrame([list(s1), list(s2)], columns = ["C1", "C2", "C3"]) print df Output: C1 C2 C3 0 1 2 3 1 a b c Lets add a new row, [10,11,12]: df = pd.DataFrame(np.array(...
Using the same example as Evaluating a NodeList in an XML document, here is how you would make multiple XPath calls efficiently: Given the following XML document: <documentation> <tags> <tag name="Java"> <topic name="Regular expression...
In this case, you want to have the expression compiled before the evaluations, so that each call to evaluate does not compile the same expression. The simple syntax would be: XPath xPath = XPathFactory.newInstance().newXPath(); //Make new XPath XPathExpression exp = xPath.compile("/documentat...
Shortcode is a small piece of code that can be added into the WordPress editor and will output something different once the page is published or previewed. Frequently, shortcodes are added to the theme functions.php file, but that's not a good practice as shortcodes are expected to keep working aft...
When programming in Prolog, we must pick two kinds of names: names of predicates names of variables. A good predicate name makes clear what each argument means. By convention, underscores are used in names to separate the description of different arguments. This is because underscores_keep_ev...
There are only a few language constructs in Prolog, and several ways for indenting them are common. No matter which style is chosen, one principle that should always be adhered to is to never place (;)/2 at the end of a line. This is because ; and , look very similar, and , frequently occurs at the...

Page 626 of 1336