text:
#Week 13 Survey Results

Responses for the survey follow, with the number of similar
responses shown to the right of a response.

There were 20 responders.

I have interpreted and aggregated some of the results, in hopefully an appropriate fashion.
Thank you to those who responded :)

##WEEK 13 – Authentication

###What do *you* think the most important takeaways are from this lesson?

- **Authenticate, and enforce access based on user roles**	9
- **CodeIgniter Authentication**	6
- bot detection and coding against them (captcha)	3
- importance of hashing and securely storing passwords	3
- Access Control Pseudocode	2
- **CodeIgniter Authorization**	2
- Consider implementing facebook or google integration	2
- Access(or/ing), and Audit(or/ing)
- Categories of users
- codeigniter doesn't come with provision for authentication
- How codeigniter does it
- Make the process easy, verify user through email, defeat bots using tools like captcha
- Security involves authentication, authorization, access, and auditing.
- Sessions
- The structure

###What are topics from the lesson that *you* feel need more or better explanation?

- Auditing	2
_A verifiable, datetime-sequenced record of activity/events; searchable & reportable.
See system/core/Log and system/core/Common_
- How does a hidden comment field detect bots?	2
_It is hidden through CSS, which bots do not normally process.
They will fill it in, so you can test for content in such a field to recognize a bot.
The User Agent library provides an is-robot() method, but that can be defeated by a
malicious bot._
- Accessing
_Refers to the mechanism you choose to authenticate users & make sure they
are authorized to access something (a URI?).
It is commonly done through user roles._
- advantages/disadvantages to each authentication choice
_Addressed during lecture_
- Authorization choices? What is rule?
_ACL has rules, per asset or user, on allowable access rights.
Eg. /admin can be accessed by user in "admin" role, with IP address within intranet.
Rules can be asset-based (eg an Asset Control List: who is allowed to do what to a folder), or
user-based (eg a User Capability List: what is this user allowed to do with different assets)._
- CodeIgniter Authentication
_Addressed during lecture_
- CodeIgniter Authorization
_Addressed during lecture_
- Demonstration and code examples of oAuth as it is a popular method of applying authorization
_Out of scope_
- i feel more will be taught in lab.
_No lab on this. Tutorial provided instead, for those interested._
- if users login with social logins, can we see their email for that service?
_That depends on whether the user has chosen to share that with an app._
- Practical social media code with increasing use of social media login
_Out of scope_
- Show how other authorization solutions work
_Out of scope_
- The practice
_Yes? addressed during lecture?_
- The two security models - what is the federations of trust?
_A federation of trust is an agreement between apps to grant access.
Eg login to BCIT campus network (A), and be allowed to access employee benefits site (B).
(B) can ask (A) for token proving that the user is an employee._
- Third party libraries
_Yes? slide 23??_

###Are there other, related, questions that you would like addressed in class?

- are sessions safe?
_Yes. The only thing exposed is the session ID, stored as a cookie client-side.
CSRF can be used to foil spoofing._
- Are there any new methods of authentication that are currently being developed
_Biometrics, RSA keys, AI bad behavior detection..._
- Bad patterns to avoid?
_Generally, don't roll your own unless super simple app; never store passwords
in plaintext; never send credentials in the open_
- Can you get user roles from OAuth authentication?
_Sort of: resource owner, resource server, client app, authorization server.
OAuth has "scopes", which can be treated as conventional "roles"._
- More detail about oAuth
_Out of scope_
- showing the psuedocode was helpful
- What kind of technologies/techniques are used to detect bots?
_Well-behaved: user agent string. Others: (re)captcha, suspicious request patterns
or frequency, ICE, blacklists..._

###Do you have comments or suggestions about the flipped learning process?

- I am not a robot.
- Section 2 of the lesson seems to come out of nowhere.  I need more explanation on those diagrams.
_Addressed during lecture ... I am surprised this question didn't come up sooner :-/_


text:
[Full Changelog][changelog]

This is a general maintenance release.

### 🔨 Changes

- :arrow_up: Updates pycurl to v<IP_ADDRESS> (#66)
- :arrow_up: Updates six to v1.14.0 (#67)
- :arrow_up: Updates pycurl to v<IP_ADDRESS> (#70)
- :arrow_up: Updates jinja2 to v2.11.1 (#71)
- :arrow_up: Upgrades nginx to 1.16.1-r6
- :ambulance: Fix Patreon link
- :arrow_up: Upgrades motion to 4.3.0-r0
- :books: Update add-on documentation to use new YAML configuration format
- :hammer: Re-branding
- :hammer: Update add-on config with new password & list features
- :hammer: Updates for upstream Supervisor changes
- :arrow_up: Upgrades add-on base image to v7.0.2
- :hammer: Update community forum links
- :fire: Removed redundant copy statement. (#73)
- :sparkles: Add action buttons (#75)
- :hammer: Use bashio for action buttons
- :books: Update readme
- :shirt: Fix lint warnings

[changelog]: https://github.com/hassio-addons/addon-motioneye/compare/v0.6.0...v0.7.0

Questions? Join our Discord server! https://discord.me/hassioaddons
Enjoying my add-ons? Consider supporting my work:
https://github.com/sponsors/frenck or https://patreon.com/frenck

license: MIT

repository: zewelor/repository

branch_name: refs/heads/master

extension: md

gha_license_id: MIT

license_type: permissive

repo_name: zewelor/repository


text:
---
layout: post
title: "ThreadTone"
description: "A halftone representation of an image made of thread."
date: 2016-12-25
tags: [python, automation, cnc, image processing, art]
comments: true
HN: 13254029
share: true
---

Not too long ago I came across a piece of art made by [Petros Vrellis](http://artof01.com/vrellis/index.html). A piece of art that makes the engineer in me scream: automation. As can be seen below Petros uses a circular loom and a lot of patience to develop portraits from thread. Below I'll quickly go through the steps of automating the process but of course all the credits go to the artist behind this amazing idea! The final result is a halftone representation of an image using nothing but thread.

![Petros Vrellis working on: A new way to knit](/assets/threadTone/PetrosVrellis.png "A new way to knit")

The main idea is comprised of three steps. First a little image pre-processing is done to various input images for threading. Second is some processing done in python to determine where one should place the successive threads as to obtain the best image representation. Third, I can put my laserless lasercutter to work to do the heavy lifting.

## Image pre-processing

To allow image processing on a pixel level we use [openCV](http://opencv.org/). Let's get started and do some initial processing of the image. The snippet below shows how one can load, crop and resize an image.

```python
import cv2
import numpy as np

# Invert grayscale image
def invertImage(image):
    return (255-image)

# Apply circular mask to image
def maskImage(image, radius):
    y, x = np.ogrid[-radius:radius + 1, -radius:radius + 1]
    mask = x**2 + y**2 > radius**2
    image[mask] = 0

    return image

# Load image
image = cv2.imread(imgPath)

# Crop image
height, width = image.shape[0:2]
minEdge= min(height, width)
topEdge = int((height - minEdge)/2)
leftEdge = int((width - minEdge)/2)
imgCropped = image[topEdge:topEdge+minEdge, leftEdge:leftEdge+minEdge]

# Convert to grayscale
imgGray = cv2.cvtColor(imgCropped, cv2.COLOR_BGR2GRAY)

# Resize image
imgSized = cv2.resize(imgGray, (2*imgRadius + 1, 2*imgRadius + 1))

# Invert image
imgInverted = invertImage(imgSized)

# Mask image
imgMasked = maskImage(imgInverted, imgRadius)
```

Once the image is of the correct size it is converted to a gray-scale image and inverted. In this form the image can be represented as an array where the originally darkest places have the highest value. Finally the image is masked with a circular mask (all values outside the circle are set to zero).

## Threading algorithm

Deciding where one needs to pass the thread as to obtain a representation of the original image is the main focus of the algorithm. For this the assumption is made that a circular loom is used with an evenly spaced amount of pins.

<video width="350" height="350" autoplay loop muted>
  <source src="/assets/threadTone/algo.mp4" type="video/mp4">
</video>

As seen in the clip above the algorithm starts at a random pin. It checks all possible options for the one that would best fit the image. It now draws the optimal line, accounts for the "darkness" added by this line and starts again. The functions below generate the pin coordinates of the loom and a mask representing a certain line.

```python
# Compute coordinates of loom pins
def pinCoords(radius, nPins=200, offset=0, x0=None, y0=None):
    alpha = np.linspace(0 + offset, 2*np.pi + offset, nPins + 1)

    if (x0 == None) or (y0 == None):
        x0 = radius + 1
        y0 = radius + 1

    coords = []
    for angle in alpha[0:-1]:
        x = int(x0 + radius*np.cos(angle))
        y = int(y0 + radius*np.sin(angle))

        coords.append((x, y))
    return coords

# Compute a line mask
def linePixels(pin0, pin1):
    length = int(np.hypot(pin1[0] - pin0[0], pin1[1] - pin0[1]))

    x = np.linspace(pin0[0], pin1[0], length)
    y = np.linspace(pin0[1], pin1[1], length)

    return (x.astype(np.int)-1, y.astype(np.int)-1)
```

Using the functions above the algorithm iteratively adds lines to the image until either the maximum number of lines is reached or the stopping criteria is reached. The fitness function is taken to be the specific line integral over the image. Lines that cover a lot of originally dark areas will therefore achieve a high fitness.

```python
# Define pin coordinates
coords = pinCoords(imgRadius, nPins)
height, width = imgMasked.shape[0:2]

# Initialize variables
i = 0
lines = []
previousPins = []
oldPin = initPin
lineMask = np.zeros((height, width))

# Loop over lines until stopping criteria is reached
for line in range(nLines):
    i += 1
    bestLine = 0
    oldCoord = coords[oldPin]

    # Loop over possible lines
    for index in range(1, nPins):
        pin = (oldPin + index) % nPins

        coord = coords[pin]
        xLine, yLine = linePixels(oldCoord, coord)

        # Fitness function
        lineSum = np.sum(imgMasked[yLine, xLine])

        if (lineSum > bestLine) and not(pin in previousPins):
            bestLine = lineSum
            bestPin = pin

    # Update previous pins
    if len(previousPins) >= minLoop:
        previousPins.pop(0)
    previousPins.append(bestPin)

    # Subtract new line from image
    lineMask = lineMask * 0
    cv2.line(lineMask, oldCoord, coords[bestPin], lineWeight, lineWidth)
    imgMasked = np.subtract(imgMasked, lineMask)

    # Save line to results
    lines.append((oldPin, bestPin))

    # Break if no lines possible
    if bestPin == oldPin:
        break

    # Prepare for next loop
    oldPin = bestPin
```

Once the algorithm no longer finds any possible lines the loop is broken and the result can be further processed. Below one can find two examples of the algorithms result. Move over the image in question to see the original image.

## NC threading

Always fascinated by the ease at which a lasercutter can produce quality parts I set out to build my own. It turned out I could never get myself to make the last investment and actually buy the lasertube/optics.  Coming across Petros's project it finally got a purpose.

<video style="border-radius: 5px;" width="720" height="400" autoplay loop muted>
  <source src="/assets/threadTone/cnc.mp4" type="video/mp4">
</video>

Parsing the resulting line coordinates to G-code allows for some NC threading. A pen was used to develop a small guide for the thread. Below one can find the initial result of about 900 lines completed. At this point the thread broke and I called it a day. I will update the post with some images of the full result once I have some time to retry.

The full code is posted to [GitHub](https://github.com/theveloped/ThreadTone) and with some explanation on the tuning parameters. Any remarks or advise is most welcome and feel free to contact me with any questions.


text:
Ti={Project} Whitepaper

0.sec=Status: Draft

1.Ti=Abstract

1.sec=This paper describes the high-level motivation, vision, scope and industry use cases, architecture, functional and non-functional requirements that the {Project} is intended to realize.

2.Ti=Motivation

3.Ti=Vision

4.Ti=Scope

4.sec=(include scope graphic here)

5.=[GHx/hyperledger/hyperledger/Whitepaper/Sec/UseCases_0.md]

6.Ti=Architecture

7.Ti=Functional Requirements

8.Ti=Non-functional Requirements

9.Ti=Conclusion

=[Z/ol/9]

Project=Hyperledger Project

Origin=(with a few touchups) https://github.com/christo4ferris/hyperledger/blob/4b30b5d3124bbb0b83f5eff1545c508c6045bef5/whitepaper.md

repository: HumanDynamics/BlockCreditUnion

repo_name: HumanDynamics/BlockCreditUnion


text:
# Delani-studio
### by  **Raissa Muyenzi**
## DESCRIPTION
### Delani-studio
Delani studio is studio that provides software related services.It has a team that develop web and mobile application
## SETUP INSTALLATION  REQUIRED
   *UBUNTU
   *VISIO CODE
   *GOOGLE CHROME

## TECHNOLOGY USED
   *HTML
   *CSS
   *JAVA SCRIPT
   *JQUERY
## BDD
  **Input**
  In this webpage;there is a form to fill to visitors who want to send us a message about what they want or any advice or compliment
  They have to enter their names(EXAMPLE :**RAISSA**)
  Email<EMAIL_ADDRESS>
  and then they type the message then you click on send button.
  **Output**
  The user will be alerted that their message has been sent
  If they user didn't fill the form he will be alerted to fill it.
## PROJECT LINK
     https://muyenzi.github.io/project3/
## SUPPORT AND CONTACT
 contact me<EMAIL_ADDRESS>
 ## LICENSE
 Licensed by MIT copyright @ 2019 **Raissa Muyenzi**


text:
Gmapping has many parameters to change performances for different environments. You can get an information about whole parameters in [ROS WiKi](http://wiki.ros.org/gmapping) or refer to the Chapter 11 of [ROS Robot Programming](https://community.robotsource.org/t/download-the-ros-robot-programming-book-for-free/51).
This tuning guide provides tips when configuring gmapping parameters. If you want to optimize SLAM performances for your environments, this section might be helpful.

Below parameters are defined in `turtlebot3_slam/config/gmapping_params.yaml` file.

### maxUrange
This parameter is set the maximum usable range of the lidar sensor.

### map_update_interval
This parameter defines time between updating the map.
The smaller the value, the more frequent the map is updated.
However, setting this too small will be require more processing power for the map calculation.
Set this parameter depending on the map environment.

![](/assets/images/platform/turtlebot3/slam/tuning_map_update_interval.png)

### minimumScore

This parameter sets the minimum score value that determines the success or failure of the sensor’s scan data matching test.
This can reduce errors in the expected position of the robot in a large area.
If the parameter is set properly, you will see information similar to one shown below.
```bash
Average Scan Matching Score=278.965
neff= 100
Registering Scans:Done
update frame 6
update ld=2.95935e-05 ad=0.000302522
Laser Pose= -0.0320253 -5.36882e-06 -3.14142
```

If set too high, you might see below warnings.
```bash
Scan Matching Failed, using odometry. Likelihood=0
lp:-0.0306155 5.75314e-06 -3.14151
op:-0.0306156 5.90277e-06 -3.14151
```

### linearUpdate
When the robot translates longer distance than this value, it will run the scan process.

### angularUpdate
When the robot rotates more than this value, it will run the scan process. It is recommended to
set this value less than linearUpdate.

repository: ROBOTIS-GIT/emanual

gha_language: JavaScript

repo_name: ROBOTIS-GIT/emanual


text:
# README

Ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

Rails 5.1.6

1. How to Install:

1.1. Download or Pull project from git.

1.2. `Bundle install`

1.3. `rails db:create`

1.4. `rails s`

2. How to config swagger:

2.1. Go to "\config\initializers"

2.2. Open "swagger_docs.rb"

```ruby
#\config\initializers
class Swagger::Docs::Config
  def self.base_api_controller
    ActionController::Base
  end
end

Swagger::Docs::Config.register_apis({
    "1.0" => {
        :controller_base_path => "",
        # the extension used for the API
        :api_file_path => "public",
        # the URL base path to your API
        :base_path => "http://localhost:3000",  #change this url with your ip address
        # if you want to delete all .json files at each generation
        :clean_directory => false,
        # add custom attributes to api-docs
        :attributes => {
            :info => {
                "title" => "Quickstart app",
                "description" => "This is an API for an quickstart",
                "termsOfServiceUrl" => "https://github.com/jasjeetsingh527/rails-quickstart",
                "contact" =><EMAIL_ADDRESS>                "license" => "Apache 2.0",
                "licenseUrl" => "http://www.apache.org/licenses/LICENSE-2.0.html"
            }
        }
    }
})
```

2.3. Run command rake swagger:docs

2.4. visit http://yourwebsite.com/api
For more information visit: https://github.com/richhollis/swagger-docs


text:
# osx-battery-health-check

This repository contains some scripts that print the battery status with Sensu-compatible format.

## Usage

```
./bin/battery_charge_remaining
# battery.charge.remaining	6261<PHONE_NUMBER>
```

## LICENSE

MIT License

repository: aereal/osx-battery-health-check

repo_name: aereal/osx-battery-health-check


text:
# Overview

This directory holds examples of dashboards that can be created using data collected by various Flex configurations.

You can quickly use these samples by editing “OWNER_EMAIL_ADDRESS” and “ACCOUNT_ID” in the source JSON and then applying the payload to your New Relic account using the [API Explorer](https://rpm.newrelic.com/api/explore/dashboards/create).

More details about the Dashboards API can be found in the [documentation](https://docs.newrelic.com/docs/insights/insights-api/manage-dashboards/insights-dashboard-api) and in an introductory [blog post](https://blog.newrelic.com/product-news/insights-dashboard-api/) on the New Relic website.

## Contributing

Please follow the following naming standard for additions to this directory:

Dashboard Payload: `technology-description-dashboard.json`

Dashboard Screenshot: `technology-description-screenshot.png`

Examples:
```
solarwinds-alert-history-dashboard.json
solarwinds-alert-history-dashboard.png
```

repository: newrelic/nri-flex

gha_language: Go

repo_name: newrelic/nri-flex


text:
# 3 Rhythm and metre

## 3.1 Time values

As well as a pitch name, each note has a rhythmic value, called a time value, note value or duration. Those most commonly found in present-day usage are shown in Example 13.

__Example 13__

![figure images/a224_pm_mu013.jpg](images/a224_pm_mu013.jpg)

Notice that in order to differentiate these symbols for time values:

* all have stems apart from the semibreve

* the note heads of the semibreve and minim are open, whereas those for the shorter values are filled in

* the quaver has a __flag__ (or tail), always drawn on the right-hand side of the stem, the semiquaver has two flags and the demisemiquaver, three.

You will probably have noticed too that the duration of each time value is half that of the one above. Therefore two minims last the same duration as a semibreve; two crotchets last the same duration as a minim; and so on. This also means that *four* crotchets last the same duration as a semibreve, as do *eight* quavers or *sixteen* semiquavers. Example 14 maps out these relationships:

__Example 14__

![figure images/a224_pm_mu014.jpg](images/a224_pm_mu014.jpg)

## 3.2 Triplets

In Section 3.1, Example 14, you saw that as you move down the list of time values from semibreve to semiquaver, each successive time value is half the length of the one above (for example, you saw that a quaver is half the length of a crotchet). However, you can divide a time value not only by two but by any number you want. The most frequent division you will come across, the next in frequency to the default division of two, is where a time value is divided into three equal components – say a crotchet divided into three quavers or a minim divided into three crotchets. This is called a triplet. As you can see and hear in Example 15, the crotchet is divided into three triplet quavers, the minim into three triplet crotchets.

__Example 15__

![figure images/a224_1_pm_mu015.jpg](images/a224_1_pm_mu015.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
At this stage, you needn’t worry about this in any detail. However, notice in Example 15 how triplets are notated with a figure three over or under the relevant notes, the figure often being combined with either a curved line or square bracket.

## 3.3 Time signatures

The rhythm of a piece of western music – whether it is simple or complex – is underpinned by a steady pulse or __beat__, and these beats are grouped together to give the music’s __metre__. The music examples in this section include a click track to help you follow the beats. The most common groupings are in twos, threes and fours and these groupings are created by a pattern of stronger and weaker stresses. Thus, a three-beat pattern would consist of strong-weak-weak beats. In notated music, each group is marked out by a __bar line__ – so from now on we will talk about how many beats there are in each __bar__.

__Time signatures__, which consist of two numbers aligned vertically, are placed at the opening of a piece of music to signify which metre is being used. (The time signature is then omitted for the rest of the piece, unless it is changed to another.) In the time signatures discussed in this section, the lower figure can be understood as the value of each beat expressed in relation to a semibreve (whole note). The number 2 represents a minim (half note), 4 represents a crotchet (quarter note), 8 represents a quaver (eighth note), and so on. The upper figure tells you the number of beats in the bar.

* __In 2/4 there are two crotchets per bar__. The lower number, 4, represents a crotchet because there are 4 crotchets (quarter notes) in a semibreve (whole note), and the upper number tells you that there are 2 beats, i.e. two crotchets, in a bar.

* __In 3/2 there are three minims per bar__. The lower number, 2, represents a minim because there are 2 minims (half notes) in a semibreve, and the upper number tells you that there are 3 beats, i.e minims, in a bar.

* __In 3/8 there are three quavers per bar__. The lower number, 8, represents a quaver because there are 8 quavers (eighth notes) in a semibreve, and the upper number tells you that there are 3 beats, i.e. quavers, in a bar.

Example 16 summarises the meaning of these three time signatures.

__Example 16__

![figure images/a224_pm_mu016.jpg](images/a224_pm_mu016.jpg)

Example 17 shows various straightforward rhythms in different time signatures.

__Example 17__

![figure images/a224_1_pm_mu017.jpg](images/a224_1_pm_mu017.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
Notice in Example 17 that 4/4 can also be written as C (__Common time__), and 2/2 as a C with a vertical stroke through it (__alla breve__). Notice too that each bar includes the correct number of time values to make up the required number of beats shown by the upper number of the time signature, and that each bar’s group of beats is marked off with a __bar line__ for ease of reading. Finally, the concluding bar line is written as a __double bar__.

Consider Example 17 carefully, spending as much time as you need in order to become proficient at adding together the number of beats in each bar, as signified by the top number of the time signature. (Pay particular attention when there are shorter values present such as quavers and semiquavers.) Additionally, make sure that you have identified the beat correctly as shown by the bottom number in the time signature – is it a minim (2), a crotchet (4) or a quaver (8)?

## 3.4 Review 2

The following activities begin with Group 1 – a series of activities that asks you to identify note values. In Group 2, one or more time values from a bar has been omitted, and you will therefore have to work out what they are. You need to be absolutely sure as to the length of each time value and how each fits together with the other time values in each bar.

---

Group 1: time values

### Activity 1

#### Question

Which of the following statements is correct?

A minim has an open note head and a stem.

A crotchet lasts twice as long as a quaver.

Four semiquavers equal two crotchets in length.

A semibreve lasts as long as four crotchets.

A quaver has a flag drawn on the left-hand side of the stem.

Six triplet quavers equal two crotchets in length.

A demisemiquaver has three flags.

---

Group 2: identifying omitted time value(s)

### Activity 1

#### Question

Which single time value is required at the place marked with the asterisk?

![figure images/a224_pm_un_mu022.jpg](images/a224_pm_un_mu022.jpg)

quaver

crotchet

minim

#### Answer

The time signature, 2/4, has two crotchet beats per bar. Since the first bar contains only one crotchet, another is needed.

### Activity 2

#### Question

Which single time value is required at the place marked with the asterisk?

![figure images/a224_pm_un_mu023.jpg](images/a224_pm_un_mu023.jpg)

crotchet

minim

semibreve

#### Answer

The time signature, 4/4, has four crotchet beats per bar. Since the second bar contains no rhythmic value, a semibreve (which is equal to four crotchets) is needed.

### Activity 3

#### Question

Which single time value is required at the place marked with the asterisk?

![figure images/a224_pm_un_mu024.jpg](images/a224_pm_un_mu024.jpg)

quaver

crochet

minim

#### Answer

The time signature, 3/4, has three crotchet beats per bar. Since the third bar contains only one crotchet, a minim (which is equal to two crotchets) is needed.

### Activity 4

#### Question

Which single time value is required at each of the places marked with asterisks?

![figure images/a224_pm_un_mu025.jpg](images/a224_pm_un_mu025.jpg)

quaver/crotchet

quaver/minim

crotchet/minim

#### Answer

The time signature, 2/4, has two crotchet beats per bar. Since the second bar contains only a crotchet and a quaver, another quaver is needed to make up the two crotchet beats. The third bar lacks a value and therefore a minim (which is equal to two crotchets) is required.

### Activity 5

#### Question

Which single time value is required at each of the places marked with asterisks?

![figure images/a224_pm_un_mu026.jpg](images/a224_pm_un_mu026.jpg)

crotchet/minim

crotchet/semibreve

minim/semibreve

#### Answer

The time signature, 4/4, has four crotchet beats per bar. Since the first bar contains only two crotchets, a minim (which is equal to two crotchets) is needed. The third bar lacks a value and therefore a semibreve (which is equal to four crotchets) is required.

### Activity 6

#### Question

Which single time value is required at each of the places marked with asterisks?

![figure images/a224_pm_un_mu027.jpg](images/a224_pm_un_mu027.jpg)

minim/quaver

crotchet/quaver

minim/crotchet

#### Answer

The time signature, 3/4, has three crotchet beats per bar. Since the first bar contains only a crotchet, a minim (which is equal to two crotchets) is required. The second bar contains only a minim (which equals two crotchets) and a quaver, and therefore another quaver is needed to make up the three crotchet beats.

### Activity 7

#### Question

Which single time value is required at the place marked with an asterisk?

![figure images/a224_pm_un_mu028.jpg](images/a224_pm_un_mu028.jpg)

semiquaver

quaver

crotchet

#### Answer

The time signature, 3/8, has three quaver beats per bar. Since the first bar includes only two quavers and a semiquaver, another semiquaver is needed to make up the three quaver beats.

### Activity 8

#### Question

Which single time value is required at the place marked with an asterisk?

![figure images/a224_pm_un_mu029.jpg](images/a224_pm_un_mu029.jpg)

crotchet

minim

semibreve

#### Answer

The time signature, 3/2, has three minim beats per bar. Since the second bar includes only one minim, a semibreve (which equals two minims) is needed to make up the three minim beats.

## 3.5 Dots and ties

In Section 3.1, Example 14 we outlined the time values of each type of note. Here is a reminder of those note values:

__Example 14 (repeated)__

![figure images/a224_pm_mu014.jpg](images/a224_pm_mu014.jpg)

However, a time value of each type of note can be lengthened (and therefore changed) through the use of:

* a __dot__ or

* a __tie__.

A dot after any value extends that value by half as much again. Therefore a dotted crotchet lasts for a crotchet plus a half a crotchet (i.e. a quaver). In other words, as shown in Example 18, it lasts for the duration of three quavers in total.

__Example 18__

![figure images/a224_pm_mu018.jpg](images/a224_pm_mu018.jpg)

The dot is placed to the right of the note head, in the same space if the note head is in a space, or above the line if a note head is on a line. Example 19 summarises these principles.

__Example 19__

![figure images/a224_pm_mu019.jpg](images/a224_pm_mu019.jpg)

As you learned in Section 3.3, bar lines mark off groups of beats according to the time signature. In 4/4 time, therefore, there cannot be any more than four beats per bar. If we want to extend a time value where the lengthened value crosses a bar line, a tie can be used, as shown in Example 20. In this particular example, the effect of the tie is the same as if we had used a dot: the value of the minim is increased by a half (because it is joined to a crotchet which is half the value of a minim).

__Example 20__

![figure images/a224_1_pm_mu020.jpg](images/a224_1_pm_mu020.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
However, as shown in Example 21, a tie can also be used to increase a value by a different fraction. So as Example 21 (a) shows, a minim can be tied to a quaver, the quaver being a quarter of the minim’s value; and as shown in Example 21 (b), a crotchet can be tied to a semiquaver, the semiquaver being a quarter of the crotchet’s value. Either can take place within a bar or across a bar line.

__Example 21__

![figure images/a224_1_pm_mu021.jpg](images/a224_1_pm_mu021.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
You can tie any number of adjacent notes together in this way – but the tied notes must always have the same pitch. The ties must also be placed on the ‘outside’ of the note heads as you can see in Example 21.

## 3.6 Grouping and beaming notes

So far, when writing notes with flags such as quavers and semiquavers, each one has been written separately. However, for ease of reading, groups of quavers and semiquavers are joined or ‘beamed’ together. Thus, the previous example should more properly be written as shown in Example 22. In Example 22 (a) the two quavers are beamed together with a single beam, and in Example 22 (b) the four semiquavers are beamed together with a double beam. (Demisemiquavers would need a triple beam.)

__Example 22__

![figure images/a224_1_pm_mu022.jpg](images/a224_1_pm_mu022.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
In Example 22 (a) and (b) __the beaming joins together notes that belong to a single beat__, and this is a useful rule of thumb to follow when beaming notes together, especially with more complex examples, as demonstrated in Example 23, which shows one line of music twice – once unbeamed (Example 23 [a]) and once beamed (Example 23 [b]).

__Example 23__

![figure images/a224_1_pm_mu023.jpg](images/a224_1_pm_mu023.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
However, the following groupings shown in Example 24 are also used. Although these groupings break the ‘show each beat’ rule, they are treated as conventions.

### Conventions that break the ‘show each beat rule’

* __Example 24 (a)__ Where there is a complete set of quavers in a bar of 2/4, these can be beamed together with one beam rather than with two beams as two sets of two quavers. A similar convention is allowed for a complete set of quavers in a bar of 3/4 – only one beam is needed.

* __Example 24 (b)__ In 3/4, where four quavers ‘replace’ a minim, only one beam is needed instead of two.

* __Example 24 (c) __Similarly, in 4/4, where four quavers ‘replace’ a minim, only one beam is needed instead of two. However, in 4/4, the beam joining the four quavers cannot extend across the middle of the bar.

* __Example 24 (d)__ In 3/8, all quavers and semiquavers in a bar can be beamed together.

__Example 24__

![figure images/a224_pm_mu024.jpg](images/a224_pm_mu024.jpg)

There are several exceptions to the ‘show each beat’ rule here and it will take you time to absorb them. Perhaps the best way to tackle this is to pause for a moment or two and examine __Examples 23 and 24__ carefully once more so that you become familiar with how the beaming looks visually. Sometimes visual information can be easier to access than verbal information, particularly if the latter is extensive and detailed. So pause for a little now, and make an effort to familiarise yourself visually with the beaming patterns.

## 3.7 Review 3

Now try the activities in Group 1 on time signatures and beaming covered so far in this section. What is the time signature for each of the five bars? First of all, identify the beat – is it a minim, crotchet or quaver? Then count how many beats there are in the bar. Where relevant, thinking about the beaming might help you.

---

Group 1: identifying time signatures

### Activity

#### Question

Match the time signatures, 3/2, 2/4, 3/4, 4/4 and 3/8 to bar numbers 1–5.

3/4

__Bar 1__ ![inlinefigure images/a224_pm_un_mu030.jpg](images/a224_pm_un_mu030.jpg)

2/4

__Bar 2__ ![inlinefigure images/a224_pm_un_mu031.jpg](images/a224_pm_un_mu031.jpg)

4/4

__Bar 3__ ![inlinefigure images/a224_pm_un_mu032.jpg](images/a224_pm_un_mu032.jpg)

3/2

__Bar 4__ ![inlinefigure images/a224_pm_un_mu033.jpg](images/a224_pm_un_mu033.jpg)

3/8

__Bar 5__ ![inlinefigure images/a224_pm_un_mu034.jpg](images/a224_pm_un_mu034.jpg)

#### Answer

__Bar 1__: 3/4 There are three crotchet beats made up from a minim plus two quavers.

__Bar 2__: 2/4 The beaming shows two crotchet beats.

__Bar 3__: 4/4 The time values add up to four crotchets in total. Notice that the first two quavers cannot be beamed together since the beam would cross the middle of the bar.

__Bar 4__: 3/2 The dotted minim plus crotchet gives two minims and the bar is completed with another minim.

__Bar 5__: 3/8 There are three quaver beats. Notice that the four semiquavers plus the quaver can all be beamed together.

## 3.8 More time signatures: compound time

The time signatures considered up to now – 2/4, 3/4, 4/4, 2/2, 3/2 and 3/8 – are all examples of __simple time__. In simple time, each beat can always be divided into twos, or multiples of two. And simple time signatures are described fully according to how many beats in a bar there are as follows:

* 2/4 and 2/2 are called __simple duple time__ since there are two beats to each bar

* 3/8, 3/4 and 3/2 are called __simple triple time__ since there are three beats to each bar, and

* 4/4 is called __simple quadruple time __since there are four beats to each bar.

Example 25 a shows a bar of 3/4 time, where there are three beats to the bar, and each beat is divided into two.

__Example 25 (a)__

![figure images/a224_1_pm_mu025a.jpg](images/a224_1_pm_mu025a.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
When the beat is divided into threes, the term __compound time__ is used.

For example:

* in 6/8, there are 6 quavers per bar, but these 6 quavers are grouped in two groups of three – so it is called __compound duple time__. 6/4 is also called compound duple time, there are 6 crotchets per bar and these 6 crotchets are grouped in two sets of three.

* In 9/8 there are 9 quavers per bar, grouped in three groups of three – so it is called __compound triple time__.

* In 12/8 time there are 12 quavers per bar, grouped in four groups of three – so it is called __compound quadruple time__.

Example 25 (b) shows a bar of 6/8 time. There are __two__ beats to the bar, and each beat is divided into three.

__Example 25 (b)__

![figure images/a224_1_pm_mu025b.jpg](images/a224_1_pm_mu025b.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
But what is the reason for this different way of grouping the notes in each beat in compound time? This is because in compound time signatures, the beat is a dotted note such as a dotted minim (in say, 6/4) or a dotted crotchet (in, say, 6/8) rather than a minim or a crotchet in simple time signatures such as 3/2 or 3/4. We can see how this affects the beat division if we consider the bars of 3/4 time and 6/8 time together.

__Examples 25 (a) and (b)__

![figure images/a224_1_pm_mu025.jpg](images/a224_1_pm_mu025.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
If we count the number of quavers in a bar of 3/4 and in a bar of 6/8, the answer is the same, six. However, in 3/4 there are __three crotchet beats__ per bar, each beat divided into two quavers. In 6/8 there are __two dotted crotchet beats __per bar, each beat divided into three quavers. So 3/4 is simple triple time and 6/8 is compound duple time. In both art and popular music, composers have explored the variable beat produced by moving between these two time signatures.

## 3.9 Grouping and beaming notes in compound time

As with grouping notes within a single beat in simple time, beaming together quavers and semiquavers that belong to a single beat is a useful guideline to follow when grouping notes together in compound time. As you learned in the previous section, the beat in such compound time signatures as 6/8 or 9/8 is the dotted crotchet (equivalent to three quavers), so with these time signatures all quavers and semiquavers within a beat must be beamed in groups of three quavers. Example 26 shows how several notes that comprise a single beat are beamed together in 6/8 time.

__Example 26__

![figure images/a224_1_pm_mu026.jpg](images/a224_1_pm_mu026.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
As you can see from Example 26, the extent of the beat is always shown in the beaming – each group of beamed notes adds up to three quavers (a dotted crotchet). Beaming together quavers in groups which do *not* add up to three quavers would suggest a different time signature where the extent of the beat is a different time value. Thus the rhythm in 6/8 in Example 27 (a) cannot be written as in Example 27 (b), because Example 27 (b) suggests 3/4 time. In Example 27 (b) the quavers are beamed together in twos rather than threes, and this signifies a crotchet beat and hence 3/4.

__Example 27__

![figure images/a224_pm_mu027.jpg](images/a224_pm_mu027.jpg)

When we consider time values that last for two beats rather than a single one in compound time, the ‘show the dotted beat rule’ no longer applies. For instance, time values that last for two beats in 6/8, 9/8 and 12/8 are written as Example 28 (a) rather than Example 28 (b).

__Example 28__

![figure images/a224_pm_mu028_new.jpg](images/a224_pm_mu028_new.jpg)

Hence, a note lasting a full bar in 6/8 is written as shown in Example 29.

__Example 29__

![figure images/a224_1_pm_mu029.jpg](images/a224_1_pm_mu029.jpg)
<!--MEDIACONTENT--><!--ENDMEDIACONTENT-->
Finally, notice that a note lasting a full bar in 9/8 time is written as shown in Example 30, and in 12/8 time as in Example 31.

__Example 30__

![figure images/a224_pm_mu030.jpg](images/a224_pm_mu030.jpg)

__Example 31__

![figure images/a224_pm_mu031.jpg](images/a224_pm_mu031.jpg)

As with beaming in simple time, you can see that there is a set of conventions to follow when beaming in compound time. So, once again, take a few moments to study carefully the visual patterns involved in Examples 26 and 27.

## 3.10 Review 4

The following three groups of activities focus on identifying simple and compound time signatures, and time values in compound time.

---

Group 1: identifying compound time signatures

### Activity 1

#### Question

Match the time signatures, 6/8, 9/8 and 12/8 to bar numbers 1–3.

When identifying compound time signatures, count how many dotted crotchet beats there are in a bar. Don’t forget that a dotted crotchet is equivalent to three quavers and that thinking about the beaming might help you.

6/8

__Bar 1__ ![inlinefigure images/a224_pm_un_mu035.jpg](images/a224_pm_un_mu035.jpg)

9/8

__Bar 2__ ![inlinefigure images/a224_pm_un_mu036.jpg](images/a224_pm_un_mu036.jpg)

12/8

__Bar 3__ ![inlinefigure images/a224_pm_un_mu037.jpg](images/a224_pm_un_mu037.jpg)

#### Answer

__Bar 1__ – __6/8__. There are two dotted-crotchet beats in the bar. The beam joining the first three notes shows conveniently the extent of the first beat, and the straightforward crotchet/quaver rhythm comprises the second beat.

__Bar 2__ – __9/8__. Despite the rhythmic complexity introduced by the ties, the beaming clearly shows three dotted-crotchet beats.

__Bar 3__ – __12/8__. Notice that the rhythmic value that extends through the first two full dotted-crotchet beats is notated with a dotted minim (not two tied dotted crotchets), but the division of the second pair of dotted-crotchet beats has to be shown using a tie.

---

Group 2: identifying simple and compound time signatures

### Activity 1

#### Question

When identifying simple and compound time signatures, identify the beat first – is it, for example, a minim? Then count how many beats there are in the bar. Remember, too, to consider the beaming.

Match the time signatures, 3/2, 2/4, 3/4, 4/4, 6/8, 9/8 to bar numbers 1–6.

3/2

__Bar 1__ ![inlinefigure images/a224_pm_un_mu038.jpg](images/a224_pm_un_mu038.jpg)

4/4

__Bar 2__ ![inlinefigure images/a224_pm_un_mu039.jpg](images/a224_pm_un_mu039.jpg)

6/8

__Bar 3__ ![inlinefigure images/a224_pm_un_mu040.jpg](images/a224_pm_un_mu040.jpg)

3/4

__Bar 4__ ![inlinefigure images/a224_pm_un_mu041.jpg](images/a224_pm_un_mu041.jpg)

9/8

__Bar 5__ ![inlinefigure images/a224_pm_un_mu042.jpg](images/a224_pm_un_mu042.jpg)

2/4

__Bar 6__ ![inlinefigure images/a224_pm_un_mu043.jpg](images/a224_pm_un_mu043.jpg)

#### Answer

__Bar 1__:3/2 There are three minim beats in the bar.

__Bar 2__:4/4 There are four crotchet beats in the bar. Notice that the beaming for the quavers cannot extend across the middle of the bar.

__Bar 3__:6/8 The beaming shows the first dotted-crotchet beat, and the second consists of a quaver/crotchet rhythm.

__Bar 4__:3/4 Six quavers in 3/4 can all be beamed together. In 6/8 the beaming of the quavers would have to show the division of the bar into two dotted crotchets: the first three quavers and the last three would be beamed separately.

__Bar 5__:9/8 The beat is a dotted crotchet and there are three of them.

__Bar 6__:2/4 Despite the rhythmic complexity, the beaming shows two crotchet beats.

---

Group 3: identifying omitted time values in compound time

### Activity 1

#### Question

Which single time value is required at each of the places marked with asterisks?

![figure images/a224_pm_un_mu044.jpg](images/a224_pm_un_mu044.jpg)

crotchet/dotted crotchet

crotchet/crotchet

dotted crotchet/dotted crotchet

#### Answer

The time signature, 6/8, has two dotted-crotchet beats per bar. In the first bar, following the first dotted-crotchet beat which is conveniently beamed, we need a crotchet to make up the second dotted-crotchet beat. The three quavers that open the second bar add up to another dotted-crotchet beat and therefore we need a dotted crotchet to complete the bar.

### Activity 2

#### Question

Which single time value is required at each of the places marked with asterisks?

![figure images/a224_pm_un_mu045.jpg](images/a224_pm_un_mu045.jpg)

dotted crotchet/dotted semibreve

dotted minim/semibreve

dotted minim/dotted semibreve

#### Answer

The time signature, 12/8, has four dotted-crotchet beats per bar. In the first bar, since two dotted-crotchet beats are already present, another two are required. A single time value for this would be a dotted minim. The time value that would extend throughout the second bar is a dotted semibreve.

### Activity 3

#### Question

Which single time value is required at each of the places marked with asterisks?

![figure images/a224_pm_un_mu046.jpg](images/a224_pm_un_mu046.jpg)

crotchet/quaver

crotchet/dotted crotchet

crotchet/crotchet

#### Answer

The time signature, 9/8, has three dotted-crotchet beats per bar. Since, in the first bar, the fourth and fifth quavers are not beamed together, they are showing the division between the second and third beats. Therefore the second beat needs a crotchet before the fourth quaver to make up the second dotted-crotchet beat and the third beat needs a crotchet after the fifth quaver to make up the third dotted-crotchet beat.

repository: ouseful-testing/action-steps

repo_name: ouseful-testing/action-steps


text:
# PrehistoricLife - Creatures of the Mesozoic

Prehistoric Life - Creatures of the Mesozoic is an educational Ruby app that allows a user to dive into a prehistoric era and learn about life on Earth during that era.

## Installation

From the command line, navigate to the "prehistoric_life" directory and run bundle install.  Then run bin/prehistoric_life.

## Usage

1)	Select one of the presented eras.
2)	Select an animal from the list presented to learn a fun fact about that animal.
3)  Exit the program or choose another era.

## Development

Developed by Christopher Dent using Ruby v 2.5 for Flatiron School CLI Project.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/'christopherdent'/prehistoric_life. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the PrehistoricLife project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'christopherdent'/prehistoric_life/blob/master/CODE_OF_CONDUCT.md).

gha_language: Ruby


text:
---
metaTitle: "Bash - Customizing PS1"
description: "Colorize and customize terminal prompt, Show git branch name in terminal prompt, Change PS1 prompt, Show a git branch using PROMPT_COMMAND, Show time in terminal prompt, Show previous command return status and time"
---

# Customizing PS1

## Colorize and customize terminal prompt

This is how the author sets their personal `PS1` variable:

```bash
gitPS1(){
    gitps1=$(git branch 2>/dev/null | grep '*')
    gitps1="${gitps1:+ (${gitps1/#\* /})}"
    echo "$gitps1"
}
#Please use the below function if you are a mac user
gitPS1ForMac(){
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
timeNow(){
    echo "$(date +%r)"
}
if [ "$color_prompt" = yes ]; then
  if [ x$EUID = x0 ]; then
    PS1='\[\033[1;38m\][$(timeNow)]\[\033[00m\] \[\033[1;31m\]\u\[\033[00m\]\[\033[1;37m\]@\[\033[00m\]\[\033[1;33m\]\h\[\033[00m\] \[\033[1;34m\]\w\[\033[00m\]\[\033[1;36m\]$(gitPS1)\[\033[00m\] \[\033[1;31m\]:/#\[\033[00m\] '
  else
    PS1='\[\033[1;38m\][$(timeNow)]\[\033[00m\] \[\033[1;32m\]\u\[\033[00m\]\[\033[1;37m\]@\[\033[00m\]\[\033[1;33m\]\h\[\033[00m\] \[\033[1;34m\]\w\[\033[00m\]\[\033[1;36m\]$(gitPS1)\[\033[00m\] \[\033[1;32m\]:/$\[\033[00m\] '
  fi
else
    PS1='[$(timeNow)] \u@\h \w$(gitPS1) :/$ '
fi

```

And this is how my prompt looks like:
[](http://i.stack.imgur.com/FmO2S.png)

Color reference:

```bash
# Colors
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m'   # Black - Background
bakred='\e[41m'   # Red
badgrn='\e[42m'   # Green
bakylw='\e[43m'   # Yellow
bakblu='\e[44m'   # Blue
bakpur='\e[45m'   # Purple
bakcyn='\e[46m'   # Cyan
bakwht='\e[47m'   # White
txtrst='\e[0m'    # Text Reset

```

**Notes:**

Make the changes in `~/.bashrc` or `/etc/bashrc` or `~/.bash_profile` or `~./profile` file (depending on the OS) and save it.

For `root` you might also need to edit the `/etc/bash.bashrc` or `/root/.bashrc` file

Run `source ~/.bashrc` (distro specific) after saving the file.

Note: if you have saved the changes in `~/.bashrc`, then remember to add `source ~/.bashrc` in your `~/.bash_profile` so that this change in `PS1` will be recorded every time the Terminal application starts.

## Show git branch name in terminal prompt

You can have functions in the PS1 variable, just make sure to single quote it or use escape for special chars:

```bash
gitPS1(){
    gitps1=$(git branch 2>/dev/null | grep '*')
    gitps1="${gitps1:+ (${gitps1/#\* /})}"
    echo "$gitps1"
}

PS1='\u@\h:\w$(gitPS1)$ '

```

It will give you a prompt like this:

```bash
user@Host:/path (master)$

```

**Notes:**

- Make the changes in `~/.bashrc` or `/etc/bashrc` or `~/.bash_profile` or `~./profile` file (depending on the OS) and save it.
- Run `source ~/.bashrc` (distro specific) after saving the file.

## Change PS1 prompt

To change PS1, you just have to change the value of PS1 shell variable. The value can be set in `~/.bashrc` or `/etc/bashrc` file, depending on the distro. PS1 can be changed to any plain text like:

```bash
PS1="hello "

```

Besides the plain text, a number of backslash-escaped special characters are supported:

| Format          | Action                                                                                |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `\a`            | an ASCII bell character (07)                                                                                |
| `\d`            | the date in “Weekday Month Date” format (e.g., “Tue May 26”)                                                                                |
| `\D{format}`    | the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required |
| `\e`            | an ASCII escape character (033)                                                                                |
| `\h`            | the hostname up to the first ‘.’                                                                                |
| `\H`            | the hostname                                                                                |
| `\j`            | the number of jobs currently managed by the shell                                                                                |
| `\l`            | the basename of the shell’s terminal device name                                                                                |
| `\n`            | newline                                                                                |
| `\r`            | carriage return                                                                                |
| `\s`            | the name of the shell, the basename of \$0 (the portion following the final slash)                                                                                |
| `\t`            | the current time in 24-hour HH:MM:SS format                                                                                |
| `\T`            | the current time in 12-hour HH:MM:SS format                                                                                |
| `\@`            | the current time in 12-hour am/pm format                                                                                |
| `\A`            | the current time in 24-hour HH:MM format                                                                                |
| `\u`            | the username of the current user                                                                                |
| `\v`            | the version of bash (e.g., 2.00)                                                                                |
| `\V`            | the release of bash, version + patch level (e.g., 2.00.0)                                                                                |
| `\w`            | the current working directory, with \$HOME abbreviated with a tilde                                                                                |
| `\W`            | the basename of the current working directory, with \$HOME abbreviated with a tilde                                                                                |
| `\!`            | the history number of this command                                                                                |
| `\#`            | the command number of this command                                                                                |
| `\$`            | if the effective UID is 0, a #, otherwise a \$                                                                                |
| `\nnn*`         | the character corresponding to the octal number nnn                                                                                |
| `\`|a backslash |
| `\[`            | begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt                                                            |
| `\]`            | end a sequence of non-printing characters                                                                                |

So for example, we can set PS1 to:

```bash
PS1="\u@\h:\w\$ "

```

And it will output:

> user@machine:~\$

## Show a git branch using PROMPT_COMMAND

If you are inside a folder of a git repository it might be nice to show the current branch you are on. In `~/.bashrc` or `/etc/bashrc` add the following (git is required for this to work):

```bash
function prompt_command {
    # Check if we are inside a git repository
    if git status > /dev/null 2>&1; then
        # Only get the name of the branch
        export GIT_STATUS=$(git status | grep 'On branch' | cut -b 10-)
    else
        export GIT_STATUS=""
    fi
}
# This function gets called every time PS1 is shown
PROMPT_COMMAND=prompt_command

PS1="\$GIT_STATUS \u@\h:\w\$ "

```

If we are in a folder inside a git repository this will output:

> branch user@machine:~\$

And if we are inside a normal folder:

> user@machine:~\$

## Show time in terminal prompt

```bash
timeNow(){
    echo "$(date +%r)"
}
PS1='[$(timeNow)] \u@\h:\w$ '

```

It will give you a prompt like this:

```bash
[05:34:37 PM] user@Host:/path$

```

**Notes:**

- Make the changes in `~/.bashrc` or `/etc/bashrc` or `~/.bash_profile` or `~./profile` file (depending on the OS) and save it.
- Run `source ~/.bashrc` (distro specific) after saving the file.

## Show previous command return status and time

Sometimes we need a visual hint to indicate the return status of previous command. The following snippet make put it at the head of the PS1.

Note that the \_\_stat() function should be called every time a new PS1 is generated, or else it would stick to the return status of last command of your .bashrc or .bash_profile.

```bash
# -ANSI-COLOR-CODES- #
Color_Off="\033[0m"
###-Regular-###
Red="\033[0;31m"
Green="\033[0;32m"
Yellow="\033[0;33m"
####-Bold-####

function __stat() {
    if [ $? -eq 0 ]; then
        echo -en "$Green ✔ $Color_Off "
    else
        echo -en "$Red ✘ $Color_Off "
    fi
}

PS1='$(__stat)'
PS1+="[\t] "
PS1+="\e[0;33m\u@\h\e[0m:\e[1;34m\w\e[0m \n$ "

export PS1

```

[](http://i.stack.imgur.com/ZjEQ5.png)

repository: haifenghuang/generate

repo_name: haifenghuang/generate


text:
#### Dependencies

Ensure that the following dependencies are installed before compiling PetIBM:

* GNU C++ Compiler(`g++`) version 4.6 or above
* [PETSc](http://www.mcs.anl.gov/petsc/) version 3.5.0 or above (use branch `petsc-3.4-compatible` to run with PETSc 3.4)
* [Boost](http://www.boost.org) version 1.55.0 or above (no build is required)

PetIBM has been tested and run on Ubuntu 12.04, Ubuntu 14.10 and Mac OS X 10.8.

---

#### GNU C++ Compiler (`g++`)

On Ubuntu, install `g++` using the following command:

    > sudo apt-get install g++

Check the version of G++ installed:

    > g++ --version

Other development and version control tools can be installed by following the instructions under Step 1 in the
[CompilingEasyHowTo](https://help.ubuntu.com/community/CompilingEasyHowTo) page on the Ubuntu Community Help Wiki.
Software developers will find it useful to install all of them.

`g++` can be installed on Mac OS X by installing XCode through the App Store.

---

#### Get PETSc

Install PETSc-3.5.2 in debugging mode and/or optimized mode. The debug mode is recommended during development, while the optimized mode should be used for production runs.

Get and unpack PETSc:

    > cd $HOME/sfw
    > mkdir -p petsc/3.5.2
    > wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.5.2.tar.gz
    > tar -xvf petsc-lite-3.5.2.tar.gz -C petsc/3.5.2 --strip-components=1
    > cd petsc/3.5.2

Configure and build an debugging version of PETSc:

    > export PETSC_DIR=$HOME/sfw/petsc/3.5.2
    > export PETSC_ARCH=linux-dbg
    > ./configure --PETSC_ARCH=$PETSC_ARCH \
    --download-fblaslapack \
    --download-mpich
    > make all
    > make test

Configure and build an optimized version of PETSc:

    > export PETSC_DIR=$HOME/sfw/petsc/3.5.2
    > export PETSC_ARCH=linux-opt
    > ./configure --PETSC_ARCH=$PETSC_ARCH \
    --with-debugging=0 \
    --COPTFLAGS=-O3 --CXXOPTFLAGS=-O3 --FOPTFLAGS=-O3 \
    --download-fblaslapack \
    --download-mpich
    > make all
    > make test

When running the code on an external cluster, make sure that you compile PETSc with the MPI that has been configured to work with the cluster. Hence, **do not use the `--download-mpich` flag**, but instead point to the folder with the MPI compilers and executables using the `--with-mpi-dir` flag. If BLAS and LAPACK are already installed in the system, you can point to the libraries using the `--with-blas-lib` and `--with-lapack-lib` flags.

If you are installing PETSc-3.4, use the option `--download-f-blas-lapack` instead of `--download-fblaslapack`.

[Detailed instructions](http://www.mcs.anl.gov/petsc/documentation/installation.html) with more options to customize your installation can be found on the PETSc website. Run `./configure --help` in the PETSc root directory to list all the available configure flags.

The PETSc Users Manual and the Manual Pages can be found on their
[documentation page](http://www.mcs.anl.gov/petsc/documentation/index.html).

---

#### Get Boost

The parser used in PetIBM to go through the input files requires some Boost header files.
If the Boost library is not already installed on your machine, you may type the following command-lines:

    > cd $HOME/sfw
    > mkdir -p boost/1.57.0
    > wget http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.gz
    > tar -xvf boost_1_57_0.tar.gz -C boost/1.57.0 --strip-components=1

That's it! We only need some header files from the Boost library.

---

#### Get PetIBM

Create a local copy of the PetIBM repository:

    > cd $HOME/sfw
    > mkdir petibm && cd petibm
    > git clone https://github.com/barbagroup/PetIBM.git
    > export PETIBM_DIR=$HOME/sfw/petibm/PetIBM

You can set the environment variable `PETIBM_DIR` to your `$HOME/.bashrc` or `$HOME/.bash_profile` files by adding the line:

    > export PETIBM_DIR=$HOME/sfw/petibm/PetIBM

and restart you terminal or  source the file:

    > source $HOME/.bashrc

Note: if you are using C shell, use the `setenv` command instead of `export`.

Configure and build PetIBM using the optimized PETSc build:

    > export PETSC_DIR=$HOME/sfw/petsc/3.5.2
    > export PETSC_ARCH=linux-opt
    > mkdir petibm-linux-opt && cd petibm-linux-opt
    > $PETIBM_DIR/configure --prefix=$HOME/sfw/petibm/petibm-linux-opt \
    --with-boost=$HOME/sfw/boost/1.57.0 \
    CC=$PETSC_DIR/$PETSC_ARCH/bin/mpicc \
    CXX=$PETSC_DIR/$PETSC_ARCH/bin/mpicxx
    > make all
    > make check
    > make install

You may also want to build a debugging version:

    > export PETSC_DIR=$HOME/sfw/petsc/3.5.2
    > export PETSC_ARCH=linux-dbg
    > mkdir petibm-linux-dbg && cd petibm-linux-dbg
    > $PETIBM_DIR/configure --prefix=$HOME/sfw/petibm/petibm-linux-dbg \
    --with-boost=$HOME/sfw/boost/1.57.0 \
    CC=$PETSC_DIR/$PETSC_ARCH/bin/mpicc \
    CXX=$PETSC_DIR/$PETSC_ARCH/bin/mpicxx
    > make all
    > make check
    > make install

## Contact

Please e-mail [Anush Krishnan](mailto:k.anush@gmail.com), [Olivier<EMAIL_ADDRESS>if you have any questions, suggestions or feedback.

To report bugs, please use the GitHub issue tracking system.
We are also open to pull-requests.

branch_name: refs/heads/develop


text:
# docker-compose-mysql-master-master

A docker-compose example for a mysql master master setup

## docker-compose scripts

1. 查看状态 `docker-compose ps`
1. 强删集群 `docker-compose rm -fsv`
1. 启动集群 `docker-compose up`
1. 登录1号 `docker-compose exec mysqlmaster1 mysql -uroot -proot`
1. 登录2号 `docker-compose exec mysqlmaster2 mysql -uroot -proot`
1. 停止1号 `docker-compose stop mysqlmaster1`
1. 启动1号 `docker-compose start mysqlmaster1`
1. 检查集群 `./MySQLReplicationCheck.sh`
1. `/bin/bash -x /etc/mysql/conf.d/configure1.sh`
1. `MYSQL_PWD=root mysql -u root`
1. `/tmp/mci -c /tmp/mci.toml`

## 测试场景

1. 自增字段场景

    1. MySQLServer1插入t1表10条数据
    1. 检查MySQLServer2中t1表10条数据是否同步，自增字段取值情况
    1. MySQLServer2插入t1表10条数据
    1. 检查MySQLServer1中t1表10条数据是否同步，自增字段取值情况

1. 双向同步场景

    1. MySQLServer1插入t1表100条数据
    1. MySQLServer2插入t1表100条数据
    1. 各自检查同步状态，是否都是200条

1. 节点重启场景

    1. MySQLServer2停
    1. MySQLServer1插入t1表100条数据
    1. MySQLServer2启动
    1. 查看MySQLServer2中t1表同步状态

## test SQL scripts

```sql
select name from mysql.proc where name like 't1%';

call bjca.batch_t1(100);
select count(*) from bjca.t1;
select * from bjca.t1;
insert into bjca.t1(a) values(3);
```

## thanks

1. [mysql refman 5.7 Chapter 16 Replication](https://dev.mysql.com/doc/refman/5.7/en/replication.html)
1. [MySQL master slave using docker](https://tarunlalwani.com/post/mysql-master-slave-using-docker/) and its related [github rep](https://github.com/tarunlalwani/docker-compose-mysql-master-slave)
1. [MySQL Master Slave Docker部署例子](https://chanjarster.github.io/post/mysql-master-slave-docker-example/) and its related [github rep](https://github.com/chanjarster/mysql-master-slave-docker-example)
1. [玩转一下MySQL双主集群](https://github.com/bingoohuang/blog/issues/118)
1. [High-Availability MySQL cluster with load balancing using HAProxy and Heartbeat.](https://github.com/bingoohuang/docker-compose-mysql-master-master)
1. [开启GTID的情况下导出导入库的注意事项](https://docs.lvrui.io/2016/10/28/%E5%BC%80%E5%90%AFGTID%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E5%AF%BC%E5%87%BA%E5%AF%BC%E5%85%A5%E5%BA%93%E7%9A%84%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9/)

## tips

### 为什么需要单独建立docker的network

> What was happening was that the default docker network doesn't allow name >> DNS mapping.
> Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option, which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias.
>
> --[How to allow docker containers to see each other by their name?](https://serverfault.com/a/913075)

```sql
select * from information_schema.tables where TABLE_SCHEMA not in ('performance_schema', 'information_schema', 'mysql', 'sys') and TABLE_NAME not like '%_mci';
rename table bjca.t2 to bjca.t2_mci;

SET GLOBAL server_id=10002;
STOP SLAVE;
RESET SLAVE ALL;
DROP USER IF EXISTS 'root'@'mysqlmaster1';
CREATE USER 'root'@'mysqlmaster1' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'mysqlmaster1' WITH GRANT OPTION;

DROP USER IF EXISTS 'repl'@'%';
CREATE USER 'repl'@'%' IDENTIFIED BY 'repl';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'repl';
CHANGE MASTER TO master_host='mysqlb', master_port=3306, master_user='repl', master_password='repl', master_auto_position = 1;
CHANGE MASTER TO master_host='mysqla', master_port=3306, master_user='repl', master_password='repl', master_auto_position = 1;
START SLAVE;

SET GLOBAL server_id=10001;
STOP SLAVE;
RESET SLAVE ALL;
DROP USER IF EXISTS 'root'@'mysqlmaster1';
CREATE USER 'root'@'mysqlmaster1' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'mysqlmaster1' WITH GRANT OPTION;

DROP USER IF EXISTS 'repl'@'%';
CREATE USER 'repl'@'%' IDENTIFIED BY 'repl';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'repl';
CHANGE MASTER TO master_host='mysqlmaster2', master_port=3306, master_user='repl', master_password='repl', master_auto_position = 1;

SHOW MASTER STATUS;
RESET MASTER;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
UNLOCK TABLES;
START SLAVE;

/* 主1上 */ create database bjca;
/* 主1上 */ create table bjca.t_m1(name varchar(100));
/* 主2上 */ insert into bjca.t_m1 values('written from master2');
/* 主1从 */ select * from bjca.t_m1;

/* 主2上 */ create table bjca.t_m2(name varchar(100));
/* 主1上 */ insert into bjca.t_m2 values('written from master1');
/* 主2从 */ select * from bjca.t_m2;

/* 所有上 */ SHOW SLAVE STATUS\G
```

```bash
root@c31810844c58:/# MYSQL_PWD=root mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+------------------------------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                        |
+------------------+----------+--------------+------------------+------------------------------------------+
| mysql-bin.000003 |      836 |              |                  | 7ab075b1-0431-11ea-80f8-0242ac120003:1-8 |
+------------------+----------+--------------+------------------+------------------------------------------+
1 row in set (0.00 sec)

mysql> select TABLE_SCHEMA, TABLE_NAME, from information_schema.tables where TABLE_SCHEMA not in ('performance_schema', 'information_schema', 'mysql', 'sys') and TABLE_NAME not like '%_mci'
    -> ;
+---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME         | UPDATE_TIME         | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------------+
| def           | bjca         | t2         | BASE TABLE | InnoDB |      10 | Dynamic    |          1 |          16384 |       16384 |               0 |            0 |         0 |           NULL | 2019-11-11 03:17:33 | 2019-11-11 03:17:33 | NULL       | utf8_general_ci |     NULL |                |               |
+---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------------+
1 row in set (0.00 sec)

mysql> rename table bjca.t2 to bjca.t2_mci;
Query OK, 0 rows affected (0.00 sec)

mysql> RESET MASTER;
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |      154 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
```

How to re-sync the Mysql DB if Master and slave have different database incase of Mysql replication?
https://stackoverflow.com/questions/2366018/how-to-re-sync-the-mysql-db-if-master-and-slave-have-different-database-incase-o

This is the full step-by-step procedure to resync a master-slave replication from scratch:

At the master:

RESET MASTER;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
And copy the values of the result of the last command somewhere.

Without closing the connection to the client (because it would release the read lock) issue the command to get a dump of the master:

mysqldump -u root -p --all-databases > /a/path/mysqldump.sql
Now you can release the lock, even if the dump hasn't ended yet. To do it, perform the following command in the MySQL client:

UNLOCK TABLES;
Now copy the dump file to the slave using scp or your preferred tool.

At the slave:

Open a connection to mysql and type:

STOP SLAVE;
Load master's data dump with this console command:

mysql -uroot -p < mysqldump.sql
Sync slave and master logs:

RESET SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=98;
Where the values of the above fields are the ones you copied before.

Finally, type:

START SLAVE;
To check that everything is working again, after typing:

SHOW SLAVE STATUS;
you should see:

Slave_IO_Running: Yes
Slave_SQL_Running: Yes
That's it!

[每日MySQL之024：FLUSH TABLES](https://blog.csdn.net/qingsong3333/article/details/77170864)

FLUSH TABLES 作用是 flush 表，并根据参数加上相应的锁。默认是写日志的，如果不希望写日志，可以设置加上参数 NO_WRITE_TO_BINLOG。另外， FLUSH TABLES 命令执行前会隐式地发出commit命令，常见语法如下：

• FLUSH TABLES
关闭所有的表，包括正在使用的表，并且会flush query cache。如果有正处于活动状态的 LOCK TABLES ... READ 命令，则不允许 FLUSH TABLES 命令

• FLUSH TABLES tbl_name [, tbl_name] ...
只FLUSH 指定表

• FLUSH TABLES WITH READ LOCK
关闭所有的表，并给所有数据库的所有表加上一个global read lock。这对于backup操作来说很有用，加锁之后，可以防止应用修改数据库。这个是全局级别的锁，而非表锁。

• FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK
同上，但只针对部分表

• FLUSH TABLES tbl_name [, tbl_name] ... FOR EXPORT
只针对 InnoDB 表，可以确保对表的修改被刷新到磁盘上，MySQL可以通过直接拷贝底层文件的方式来复制表，参考链接。

[Should a MySQL replication slave be set to read only?](https://dba.stackexchange.com/a/30129)

When a Slave is read-only, it is not 100% shielded from the world.

According to MySQL Documentation on read-only

This variable is off by default. When it is enabled, the server permits no updates except from users that have the SUPER privilege or (on a slave server) from updates performed by slave threads. In replication setups, it can be useful to enable read_only on slave servers to ensure that slaves accept updates only from the master server and not from clients.

Thus, anyone with SUPER privilege can read and write at will to such a Slave...

Make sure all non-privileged users do not have the SUPER Privilege.

If you want to revoke all SUPER privileges in one shot, please run this on Master and Slave:

UPDATE mysql.user SET super_priv='N' WHERE user<>'root';
FLUSH PRIVILEGES;
With reference to the Slave, this will reserve SUPER privilege to just root and prevent non-privileged from doing writes they would otherwise be restricted from.

UPDATE 2015-08-28 17:39 EDT
I just learned recently that MySQL 5.7 will introduce super_read_only.

This will stop SUPER users in their tracks because the 5.7 Docs say

If the read_only system variable is enabled, the server permits client updates only from users who have the SUPER privilege. If the super_read_only system variable is also enabled, the server prohibits client updates even from users who have SUPER. See the description of the read_only system variable for a description of read-only mode and information about how read_only and super_read_only interact.

Changes to super_read_only on a master server are not replicated to slave servers. The value can be set on a slave server independent of the setting on the master.

super_read_only was added in MySQL 5.7.8.

`MYSQL_PWD=root mysqldump -u root -p --all-databases > /a/path/mysqldump.sql`

repository: bingoohuang/mysql-cluster

repo_name: bingoohuang/mysql-cluster


text:
# urdf-viz

 Visualizer Tool, written by **Takashi Ogura** in Rust.

![](img/themes.png)

## How to use

`urdf-viz` command will be installed.
It needs `rosrun` and `rospack` to resolve `package://` in `<mesh>` tag, and
it uses `xacro` to convert `.xacro` file into urdf file.
It means you need `$ source ~/catkin_ws/devel/setup.bash` or something before using `urdf-viz`.

```bash
urdf-viz URDF_FILE.urdf
```

It is possible to use xacro file directly.
It will be converted by `rosrun xacro xacro` inside of `urdf-viz`.

```bash
urdf-viz XACRO_FILE.urdf.xacro
```

For other options, please read the output of `-h` option.

```bash
urdf-viz -h
```

If there are no "package://" in mesh tag, and don't use xacro you can skip install of ROS.

## GUI Usage

In the GUI, you can do some operations with keyboard and mouse.

* `t` key to switch between dark and light themes :new:
* `l` key to reload the urdf from file
* `c` key to toggle collision model or visual mode
* Move a joint
  * set the angle of a joint by `Up`/`Down` key
  * `Ctrl` + Drag to move the angle of a joint
  * change the joint to be moved by `[` and `]`
* Inverse kinematics (only positions)
  * `Shift` + Drag to use inverse kinematics(Y and Z axis)
  * `Shift` + `Ctrl` + Drag to use inverse kinematics(X and Z axis)
  * change the move target for inverse kinematics by `,` or `.`
* `r` key to set random joints
* Move view point
  * Mouse Right Drag to translate view camera position
  * Mouse Left Drag to look around
  * Scroll to zoom in/out

## Web I/O interface

You can set/get the joint angles using http/JSON.
Default port number is 7777. You can change it by `-p` option.
(`jq` is used for JSON formatter in the following examples)

### Set joint angles

POST the JSON data, which format is like below. You have to specify the names of joints and positions (angles).
The length of `names` and `positions` have to be the same. You don't need write
all joint names, it means you can specify a part of the joints.

```json
{
  "names": ["joint_name1", "joint_name2"],
  "positions": [0.5, -0.1]
}
```

You can try it using `curl`.

```bash
$ curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"names": ["r_shoulder_yaw", "r_shoulder_pitch"], "positions": [0.8, -0.8]}'  http://<IP_ADDRESS>:7777/set_joint_positions | jq
{
  "is_ok": true,
  "reason": ""
}
```

### Get joint angles as JSON

The result JSON format of getting the joint angles is the same as the *Set* method.

```bash
$ curl http://<IP_ADDRESS>:7777/get_joint_positions | jq
{
  "names": [
    "r_shoulder_yaw",
    "r_shoulder_pitch",
    "r_shoulder_roll",
    "r_elbow_pitch",
    "r_wrist_yaw",
    "r_wrist_pitch",
    "l_shoulder_yaw",
    "l_shoulder_pitch",
    "l_shoulder_roll",
    "l_elbow_pitch",
    "l_wrist_yaw",
    "l_wrist_pitch"
  ],
  "positions": [
    0.8,
    -0.8,
    -1.3447506,
    -1.6683152,
    -1.786362,
    -1.0689334,
    0.11638665,
    -0.5987091,
    0.7868867,
    -0.027412653,
    0.019940138,
    -0.6975361
  ]
}
```

## Dependencies

* [kiss3d](https://github.com/sebcrozet/kiss3d): `urdf-viz` is strongly depend on `kiss3d`, which is super easy to use, great 3D graphic engine.
* [nalgabra](https://github.com/sebcrozet/nalgebra): linear algebra library.
* [k](https://github.com/OTL/k): kinematics library which is based on [nalgabra](https://github.com/sebcrozet/nalgebra). It can load URDF files using `urdf-rs`.
* [assimp-rs](https://github.com/Eljay/assimp-rs): assimp rust interface. `kiss3d` supports `.obj` files natively, but urdf contains `dae` or `stl` files. These files are converted to kiss3d mesh model by `assim-rs`
* [urdf-rs](https://github.com/OTL/urdf-rs): URDF file loader.
* [structopt](https://github.com/TeXitoi/structopt): super easy command line arguments parser.

repository: nilseuropa/urdf-viz

repo_name: nilseuropa/urdf-viz


text:
# End-to-end Autonomous Driving Perception
[[Project webpage]](https://sites.google.com/berkeley.edu/e2e-percep/) [[Paper]](https://arxiv.org/abs/2003.12464)

This repo contains code for [End-to-end Autonomous Driving Perception with Sequential Latent Representation Learning](https://arxiv.org/abs/2003.12464). This work introduces a novel end-to-end approach for autonomous driving perception. A latent space is introduced to capture all relevant features useful for perception, which is learned through sequential latent representation learning. The learned end-to-end perception model is able to solve the detection, tracking, localization and mapping problems altogether with only minimum human engineering efforts and without storing any maps online. The proposed method is evaluated in a realistic urban driving simulator (CARLA simulator), with both camera image and lidar point cloud as sensor inputs.

## System Requirements
- Ubuntu 16.04
- NVIDIA GPU with CUDA 10. See [GPU guide](https://www.tensorflow.org/install/gpu) for TensorFlow.

## Installation
1. Setup conda environment
```
$ conda create -n env_name python=3.6
$ conda activate env_name
```

2. Install the interpretable end-to-end driving package following the installation steps 2-4 in [https://github.com/cjy1992/interp-e2e-driving](https://github.com/cjy1992/interp-e2e-driving).

3. Clone this git repo to an appropriate folder
```
$ git clone https://github.com/cjy1992/detect-loc-map.git
```

4. Enter the root folder of this repo and install the packages:
```
$ pip install -r requirements.txt
$ pip install -e .
```

## Usage
1. Enter the CARLA simulator folder and launch the CARLA server by:
```
$ ./CarlaUE4.sh -windowed -carla-port=2000
```
You can use ```Alt+F1``` to get back your mouse control.
Or you can run in non-display mode by:
```
$ DISPLAY= ./CarlaUE4.sh -opengl -carla-port=2000
```
It might take several seconds to finish launching the simulator.

2. Enter the root folder of this repo and run:
```
$ ./run_train_eval.sh
```
It will then connect to the CARLA simulator, collect driving data, then train and evaluate the agent. Main Parameters are stored in ```params.gin```.

3. Run `tensorboard --logdir logs` and open http://localhost:6006 to view training and evaluation information.

## Trouble Shootings
1. If out of system memory, change the parameter ```replay_buffer_capacity``` and ```initial_collect_steps``` of the function ```tran_eval``` smaller.

2. If out of CUDA memory, set parameter ```model_batch_size``` or ```sequence_length``` of the function ```tran_eval``` smaller.

## Citation
If you find this useful for your research, please use the following.

```
@article{chen2020perception,
  title={End-to-end Autonomous Driving Perception with Sequential Latent Representation Learning},
  author={Chen, Jianyu and Xu, Zhuo and Tomizuka, Masayoshi},
  journal={arXiv preprint arXiv:2003.12464},
  year={2020}
}
```

repository: zeyruca/detect-loc-map

repo_name: zeyruca/detect-loc-map


text:
## Helper functions for PHP frameworks

This package contains display formatting helpers for your php project.

### Usage

all functions are called as static functions. Some examples:
```php
Helper::formatDate($date);
Helper::isJson($json_string);
Helper::cast($object, $to_class_name);
Helper::toBase64($filename);
Helper::timeSince($date);
Helper::truncate($really_long_string);
Helper::mime($file_extension);
Helper::checkForFolder($folder_path);
Helper::is_serialized($string_to_check);
Helper::maxFileUploadSize();
Helper::hex2rgb($hexadecimal_string);
```

## Installation

### Laravel 5.x:

After updating composer, add the ServiceProvider to the providers array in config/app.php

    Hansvn\Helper\ServiceProvider::class,

You can optionally use the facade for shorter code. Add this to your facades:

    'Helper' => Hansvn\Helper\Facade::class

### Lumen:

After updating composer add the following lines to register provider in `bootstrap/app.php`

  ```
  $app->register(\Hansvn\Helper\ServiceProvider::class);
  ```

To change the configuration, copy the config file to your config folder and enable it in `bootstrap/app.php`:

  ```
  $app->configure('helper');
  ```

### Configuration
The defaults configuration settings are set in `config/helper.php`. Copy this file to your own config directory to modify the values. You can publish the config using this command:

    php artisan vendor:publish --tag=config --provider="Hansvn\Helper\ServiceProvider"

### Functions

There are serveral functions in this package (represented with the parameters of the functions definition):

* formatDate: function to format a date
  * `formatDate($date, $format = null)`
* isJson: check if a given string is json
  * `isJson($string)`
* cast: cast object to an(other) class
  * `cast($obj, $to_class)`
* toBase64: base64 encode files
  * `toBase64($directory, $file = null, $with_mime = false)`
* timeSince: display the difference in time in a human readable form
  * `timeSince($date, $now = null)`
* truncate: cut a text to specified length and add three dots ('...') at the and of the string
  * `truncate($text, $length = 100, $options = array())`
* mime: Get the mime type from file extension
  * `mime($extension, $default = 'application/octet-stream')`
* checkForFolder: Check if a folder exists and create if not exists
  * `checkForFolder($folder, $permissions = 0775)`
* is_serialized: Check if a string is serialized
  * `is_serialized($string)`
* maxFileUploadSize: Get the maximum file upload size (in MB) allowed by the sever
  * `maxFileUploadSize()`
* hex2rgb: Convert a hexadecimal color to their rgb values
  * `hex2rgb($hex)`

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

repository: hansvn/laravel-helpers

repo_name: hansvn/laravel-helpers


text:
# Changelog

## v2.0.0

### Breaking Changes

* Removed support for Node 4
* Removed callback interface
* Changed counter method interfaces from optional arguments to an options argument, where applicable:
  * `incr` receives an option object with the `eventObj` as a key.
  * `incrby` same as `incr` on the last argument.
  * `count` receives all previous arguments as a single option object.
  * `countRange` still gets `timeGranularity` as a first argument, but range dates are passed on a single second argument, and the `eventObj` is passed within an optional third argument object.
  * `top` receives all previous arguments as a single option object.
  * `topRange` same as `countRange` for range dates, and all arguments go onto the last optional argument.
  * `trimEvents` same as `count`.
  * `zero` same as `incr`.

### Other Changes

* Changed linting tools and configs

repository: getconversio/redis-metrics

repo_name: getconversio/redis-metrics


text:
# GroceryShare
Covid-19 Inspired Android App to help folks who can't leave their homes get groceries from family, friends, and neighbors who would like to shop for them.

## Table of Contents
- [Demo](#demo)
- [Setup](#setup)
- [Features](#features)
- [Team](#team)
- [License](#license)

## Demo
[![GroceryShare Demo](https://github.com/masher1/GroceryShare/blob/malkiel/app/src/img/SocialScreen.png)](https://www.youtube.com/watch?v=71_3D9gpscU "GroceryShare Demo")

## Setup
- Install **[Android Studio](https://developer.android.com/studio)**
- Clone this repo to your local machine using: https://github.com/masher1/GroceryShare.git
- Import the root folder of the project into Android Studio and wait for all the processes to finish in the bottom right corner.
- Build project Gradle
![Setup Image1](https://github.com/masher1/GroceryShare/blob/master/app/src/img/Instructions%20pic%201.png)
- In the Project window, right-click a testable item and select either Run filename or Debug filename. Android Studio creates a temporary run/debug configuration and launches your app.
- Select Save from the Select Run/Debug Configuration drop-down list in the toolbar. If you do not see the toolbar, select View > Toolbar.
![Save the configuration](./app/src/img/rundebug-saveconfiguration_2x.png)
- Open AVD manager and press "Create Virtual Device..."
![Setup Image2](https://github.com/masher1/GroceryShare/blob/master/app/src/img/Instruction%20pic%202.png)
![Setup Image3](https://github.com/masher1/GroceryShare/blob/master/app/src/img/Instruction%20pic%203.png)
- Choose a phone device of your choice (most of the testing was done on a Pixel 2)
![Setup Image4](https://github.com/masher1/GroceryShare/blob/master/app/src/img/Instruction%20pic%204.png)
- Follow the AVD wizard, ensuring that System Image has an API of 29 or higher. Press finish once the wizard is complete.
![Setup Image5](https://github.com/masher1/GroceryShare/blob/master/app/src/img/Instruction%20pic%205.png)
- Once the new emulator has been installed, run the project with the emulator.
![Setup Image6](https://github.com/masher1/GroceryShare/blob/master/app/src/img/Instruction%20pic%206.png)
- Once the project has been built and installed onto the phone, the app will be fully functional for use.
![Setup Image7](https://github.com/masher1/GroceryShare/blob/master/app/src/img/Instruction%20pic%207.png)

### Note:
- We used Firebase's Realtime Database, Authentication, and Storage tools to build our application. Find out more about the tools we used **[here](https://firebase.google.com/)**
- We also utilized OneSignal to roll out notifications to users when certain trigers occured. Find out more about OneSignal **[here](https://app.onesignal.com/)**

## Features

A new way for people in high-risk groups (immunocompromised, elderly, etc.) to receive their groceries. Order yourself, or order on behalf of a family member. Alternately, help a neighbor, or member of your community out by being a volunteer shopper.

### For People Ordering Groceries:
- Create your shopping list, customize the quantity, preferred brand, and store name
- A volunteer shopper in your area will pick your order, upload a receipt with an order total, and drop off your groceries
- You can pay for just the cost of the groceries, or you can tip your shopper.
- Use your shopper’s phone number to communicate any clarifications or issues.

- Communicate with your shopper via text to ensure a contactless delivery
- View your order requests and past orders at any time
- Fill out a complaint form in the app for any issues with the app or shopper
- Update your personal information as necessary in settings or when you create an order

### For People Buying And Delivering Groceries:
- Pick an order after viewing the shopping list, rating of the requester, distance from your address, preferred store, and preferred payment method
- Use the shopper’s phone number for any clarifications or issues
- Upload the receipt and order total, and get paid for the cost of groceries by the requester
- While buying and delivering is a volunteer service, a requester may tip you should they want to
- Communicate with the requester via text to arrange the contactless delivery
- View your past orders at any time
- Fill out a complaint form in the app for any issues with the app or shopper
- Update your personal information in settings as necessary

## Team

| **Malkiel Asher** | **Celeste Lemus** | **Fiona Powers Beggs** | **John Sobieski** |
| :---: |:---: | :---: | :---: |
| [![Malkiel Asher](https://avatars2.githubusercontent.com/u/44737740?s=60&v=4s=200)](https://malkielasher.com) | [![Celeste Lemus](https://avatars0.githubusercontent.com/u/47994727?s=460&v=4&s=200)](https://www.linkedin.com/in/celeste-lemus-806083195/) | [![Fiona Powers Beggs](https://avatars3.githubusercontent.com/u/59042926?s=460&v=4&s=200)](https://www.linkedin.com/in/fiona-powers-beggs-518a21170/) | [![John Sobieski](https://avatars0.githubusercontent.com/u/35733259?s=460&v=4&s=200)](https://www.linkedin.com/in/john-sobieski-a9811b195/)
| `https://github.com/masher1` | `https://github.com/clemus55` | `https://github.com/fcpowe` | `https://github.com/jfsobieski` |

---

## License
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)

- **[Privacy Policy](https://github.com/masher1/GroceryShare/blob/malkiel/app/src/img/PrivacyPolicy.txt)**
- **[MIT license](http://opensource.org/licenses/mit-license.php)**
- Copyright 2020


text:
# Nuxeo Docker Image

Nuxeo provides a ready to use Docker image that is pushed to our Docker registry. To pull the image, run:

```bash
docker pull DOCKER_REGISTRY/nuxeo:TAG
```

## Disclaimer

This Docker image doesn't aim to replace the [Nuxeo Docker official image](https://hub.docker.com/_/nuxeo/). It implements a different approach to try having an immutable image configured at build time instead of runtime.

## Nuxeo Image

Based on CentOS 7, it includes:

- OpenJDK.
- A bare Nuxeo server without any package installed.
- Some basic Open Source converters, e.g.: ImageMagick, LibreOffice.
- A `nuxeo` user with the `900` fixed UID.
- The directories required to have the Nuxeo configuration, data and logs outside of the server directory, with appropriate permissions.
- An entrypoint script to configure the server.
- The default recommended volumes.
- The environment variables required by the server, typically `NUXEO_HOME` and `NUXEO_CONF`.
- The exposed port `8080`.

## Build the Image

It requires to install [Docker](https://docs.docker.com/install/).

There are several ways to build the image, depending on the context:

- For a local build, use [Maven](#with-maven).
- For a pipeline running in Jenkins on Kubernetes, use [Skaffold](#with-skaffold).
- In any case, you can use [Docker](#with-docker).

### With Maven

To build the `nuxeo/nuxeo` image locally, run:

```bash
mvn -nsu install
```

### With Skaffold

We use Skaffold to build the images as part of the [nuxeo](http://jenkins.platform.dev.nuxeo.com/job/nuxeo/job/nuxeo/) pipeline in our Jenkins CI/CD platform.

This requires to:

- Install [Skaffold](https://skaffold.dev/docs/getting-started/#installing-skaffold).
- Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/).
- Configure `kubectl` to connect to a Kubernetes cluster.

It also requires the following environment variables:

- `DOCKER_REGISTRY`: the Docker registry to push the images to.
- `VERSION`: the image tag, for instance `latest`.

To build the `nuxeo/nuxeo` image with Skaffold, you first need to fetch the Nuxeo server ZIP file and make it available for the Docker build with Maven:

```bash
mvn -nsu process-resources
```

Then, from the root directory, run:

```bash
skaffold build -f docker/skaffold.yaml
```

### With Docker

To build the `nuxeo/nuxeo` image with Docker, you first need to fetch the Nuxeo server ZIP file and make it available for the Docker build with Maven:

```bash
mvn -nsu process-resources
```

Then, run:

```bash
docker build -t nuxeo/nuxeo:latest .
```

## Run the Image

To run a container from the `nuxeo/nuxeo` image built locally, run:

```bash
docker run -it -p 8080:8080 nuxeo/nuxeo:latest
```

To pull the `nuxeo/nuxeo` image from our Docker regsitry and run a container from it, run:

```bash
docker run -it -p 8080:8080 DOCKER_REGISTRY/nuxeo/nuxeo:latest
```

## Inspect an Image

To inspect the different layers included in an image, you can run for instance:

```bash
docker history nuxeo/nuxeo:latest
```

The [dive](https://github.com/wagoodman/dive) tool is also very good for exploring an image, its layer contents and discovering ways to shrink the image size:

```bash
dive nuxeo/nuxeo:latest
```

## Configure the Image at Runtime

Though we try to have immutable images configured at build time, in some cases it makes sense to configure a container at runtime. This typically applies to the address and credentials of each back-end store (database, Elasticsearch, S3, etc.) that are specific to a given deployment: development, staging, production, etc.

### Configuration Properties

To add some configuration properties when running a container from a Nuxeo image, you can mount property files as volumes into the `/etc/nuxeo/conf.d` directory of the container. Each property file will be appended to `nuxeo.conf` ordered by filename during startup.

For instance, to append the following `postgresql.conf` file to `nuxeo.conf`:

```Java Properties
nuxeo.db.name=nuxeo
nuxeo.db.user=nuxeo
nuxeo.db.password=nuxeo
nuxeo.db.host=localhost
nuxeo.db.port=5432
```

you can run:

```bash
docker run -it -p 8080:8080 -v /path/to/postgresql.conf:/etc/nuxeo/conf.d/postgresql.conf nuxeo/nuxeo:latest
```

### Environment Variables

Currently, these are the environment variables that are taken into account by a Nuxeo image:

- `JAVA_OPTS`
- `NUXEO_CLID`
- `NUXEO_CONNECT_URL`
- `NUXEO_PACKAGES`

Later on, with [NXP-28191](https://jira.nuxeo.com/browse/NXP-28191), we should be able to configure any Nuxeo property as an environment variable passed to the container.

#### JAVA_OPTS

The value of `JAVA_OPTS` is appended to the `JAVA_OPTS` property defined in `nuxeo.conf` at startup.

For instance, to make the Nuxeo Launcher display the JVM settings in the console, run:

```bash
docker run -it -p 8080:8080 -e JAVA_OPTS=-XshowSettings:vm nuxeo/nuxeo:latest
```

#### NUXEO_CLID

The value of `NUXEO_CLID` is copied to `/var/lib/nuxeo/instance.clid` at startup.

For instance, to run a container with a registered Nuxeo instance:

```bash
docker run -it -p 8080:8080 -e NUXEO_CLID=<NUXEO_CLID> nuxeo/nuxeo:latest
```

#### NUXEO_CONNECT_URL

`NUXEO_CONNECT_URL` allows to override the default Connect URL at startup.

For instance, to run a container with another Connect URL than the default one:

```bash
docker run -it -p 8080:8080 -e NUXEO_CONNECT_URL=<NUXEO_CONNECT_URL> nuxeo/nuxeo:latest
```

#### NUXEO_PACKAGES

`NUXEO_PACKAGES` allows to define a space separated list of Nuxeo packages to install at startup.

For instance, to run a container with the `nuxeo-web-ui` and `nuxeo-drive` packages installed:

```bash
docker run -it -p 8080:8080 -e NUXEO_CLID=<NUXEO_CLID> -e NUXEO_PACKAGES="nuxeo-web-ui nuxeo-drive" nuxeo/nuxeo:latest
```

repository: mehboob-tx/nuxeo

repo_name: mehboob-tx/nuxeo