Tutorial by Examples: c

VoiceOver can navigate many apps on iOS because most UIKit classes implement UIAccessibilityProtocol. Features that don’t represent onscreen elements using UIView, including apps that leverage Core Graphics or Metal to perform drawing, must describe these elements for accessibility. As of iOS 8.0, t...
You can use a template in a function based view as follows: from django.shortcuts import render def view(request): return render(request, "template.html") If you want to use template variables, you can do so as follows: from django.shortcuts import render def view(request):...
List Comprehensions can use nested for loops. You can code any number of nested for loops within a list comprehension, and each for loop may have an optional associated if test. When doing so, the order of the for constructs is the same order as when writing a series of nested for statements. The ge...
Swap out AccountSid, AuthToken, ToPhoneNumber and FromPhoneNumber for your credentials/intended recipients. You need to ensure that if the ToPhoneNumber and FromPhoneNumber have + in them, they are urlencoded (ie: as %2B) notification sms { post = https://{AccountSid}:{Authtoken}@api.twilio.co...
Closures are often used for asynchronous tasks, for example when fetching data from a website. 3.0 func getData(urlString: String, callback: (result: NSData?) -> Void) { // Turn the URL string into an NSURLRequest. guard let url = NSURL(string: urlString) else { return } let re...
It is possible to force the type parameters of a generic class to implement a protocol, for example, Equatable class MyGenericClass<Type: Equatable>{ var value: Type init(value: Type){ self.value = value } func getValue() -> Type{ return self....
Scollector has built in support for using cAdvisor to generate container.* metrics in Bosun for each Docker container on a host. To get started you will need to start a new container on each docker host: docker run --name cadvisor --restart=always -d -p 8080:8080 google/cadvisor And then from an...
Example init script for scollector: #!/bin/bash # # scollector Startup script for scollector. # # chkconfig: 2345 90 60 # description: scollector is a replacement for OpenTSDB's TCollector \ # and can be used to send metrics to a Bosun server # Source function library. . /etc/init....
Here is an init.d script for Bosun that includes setting Environmental Variables that can be used to hide secrets from the raw config. It uses http://software.clapper.org/daemonize/ to run the program as a daemon. #!/bin/sh # # /etc/rc.d/init.d/bosun # bosun # # chkconfig: - 98 02 # descripti...
#Create Scollector unit file at /etc/systemd/system/scollector.service [Unit] Description=Scollector Service After=network.target [Service] Type=simple User=root ExecStart=/opt/scollector/scollector -h mybosunserver.example.com Restart=on-abort [Install] WantedBy=multi-user.target #...
Chef Scollector Cookbook: https://github.com/alexmbird/chef-scollector Chef Bosun Cookbook: https://github.com/ptqa/chef-bosun Puppet scollector module: https://github.com/axibase/axibase-puppet-modules Bosun Ansible/Vagrant example: https://github.com/gnosek/bosun-deploy
docker ps --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}'
docker ps --filter name=myapp_1
git bisect allows you to find which commit introduced a bug using a binary search. Start by bisecting a session by providing two commit references: a good commit before the bug, and a bad commit after the bug. Generally, the bad commit is HEAD. # start the git bisect session $ git bisect start ...
To explicitly declare variables in VBA, use the Dim statement, followed by the variable name and type. If a variable is used without being declared, or if no type is specified, it will be assigned the type Variant. Use the Option Explicit statement on first line of a module to force all variables t...
public class CustomFormat : IFormatProvider, ICustomFormatter { public string Format(string format, object arg, IFormatProvider formatProvider) { if (!this.Equals(formatProvider)) { return null; } if (format == "Reverse") ...
There is a collection in .Net used to manage values in a Stack that uses the LIFO (last-in first-out) concept. The basics of stacks is the method Push(T item) which is used to add elements in the stack and Pop() which is used to get the last element added and remove it from the stack. The generic ve...
div { font-size: 7px; border: 3px dotted pink; background-color: yellow; color: purple; } body.mystyle > div.myotherstyle { font-size: 11px; background-color: green; } #elmnt1 { font-size: 24px; border-color: red; } .mystyle .myotherstyle { ...
7 Object spreading is just syntactic sugar for Object.assign({}, obj1, ..., objn); It is done with the ... operator: let obj = { a: 1 }; let obj2 = { ...obj, b: 2, c: 3 }; console.log(obj2); // { a: 1, b: 2, c: 3 }; As Object.assign it does shallow merging, not deep merging. let obj3 = ...
In order to create a new Android HTTP Client HttpURLConnection, call openConnection() on a URL instance. Since openConnection() returns a URLConnection, you need to explicitly cast the returned value. URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnect...

Page 64 of 826