Tutorial by Examples

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 Bosun unit file at /etc/systemd/system/bosun.service [Unit] Description=Bosun Service After=network.target After=rsyslog.service [Service] Type=simple User=root ExecStart=/opt/bosun/bosun -c /opt/bosun/config/prod.conf Restart=on-abort [Install] WantedBy=multi-user.target #...
#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 #...
TSDBRelay can be used to forward metrics to an OpenTSDB instance, send to Bosun for indexing, and relay to another opentsdb compatible instance for backup/DR/HA. It also has options to denormalize metrics with high tag cardinality or create redis/ledis backed external counters. #Create tsdbrelay un...
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
This example assumes Ruby is installed. Place the following in a file named hello.rb: puts 'Hello World' From the command line, type the following command to execute the Ruby code from the source file: $ ruby hello.rb This should output: Hello World The output will be immediately di...
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...
Serialization with Gson is easy and will output correct JSON. public class Employe { private String firstName; private String lastName; private int age; private BigDecimal salary; private List<String> skills; //getters and setters } (Serialization) ...
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...
URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); try { BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); // read the input stream // in this case, I simply read t...
URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); try { BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); // use a string builder to bufferize the response body //...
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->...
A nice example of a parameterized type is the Option type. It is essentially just the following definition (with several more methods defined on the type): sealed abstract class Option[+A] { def isEmpty: Boolean def get: A final def fold[B](ifEmpty: => B)(f: A => B): B = if (i...

Page 101 of 1336