Tutorial by Examples

#Post to pagerduty.com notification pagerduty { post = https://events.pagerduty.com/generic/2010-04-15/create_event.json contentType = application/json runOnActions = false body = `{ "service_key": "myservicekey", "incident_key": {{.|jso...
The effect of using the * operator on an argument when calling a function is that of unpacking the list or a tuple argument def print_args(arg1, arg2): print(str(arg1) + str(arg2)) a = [1,2] b = tuple([3,4]) print_args(*a) # 12 print_args(*b) # 34 Note that the length of the starr...
Seaborn is a wrapper around Matplotlib that makes creating common statistical plots easy. The list of supported plots includes univariate and bivariate distribution plots, regression plots, and a number of methods for plotting categorical variables. The full list of plots Seaborn provides is in thei...
CSS ul { list-style: none; counter-reset: list-item-number; /* self nesting counter as name is same for all levels */ } li { counter-increment: list-item-number; } li:before { content: counters(list-item-number, ".") " "; /* usage of counters() function means val...
In many other languages, if you run the following (Java example) if("asgdsrf" == 0) { //do stuff } ... you'll get an error. You can't just go comparing strings to integers like that. In Python, this is a perfectly legal statement - it'll just resolve to False. A common gotcha ...
In the example of a message bubble illustrated below: the corners of the image should remain unchanged which is specified by UIEdgeInsets, but the borders and center of the image should expand to cover the new size. let insets = UIEdgeInsetsMake(12.0, 20.0, 22.0, 12.0) let image = UIImage(na...
<div tabindex="0">Some button</div> Note: Try to use a native HTML button or an a tag where appropriate.
<button tabindex="-1">This button will not be reachable by tab</button> The element will be removed from the tabbing order but will still be focusable.
<div tabindex="2">Second</div> <div tabindex="1">First</div> Positive values will insert the element at the tabbing order position of its respective value. Elements without preference (i.e. tabindex="0" or native elements such as button and a...
Build constraints are commonly used to separate normal unit tests from integration tests that require external resources, like a database or network access. To do this, add a custom build constraint to the top of the test file: // +build integration package main import ( "testing&...
We can optimize a simple xor function for only architectures that support unaligned reads/writes by creating two files that define the function and prefixing them with a build constraint (for an actual example of the xor code which is out of scope here, see crypto/cipher/xor.go in the standard libra...
This is a simple but robust core-data set-up for iOS 10+. There are exactly two way to access core-data: viewContext. The viewContext can only be used from the main thread, and only for reading. strong enqueueCoreDataBlock. All writing should be done using enqueueCoreDataBlock. There is no ne...
// Core Data stack lazy var applicationDocumentsDirectory: NSURL = { let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) return urls[urls.count-1] }() lazy var managedObjectModel: NSManagedObjectModel = { let modelURL = NSB...
lazy var persistentContainer: NSPersistentContainer = { let container = NSPersistentContainer(name: "ProjectName") container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error { fatalError("Unreso...
Just some methods of an object can be mocked using spy() of mockito. For example, imagine that method class requires some web service to work. public class UserManager { List<User> users; public UserManager() { user = new LinkedLisk<User>(); } ...
Get the Source Package from http://typo3.org/download/ and upload this package to your web server. Put it one level above the document root. For this manual, we will use the .tar.gz file. Use the shell to execute the according commands: /var/www/site/htdocs/$ cd .. /var/www/site/$ wget get.typo3....
go() method The go() method loads a specific URL from the history list. The parameter can either be a number which goes to the URL within the specific position (-1 goes back one page, 1 goes forward one page), or a string. The string must be a partial or full URL, and the function will go to the f...
The spacing should be even and uniform throughout. Improper indentation can cause an IndentationError or cause the program to do something unexpected. The following example raises an IndentationError: a = 7 if a > 5: print "foo" else: print "bar" print "done&qu...
For Python, Guido van Rossum based the grouping of statements on indentation. The reasons for this are explained in the first section of the "Design and History Python FAQ". Colons, :, are used to declare an indented code block, such as the following example: class ExampleClass: #Eve...
The following example shows a basic main GUI window with a label widget, a toolbar, and a status bar using PyQt4. import sys from PyQt4 import QtGui class App(QtGui.QApplication): def __init__(self, sys_argv): super(App, self).__init__(sys_argv) self.build_ui() ...

Page 325 of 1336