text:
web-component-polyomino
=======================

A web component for creating, editing, or displaying polyominos (i.e. generalizations of tetris pieces).
Useful for games, applications, or solvers that require the user to specify certain polyominos.

[Install from npm](https://www.npmjs.com/package/web-component-polyomino).

See [an example codepen demo](https://codepen.io/cemulate/pen/dExpJw) or a [project using this component](https://cemulate.github.io/polyomino-solver/).

## Usage

Import the library in your main entrypoint:

```
import 'web-component-polyomino';
```

Or with a script tag (using unpkg), as:
```
<script<EMAIL_ADDRESS>```

The custom element is now available and may be used in HTML directly as with:
```
<polyomino-control size=10 mode="create" value="[[0,0],[0,1],[1,0],[1,1]]"></polyomino-control>
```

Attributes on `polyomino-control` elements are as follows:

* `size`: The size of the (square) editing or display grid.
Has nothing to do with the style/CSS dimensions of the element, but only the logical polyomino grid.
* `value`: The polyomino (or, in `display-multiple` mode only, a list of polyominos) to display, represented as a list of coordinates `[[x1, y1], [x2, y2], ...]`
* `mode`: One of three string values:
    - `create`:
    The standard mode.
    Background grid cells are white, and filled-in cells representing the object polyomino are a chosen active color (`--create-color`)
    - `create-region`:
    Functionally equivalent to `create`, but with an inverse UI:
    The background is a blank canvas while only the filled in cells are visible and white.
    Intended for creating the destination areas in polyomino fitting problems, for example.
    - `display`:
    Editing is disabled, and background/blank grid cells are not displayed.
    Intended for displaying static polyominos.
    - `display-multiple`:
    In this mode, `value` takes a *list* of polyominos, all of which will be displayed.
    The first of the list is treated as a "backdrop" and will be displayed in white, while the rest will be displayed in differing colors on top.

The component respects the following CSS variables, which can be used to style it:

* `--cell-color`: The color of filled in cells during `create` and `display` mode.
Default `cyan`.

repository: cemulate/web-component-polyomino

repo_name: cemulate/web-component-polyomino


text:
# FCTSFN

This repository includes the [caffe][1] model and codes for the following paper on interactive image segmentation:

Y.Hu, A. Soltoggio, R. Lock and S. Carter. A Fully Convolutional Two-Stream Fusion Network for Interactive Image Segmentation. Neural Networks, vol.109, pp.31-42, 2019.

The codes are tested with Python 2.7 and Ubuntu 16.04.

## Example run

Run `run_example.py` on an example to use the model file and pre-trained weights.

## Model training

See `./data/example_data/voc` an example of the way to organize training data (note that this is not the full data; see above paper on more detailed information on the data used in the paper).

Run `solve_32s.py`, `solve_16s.py`, `solve_8s.py` for the training of TSLFN subnet in FCTSFN from stride 32 to stride 8.

Run `solve_fctsfn.py` for the training of MSRN subnet in FCTSFN.

## Acknowledgement

Part of codes are modified from the codes in [FCN][2] repository.

[1]:https://github.com/BVLC/caffe "caffe"

[2]:https://github.com/shelhamer/fcn.berkeleyvision.org "FCN"

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# esx_trunks_inventory
Inventario para carros
My Discord:https://discord.gg/qmFKfcC
# Instalaçao PT
# Clica E para abrir a bagageira
# Esta Bagageira nao tem bug de Multiplicaçao

Coloca na Resource/[esx]

Executa a SQL

Start esx_trunks_inventory na server.cfg

# EN installation
# Click E to open the luggage compartment
# This luggage has no multiplication bug

Place in the Resource/[esx]

Execute  SQL

Start esx_trunks_inventory on server.cfg

repository: sdiaz/Server

repo_name: sdiaz/Server


text:
# arduino-hifi

A small HiFi system based on Arduino.

External libraries used in this project:
 * [my forked new-liquidcrystal](https://bitbucket.org/vtech/new-liquidcrystal/branch/read_data_%2379) library with additional improvement
 * [BigCrystal](https://github.com/gregington/BigCrystal)
 * [my forked PT2314](https://github.com/wmarkow/PT2314) library with some additional fixes and improvements
 * [my forked Radio](https://github.com/wmarkow/Radio) library with some fixes
 * [greyltc's forked Arduino core](https://github.com/greyltc/ArduinoCore-avr/tree/issue%2342) internal **Wire** library with the fix for [ArduinoCore-avr/issues/42](https://github.com/arduino/ArduinoCore-avr/issues/42)

license: MIT

repository: wmarkow/arduino-hifi

repo_name: wmarkow/arduino-hifi


text:
# finagled-batch

Concept:  You can batch requests to a single endpoint and asynchronously reduce these to a single response.

Thinking aloud:  This seems to be heading very much into the direction of map <-> reduce

## Get Started

```BASH
git clone git://github.com/SamGiles/finagled-batch.git
cd finagled-batch

# Build the JAR and writes out run.sh
./quick_start.sh

# Runs the API batching endpoint on port 8081
./run.sh

# Sends a request to facebook.com and a twitter.com test endpoint
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '[{"url": "http://facebook.com/index.php", "method": "GET", "headers": {"Accept-Language": "en_us"}, "body": ""}, {"url": "https://api.twitter.com/1/help/test.json", "method": "GET", "headers":{}, "body": ""}]' localhost:8081
```

## How it works

This is similar concept to Facebook's API batching:  https://developers.facebook.com/docs/reference/api/batch

You can send off multiple requests as a single JSON payload and receive a JSON array of responses to each request.

```JSON
[
        {
                "url": "http:\/\/facebook.com\/index.php",
                "method": "GET",
                "headers": {
                        "Accept-Language": "en_us"
                },
                "body": ""
        },
        {
                "url": "https:\/\/api.twitter.com\/1\/help\/test.json",
                "method": "GET",
                "headers": {},
                "body": ""
        }
]
```

Response

```JSON
[
        {
                "status": 302,
                "headers": {
                        "Location": "https:\/\/<IP_ADDRESS>\/index.php",
                        "Connection": "keep-alive",
                        "Content-Length": "0",
                        "X-FB-Debug": "*",
                        "Content-Type": "text\/html; charset=utf-8",
                        "Date": "Thu, 11 Apr 2013 17:34:32 GMT"
                },
                "body": ""
        },
        {
                "status": 200,
                "headers": {
                        "x-transaction": "f855ea94fa382521",
                        "etag": "\"72054d9a6fbdcc7df012e19f32345b65\"",
                        "expires": "Tue, 31 Mar 1981 05:00:00 GMT",
                        "server": "tfe",
                        "cache-control": "no-cache, no-store, must-revalidate, pre-check=0, post-check=0",
                        "x-transaction-mask": "a6183ffa5f8ca943ff1b53b5644ef114f5d00892",
                        "content-length": "4",
                        "last-modified": "Thu, 11 Apr 2013 17:34:32 GMT",
                        "date": "Thu, 11 Apr 2013 17:34:32 GMT",
                        "content-type": "application\/json; charset=utf-8",
                        "status": "200 OK",
                        "pragma": "no-cache",
                        "x-mid": "687960793640b4964f28bd58ff80dc81c1669bdf",
                        "set-cookie": "guest_id=; Domain=.twitter.com; Path=\/; Expires=Sat, 11-Apr-2015 17:34:32 UTC",
                        "x-frame-options": "SAMEORIGIN",
                        "x-runtime": "0.01271",
                        "vary": "Accept-Encoding"
                 },
                 "body": "\"ok\""
        }
]
```

repository: samgiles/finagled-batch

repo_name: samgiles/finagled-batch


text:
[![GoReportCard](http://goreportcard.com/badge/github.com/asticode/go-astideepspeech)](http://goreportcard.com/report/github.com/asticode/go-astideepspeech)
[![GoDoc](https://godoc.org/github.com/asticode/go-astideepspeech?status.svg)](https://godoc.org/github.com/asticode/go-astideepspeech)

Golang bindings for Mozilla's [DeepSpeech](https://github.com/mozilla/DeepSpeech) speech-to-text library.

As of now, `astideepspeech` is only compatible with version `v0.4.0` of `DeepSpeech`.

# Installation
## Install DeepSpeech

- fetch an uptodate `native_client.tar.xz` matching your system, from DeepSpeech's ["releases"](https://github.com/mozilla/DeepSpeech/releases/tag/v0.4.0)
- download `deepspeech.h` from https://github.com/mozilla/DeepSpeech/raw/v0.4.0/native_client/deepspeech.h
- extract/copy both to /tmp/ds/
- export CGO_LDFLAGS="-L/tmp/ds/"
- export CGO_CXXFLAGS="-I/tmp/ds/"
- export LD_LIBRARY_PATH=/tmp/ds/:$LD_LIBRARY_PATH

## Install astideepspeech

Run the following command:

    $ go get -u github.com/asticode/go-astideepspeech/...

# Example
## Get the pre-trained model

Run the following commands:

    $ mkdir /tmp/deepspeech
    $ cd /tmp/deepspeech
    $ wget https://github.com/mozilla/DeepSpeech/releases/download/v0.4.0/deepspeech-0.4.0-models.tar.gz
    $ tar xvfz deepspeech-0.4.0-models.tar.gz

## Get the audio files

Run the following commands:

    $ cd /tmp/deepspeech
    $ wget https://github.com/mozilla/DeepSpeech/releases/download/v0.4.0/audio-0.4.0.tar.gz
    $ tar xvfz audio-0.4.0.tar.gz

## Use the client

Run the following commands (make sure `$GOPATH/bin` is in your `$PATH`):

    $ cd /tmp/deepspeech
    $ deepspeech -model models/output_graph.pb -audio audio/2830-3980-0043.wav -alphabet models/alphabet.txt -lm models/lm.binary -trie models/trie

        Text: experience proves this

    $ deepspeech -model models/output_graph.pb -audio audio/4507-16021-0012.wav -alphabet models/alphabet.txt -lm models/lm.binary -trie models/trie

        Text: why should one halt on the way

    $ deepspeech -model models/output_graph.pb -audio audio/8455-210777-0068.wav -alphabet models/alphabet.txt -lm models/lm.binary -trie models/trie

        Text: your power is sufficient i said


text:
# BitRiot
Clone / re-implementation of the Amiga BugBomber game

![Screenshot](https://raw.github.com/VenKamikaze/BitRiot/master/doco/screenshots/BitRiot-1.png)

This game is a re-implementation of 'BugBomber' - a great Amiga game that is similar to Bomberman but with a twist of being able to spawn your own helper robots. I found the code for BitRiot when I was searching to see if anyone recreated bomberman. It was built by one guy as a university project and posted to a forum.

It was original built against the win32 API, and I figured I'd like to learn the difficulties in porting a game from win32 to something Linux native. I wasn't quite ready to jump into OpenGL / 3D APIs, so I took the approach of porting to SDL 1.2.x with normal software blitting.

I contacted the original author and they were happy for me to work on this code. When I asked about licencing they said they would have licensed it as something free "like Apache", hence the Apache Software License now added to the source code!

The game now works in Linux w/SDL 1.2.x, however may have some minor input issues which I haven't bothered to clean up.

There are two software tags:
* win32-v1
* sdl-v1.1

The master branch has the latest sdl-v1.1 code and is unlikely to advance as I lost interest in the project some time ago.

Things that I'd like to do, but likely won't ever find time for (in order of personal interest):

* Cleanups / fix up the input code a bit
* Port this to SDL2 (and I guess OpenGL)
* Write up some notes to explain the porting process to SDL2, as a quick 'n' dirty tutorial for others thinking of doing this for other games.
* Scaling / resolution options.
* Create a basic menu selection screen on startup to configure game parameters
* Handle controller input
* Network play (honestly, unless someone else did this I highly doubt I'd get around to even attempting)

If you'd ever like to work on this code, please fork it and file pull requests - I'd be glad to accept them.

Please note: If you'd found the original BitRiot release anywhere, you might notice the artwork in this one was different. This was only done out of safety (more like paranoia!) incase there were any concerns over the artwork included in the original release.

# Build

To build the game, first make sure you have the necessary dependencies installed on your system. The obvious ones that I can recall are SDL 1.2.x, SDL_mixer and SDL_ttf.

In the BitRiot directory, run 'make'
It should compile a 'BitRiot-dbg' file that you can run.

repository: Smeat/BitRiot

repo_name: Smeat/BitRiot


text:
# Analog Clock Reading

[![HitCount](http://hits.dwyl.io/ayan-b/Analog-Clock-Reading.svg)](http://hits.dwyl.io/ayan-b/Analog-Clock-Reading)

>A Simple Analog Clock Reading animation made using PIE library (based on THREE.js).

## Usage

First navigate to the Experiment directory and create a server. For example in python 3, you can create a server using the following command python -m http.server 8000.

Run localhost:8000 in your browser.

## Contributing

Spot a bug? Open up an issue! Thought of a cool feature? Make a pull request!

repository: ayan-b/Analog-Clock-Reading

gha_language: JavaScript

repo_name: ayan-b/Analog-Clock-Reading


text:
# fhash
__[fpm](https://github.com/fortran-lang/fpm) package implementing a hash table with support for generic keys and values.__

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![fpm test](https://github.com/LKedward/fhash/workflows/fpm%20test/badge.svg?branch=master&event=push)](https://github.com/LKedward/fhash/actions)
[![ford docs](https://img.shields.io/badge/FORD%20API%20Docs-Deployed-green)](https://lkedward.github.io/fhash/)

## fpm usage

To use *fhash* within your *fpm* project, add the following to your package manifest file (`fpm.toml`):

```toml
[dependencies]
fhash = { git = "https://github.com/LKedward/fhash.git" }
```

## Simple example: scalar intrinsics

The package provides a `fhash_tbl_t` type with `set` and `get` methods for storing and retrieving key-value pairs.
The `fhash_key` interface (aliased to `key` below) is used to define a valid key from different inputs.

```fortran
program fhash_demo1
  use fhash, only: fhash_tbl_t, key=>fhash_key
  implicit none
  type(fhash_tbl_t) :: tbl
  integer :: val

  call tbl%set(key('my_key_1'), value=10)
  call tbl%set(key('my_key_2'), value=1.0)
  call tbl%set(key(123456), value='a string value')
  call tbl%set(key([1,2,3,4,5]), value=.false.)

  call tbl%get(key('my_key_1'),val)

end program fhash_demo1
```

See the [Quickstart Guide](https://lkedward.github.io/fhash/page/index.html) for an explanation of this example and the API methods used.

## Advanced usage

- [More table methods](https://lkedward.github.io/fhash/page/1-methods-demo/index.html)
- [Storing custom derived types as values](https://lkedward.github.io/fhash/page/2-derived-type-demo/index.html)
- [Using custom derived types as keys](https://lkedward.github.io/fhash/page/3-custom-key-demo/index.html)

See <https://lkedward.github.io/fhash/> for the full API documentation.

repository: M-Badri/fhash

repo_name: M-Badri/fhash


text:
# Specifications for the Sinatra Assessment

Specs:
- [x] Use Sinatra to build the app
- [x] Use ActiveRecord for storing information in a database
- [x] Include more than one model class (list of model class names e.g. User, Post, Category)--used Volunteer, Opportunity, Success_Story
- [x] Include at least one has_many relationship (x has_many y e.g. User has_many Posts), volunteer has_many opportunities and success_stories. Both opportunities and success_stories belong_to a volunteer
- [x] Include user accounts- volunteers sign in and login in
- [x] Ensure that users can't modify content created by other users- only the owner of an opportunity or story can edit or delete it
- [x] Ensure that the belongs_to resource has routes for Creating, Reading, Updating and Destroying- opportunities and success_stories can be created, read, updated, and destroyed
- [x] Include user input validations- makes sure inputs aren't empty, requires specific fields
- [x] Display validation failures to user with error message (example form URL e.g. /posts/new)- flash messages that let you know if your username is already taken, that you successfully created, edited, or destroyed an opportunity or story
- [x] Your README.md includes a short description, install instructions, a contributors guide and a link to the license for your code

Confirm
- [x] You have a large number of small Git commits
- [x] Your commit messages are meaningful
- [x] You made the changes in a commit that relate to the commit message
- [x] You don't include changes in a commit that aren't related to the commit message

repository: jessiehuff/voluntell-sinatra-app

gha_language: Ruby

repo_name: jessiehuff/voluntell-sinatra-app


text:
---
id: typescript
title: "TypeScript"
---

This document note some need-to-know things for TypeScript User.

## Type Definition

Almin has built-in Type definition file(`.d.ts`).

If you want to use almin with TypeScript, you just install Almin.
Type definition file(`.d.ts`) will be loaded automatically.

## Payload

You can use abstract `Payload` class for creating own payload.
This `Payload` class pattern is simple in TypeScript.

Example: `StartLoadingUseCase`

`StartLoadingUseCase.ts`
```ts
import { Payload, UseCase } from "almin";
export class StartLoadingPayload implements Payload {
    type = "StartLoadingPayload";
}

export class StartLoadingUseCase extends UseCase {
    execute() {
        this.dispatch(new StartLoadingPayload());
    }
}
```

Also, you just use `instanceof` type-guard.

```ts
import { Payload, UseCase } from "almin";
import { StartLoadingPayload } from "./StartLoadingUseCase.ts";
export class ExampleStore extends Store {
    receivePayload(payload: any) {
        if(payload instanceof StartLoadingPayload){
            // payload is StartLoadingPayload
        }
    }
    // ...
}
```

### Further reading

- [Tackling State – Angular](https://vsavkin.com/managing-state-in-angular-2-applications-caf78d123d02)
- [Redux & Typescript typed Actions with less keystrokes](https://medium.com/@martin_hotell/redux-typescript-typed-actions-with-less-keystrokes-d984063901d)

## UseCase

You should use `executor` method instead of `execute` method.
Because, `executor` is type-safe method, but `execute` is not type-safe.

```ts
// OK
context.useCase(someUseCase).executor(useCase => useCase.execute(args))
```

```ts
// NG
context.useCase(someUseCase).execute(args);
```

This limitation come from TypeScript feature.
For more details, see following link.

- [TypeScript: improve UseCase#execute typing · Issue #107 · almin/almin](https://github.com/almin/almin/issues/107 "TypeScript: improve UseCase#execute typing · Issue #107 · almin/almin")

## Helper

- [almin/ddd-base: DDD base class library for JavaScript application.](https://github.com/almin/ddd-base "almin/ddd-base: DDD base class library for JavaScript application.")

## Examples

Almin + TypeScript real examples.

- [azu/faao: Faao is a GitHub issue/pull-request client on Electron.](https://github.com/azu/faao)
- [azu/irodr: RSS reader client like LDR for Inoreader.](https://github.com/azu/irodr)
- [proofdict/editor: Proofdict editor.](https://github.com/proofdict/editor)

repository: satoshicano/almin

gha_license_id: MIT

repo_name: satoshicano/almin


text:
---
layout: tutorials
title: Publish/Subscribe
summary: Demonstrates the publish/subscribe message exchange pattern.
icon: I_dev_P+S.svg
links:
    - label: TopicPublisher.java
      link: /blob/master/src/main/java/com/solace/samples/TopicPublisher.java
    - label: TopicSubscriber.java
      link: //blob/master/src/main/java/com/solace/samples/TopicSubscriber.java
    - label: feedback
      link: https://github.com/SolaceDev/solace-dev-tutorials/blob/master/src/pages/tutorials/java-amqp-qpid-jms1/publish-subscribe.md
---

This tutorial will show you to how to connect a Apache Qpid JMS 1.1 client to a Solace Message Router using AMQP, add a topic subscription and publish a message matching this topic subscription. This is the publish/subscribe message exchange pattern as illustrated here:

At the end, this tutorial walks through downloading and running the sample from source.

This tutorial focuses on using a non-Solace JMS API implementation. For using the Solace JMS API see [Solace Getting Started JMS Tutorials](../../solace-samples-jms/).

## Assumptions

This tutorial assumes the following:

*   You are familiar with Solace [core concepts](https://docs.solace.com/PubSub-Basics/Core-Concepts.htm).
*   You have access to Solace messaging with the following configuration details:
    *   Connectivity information for a Solace message-VPN
    *   Enabled client username and password

One simple way to get access to Solace messaging quickly is to create a messaging service in Solace Cloud [as outlined here](https://solace.com/cloud/). You can find other ways to get access to Solace messaging below.

## Goals

The goal of this tutorial is to demonstrate how to use a Apache Qpid JMS 1.1 over AMQP using Solace messaging. This tutorial will show you:

1. How to build and send a message on a topic
2. How to subscribe to a topic and receive a message

`markdown:solaceMessaging-part1.md`
![Screenshot: Messaging Connectivity Information](../../../images/screenshots/connectivity-info-amqp.png)
`markdown:solaceMessaging-part2.md`
`markdown:jmsApi.md`

## Java Messaging Service (JMS) Introduction

JMS is a standard API for sending and receiving messages. As such, in addition to information provided on the Solace developer portal, you may also look at some external sources for more details about JMS. The following are good places to start:

1. [https://docs.oracle.com/javaee/7/api/javax/jms/package-summary.html](https://docs.oracle.com/javaee/7/api/javax/jms/package-summary.html)
2. [https://en.wikipedia.org/wiki/Java_Message_Service](https://en.wikipedia.org/wiki/Java_Message_Service)
3. [https://docs.oracle.com/javaee/7/tutorial/partmessaging.htm#GFIRP3](https://docs.oracle.com/javaee/7/tutorial/partmessaging.htm#GFIRP3)

The last (Oracle docs) link points you to the JEE official tutorials which provide a good introduction to JMS.

This tutorial focuses on using [JMS 1.1 (April 12, 2002)](https://download.oracle.com/otndocs/jcp/7195-jms-1.1-fr-spec-oth-JSpec/), for [JMS 2.0 (May 21, 2013)](https://download.oracle.com/otndocs/jcp/jms-2_0-fr-spec/) see [Solace Getting Started AMQP JMS 2.0 Tutorials](../../solace-samples-amqp-qpid-jms2/).

## Connecting to Solace Messaging

In order to send or receive messages, an application must start a JMS connection.

There are three parameters for establishing the JMS connection: the Solace messaging host name with the AMQP service port number, the client username and the optional password.

*TopicPublisher.java/TopicSubscriber.java*
```java
ConnectionFactory connectionFactory = new JmsConnectionFactory(solaceUsername, solacePassword, solaceHost);
Connection connection = connectionFactory.createConnection();
```

Next, a session needs to be created. The session will be non-transacted using the acknowledge mode that automatically acknowledges a client's receipt of a message.

*TopicPublisher.java/TopicSubscriber.java*
```java
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
```

At this point the application is connected to Solace messaging and ready to publish messages.

## Publishing messages

In order to publish a message to a topic a JMS message *MessageProducer* needs to be created.

![Diagram: Sending a Persistent Message to a Queue](../../../images/diagrams/persistence-with-queues-details-2.png)

*TopicPublisher.java*
```java
final String TOPIC_NAME = "T/GettingStarted/pubsub";
Topic topic = session.createTopic(TOPIC_NAME);
MessageProducer messageProducer = session.createProducer(null);
```

Now we can publish the message.

*TopicPublisher.java*
```java
TextMessage message = session.createTextMessage("Hello world!");
messageProducer.send(topic, message,
        DeliveryMode.NON_PERSISTENT,
        Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
```

Now if you execute the `TopicPublisher.java` program it will successfully publish a message, but another application is required to receive it.

## Receiving messages

In order to receive a message from a topic a JMS *MessageConsumer* needs to be created.

![Diagram: Receiving a Persistent Message from a Queue](../../../images/diagrams/persistence-with-queues-details-1.png)

*TopicSubscriber.java*
```java
final String TOPIC_NAME = "T/GettingStarted/pubsub";
Topic topic = session.createTopic(TOPIC_NAME);
MessageConsumer messageConsumer = session.createConsumer(topic);
```

We will be using the anonymous inner class for receiving messages asynchronously.

*TopicSubscriber.java*
```java
messageConsumer.setMessageListener(new MessageListener() {
    @Override
    public void onMessage(Message message) {
        try {
            if (message instanceof TextMessage) {
                System.out.printf("TextMessage received: '%s'%n", ((TextMessage) message).getText());
            } else {
                System.out.println("Message received.");
            }
            System.out.printf("Message Content:%n%s%n", message.toString());
            latch.countDown(); // unblock the main thread
        } catch (Exception ex) {
            System.out.println("Error processing incoming message.");
            ex.printStackTrace();
        }
    }
});
connection.start();
latch.await();
```

If you execute the `TopicSubscriber.java` program, it will block at the `latch.await()` call until a message is received. Now if you execute the `TopicPublisher.java` program that publishes a message, the `TopicSubscriber.java` program will resume and print out the received message.

## Summary

Combining the example source code shown above results in the following source code files:

* [TopicPublisher.java](https://github.com/SolaceSamples/solace-samples-amqp-qpid-jms1/blob/master/src/main/java/com/solace/samples/TopicPublisher.java)
* [TopicSubscriber.java](https://github.com/SolaceSamples/solace-samples-amqp-qpid-jms1//blob/master/src/main/java/com/solace/samples/TopicSubscriber.java)

### Getting the Source

Clone the GitHub repository containing the Solace samples.

```
git clone https://github.com/SolaceSamples/solace-samples-amqp-qpid-jms1
cd solace-samples-amqp-qpid-jms1
```

### Building

You can build and run both example files directly from Eclipse or with Gradle.

```shell-session
./gradlew assemble
```

The examples can be run as:

```shell-session
cd build/staged/bin
./topicSubscriber amqp://<HOST:AMQP_PORT> <USERNAME> <PASSWORD>
./topicPublisher amqp://<HOST:AMQP_PORT> <USERNAME> <PASSWORD>
```

### Sample Output

First start the `TopicSubscriber` so that it is up and waiting for published messages. You can start multiple instances of this application, and all of them will receive published messages.

```shell-session
$ topicSubscriber amqp://<HOST:AMQP_PORT> <USERNAME> <PASSWORD>
TopicSubscriber is connecting to Solace messaging at amqp://<HOST:AMQP_PORT>...
Connected to the Solace messaging.
Awaiting message...
```

Then you can start the `TopicPublisher` to publish a message.
```shell-session
$ topicPublisher amqp://<HOST:AMQP_PORT> <USERNAME> <PASSWORD>
TopicPublisher is connecting to Solace messaging amqp://<HOST:AMQP_PORT>...
Connected to the Solace messaging.
Sending message 'Hello world!' to topic 'T/GettingStarted/pubsub'...
Sent successfully. Exiting...
```

Notice how the published message is received by the `TopicSubscriber`.

```shell-session
Awaiting message...
TextMessage received: 'Hello world!'
Message Content:
JmsTextMessage { org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade@18c1752a }
```

With that you now know how to use the Apache Qpid JMS 1.1 over AMQP using Solace messaging to implement the publish/subscribe message exchange pattern.


text:
# qrcodegenerator
An QR code generator application written in c++11. I made it for homework of a university subject called "C11 and C++11 Programming" and it was a individual task choosen by myself.

## install
The generator module placed in the qr folder could be used without any external library, the only used library called simple_svg_1.0.0 is directly attached (as source) to the project.

There is also a UI module developed in Qt5, where I need to use some extra qt packages, called Svg, it should be installed before compiling this source.

On Ubuntu 14.04, you can install Qt from with a command as follows:
`sudo apt-get install qt5-default qttools5-dbg qttools5-dev qttools5-doc qttools5-dev-tools libqt5svg5 libqt5svg5-dev build-essential`

Also, I'm created a cmakelist file for compiling code using cmake. On Unix systems, the compiling needs only 2 command:

`cmake .`

`make`

repository: awfeequdng/qrcodegenerator

repo_name: awfeequdng/qrcodegenerator


text:
# Clicky-Memory-Game

## Summary

A memory game built using Reaact components. This application should keep track of the user's score. The user's score is incremented when clicking an image for the first time. The user's score should be reset to 0 if they click the same image more than once.

## Installation
- install: `npm create-react-app app-name`

## License

[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)

## Deployment
 - Heroku

## Authors
Travis Stewart

## License & copyright

Licensed under the [MIT License](LICENSE).

repository: travisstew/Clicky-Memory-Game

path: /README 2.md

filename: README 2.md

repo_name: travisstew/Clicky-Memory-Game


text:
### Airdrop in Starcoin

Airdrop STC to starcoin users.

```shell
./target/debug/airdrop -i amount.csv
```

amount.csv should be in format: `address,amount`. for example:

```text
0x00009cc5c3d56231df33dd74cc4780f2,1000
0x0026241a238ede23f1d9e18421c0185d,1000
0x00342e46b92e499108f2e5fbd3e44227,999
0x0034914ea62e78ac86ddf99f9240c7c5,99
```

repository: starcoinorg/starcoin

gha_language: Rust

repo_name: starcoinorg/starcoin


text:
# Pseudomycena capillaris (Schumach.) Cejp, 1930 SPECIES

#### Status
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Publ. Fac. Sci. Univ. Charles 104: 141 (1930)

#### Original name
Agaricus capillaris Schumach., 1803

### Remarks
null

repository: mdoering/backbone

path: /life/Fungi/Basidiomycota/Agaricomycetes/Agaricales/Mycenaceae/Mycena/Mycena capillaris/ Syn. Pseudomycena capillaris/README.md

repo_name: mdoering/backbone


text:
Administration utilities authored and/or packaged for [Homebrew](https://brew.sh) by Donald Sebastian Leung, for both macOS and Linux where applicable.

## Installing

Add the tap as follows:

```bash
$ brew tap DonaldKellett/admin
```

Then search for and install formulae as usual.

## Contributing

Issue reports for existing formulae are welcome. See also [issues labelled with "help wanted"](https://github.com/DonaldKellett/homebrew-admin/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) to see how you could contribute to resolving them. Pull requests addressing bugs in existing formulae are generally welcome, but remember to keep in mind that formulae should work (or fail gracefully) on both macOS and Linux platforms. If in doubt, open an issue to seek for approval from the tap maintainer.

For Linux, the reference distribution is Ubuntu 20.04 LTS.

## License

**Important! The license in this repo pertains only to the formulae themselves. The software installed by each formula retain their original licenses.**

[MIT](./LICENSE)

repository: DonaldKellett/homebrew-admin

branch_name: refs/heads/main

repo_name: DonaldKellett/homebrew-admin


text:
---
date: 2016-09-13T09:00:00+00:00
title: Get started
url: /why-use-waziup/get-started
---

## Try Waziup
To make the most of your 'my first Waziup' experience, we suggest you start with the [Waziup Hello World app](documentation/installation/hello-world/).

{{< note title="What next?" >}}
* Try the [Hello World app](documentation/installation/hello-world/) and [tutorials](documentation/tutorials)
* Read about the [Waziup architecture](documentation/how-waziup-works/architecture-and-components)
* Check the [installation docs](documentation/installation/)
{{< /note >}}

path: /content/why use waziup/get-started.md


text:
##Suggested readings:

Ingalls 7.1 and 7.2

[Original paper on the Collins toggle switch: Gardner 2000]()

## Additional works cited:

Classic paper on bistability in the lac operon: [Novick and Weiner 1957](http://www.pnas.org/content/43/7/553)

(Relatively) more recent theoretical treatment of bistability in the lac operon: [Ozbudak 2004](http://www.nature.com/nature/journal/v427/n6976/abs/nature02298.html)

url: https://raw.githubusercontent.com/mozartvn/intro-systems-biology/95ad58ec50ef79d084e71f4380fbfbf5e1603836/lectures/Lecture 11 - Genetic Switches, Natural and Engineered/lecture 11 suggested reading.md

repository: mozartvn/intro-systems-biology

filename: lecture 11 suggested reading.md

repo_name: mozartvn/intro-systems-biology


text:
# Installation on *nix

After downloading phar file, move it to your `PATH`, so you can access it globally.

```sh
$ mv apigen.phar /usr/local/bin/apigen
```

Now you can simply run `apigen` instead of `php apigen.phar`.

# Installation on Windows

Move phar file to your `PATH` directory.

```sh
C:\Users\username>cd C:\bin
```

Create a new `apigen.bat` file alongside `apigen.phar`:

```sh
C:\bin>echo @php "%~dp0apigen.phar" %*>apigen.bat
```

Close your current terminal. Test usage with a new terminal:

```sh
C:\Users\username>apigen
ApiGen version v4.0.0
```

repository: chengky/apigen

repo_name: chengky/apigen


text:
---
layout: post
title: Overlord
categories: robots
excerpt:
tags: [robots, OpenCV, Python]
color: "#152a55"
image:
  feature: overlord.jpg
  teaser: overlord.jpg
  thumb:
comments: true
---

Originally posted on [www.letsmakerobots.com](www.letsmakerobots.com)

**NOTE: Try as I might, guys, I can't get the numbers to line up in my HTML version of my code.  Instead, you might just load it into Geany or Notepad+ to follow along, since I indicated things by the line number.  I'm sorry, I'm out of patience for it.**

**These are redneck instructions on how to control a robot with a static webcam for under 50 USD.**

I'm a robot builder and I got tired of seeing universities play robot soccer or something with computer vision guiding their players, and no matter how much I begged, darn Ivy Leagues wouldn't share.

So, I wrote my own.  And while I did it, I swore I'd try to help _anyone_ trying something similar.

![](/images/FQNP4DNHMVJHBJQ.MEDIUM.jpg)

[Overlord and Dot Muncher](http://www.youtube.com/watch?v=uqnNYnS66do)

So, here's an overview of how the code works:

[](http://www.youtube.com/watch?feature=player_embedded&v=WyMZ6iGWpj4)

[Red Hatted Robot](http://www.youtube.com/watch?feature=player_embedded&v=WyMZ6iGWpj4)

1.  Webcam sends images of its field-of-view.
2.  OpenCV looks for the largest red blob.
3.  It begins tracking the red blob's X, Y.
4.  The PC averages these X, Y positions for around 150 camera frames.
5.  If the blob hasn't moved much, the PC assumes the red blob is the robot.
6.  The PC gets frisky and gives our robot a random target within the webcam's field-of-view.
7.  The PC calculates the angle between the bot and the target.
8. **Meanwhile,** the robot's microcontroller is taking readings from a [magnetometer](https://www.loveelectronics.co.uk/Tutorials/8/hmc5883l-tutorial-and-arduino-library) on the robot.
9.  The robot, with a one time human calibration, translates true North to "video-game north," aka, top of PC's screen.
10.  The microcontroller transmits this code to the PC.
11.  The PC compares the angle of the bot from the target with the robots angle.
12.  The PC sends a code to the bot telling it to turn left, right, or move forward (closer to the target).
13.  When the robot has made it within an acceptable distance from the target he "Munches the Dot."
14.  A new random dot appears. Rinse repeat. (For real though, don't rinse the bot. Consider [Asimov's](http://en.wikipedia.org/wiki/Isaac_Asimov) Third Law.)

**About Me: (skip, it's boring)**

I'm a homeless outreach worker.  The job's amazing.  But I'll say, emotionally taxing.  Skipping the politics and the sermon on [harm-reduction](http://en.wikipedia.org/wiki/Harm_reduction), I decided at the start I needed something far from the job to allow my mind rest and prevent compassion fatigue.  Something that consumed my brain-power so I'd not be stressing over the 6 months pregnant 17 year-old, shooting up under a bridge on I-35\. Something to protect my down-time so I'd be frosty for the next day.

Well, I saw that TED talk about the [Sand Flea](http://www.youtube.com/watch?v=6b4ZZQkcNEo#t=23) and I told Bek, "That's awesome, think I could build one?"
 "Oh crap," she said, "new obsession?"

Now, robots are my relief.  My way to prevent white-matter from becoming dark-matter as I rake through sludge looking for those who want out.

I started reading a lot.  I discovered, Arduino, Sparkfun, eBay, Raspberry Pi, ferric chloride, Python, [hackaday](http://hackaday.com/), [HC-SR04](http://www.instructables.com/id/Easy-ultrasonic-4-pin-sensor-monitoring-hc-sr04/), [Eagle](http://www.cadsoftusa.com/), [OSHPark](http://www.oshpark.com/), and the list goes on.  But every time I Googled something about robots, I'd end up at the same place.

[www.letsmakerobots.com](http://www.letsmakerobots.com)

**These guys are brilliant.  They are a college education from collaboration, I swear.**

Soon, I ended up with [my first bot.](http://letsmakerobots.com/node/35922)  A piece of sh...short-circuits.  Although, I did learn a lot interfacing the bot with the [Raspberry Pi](http://www.instructables.com/id/How-to-Make-a-ArduinoRaspberry-Pi-Robot-Platform/).  Also, while I was working with a Raspberry Pi, I played with [OpenCV](http://opencv.org/), and was considering adding a face tracker to my bot before I got distracted.  But before I quit, I created a [proof-of-concept](http://letsmakerobots.com/node/36947).

So, all these experiences began to culminate.

Meanwhile, I was taking a graduate Research Methods class at UTA and my professor disappeared.  The university was amazing; good professors filled in and made sure our education didn't suffer. But we wondered for many months.  Sadly, it was discovered he had killed himself.

It shook me.  I deal with suicidality every other day, but it's usually on the street.  Why a successful research professor?  My thoughts got dark for a bit, which meant I sunk into robots even more.  Yet, now, a question sat at the front of my mind:**Will robots one day kill themselves?**

<video class="post-video" autoplay loop muted playsinline>
  <source src="https://ladvien.com/images/movies/F2SB0VPHMMFC1O5.MEDIUM.mp4"
  title="Futurama Suicide Booth"
  type="video/mp4">
</video>

This may sound silly.  But I believe the formula for self-termination can be expressed in Boolean logic, and therefore coded.

Pseudo-code would be:

**if painOfExistence > senseOfPurpose then:**

**self_terminate()**

Derived from work and life experience I genuinely believe the root-motive for suicide is [existential-anxiety](http://en.wikipedia.org/wiki/Anxiety#Existential_anxiety), which seems to me, entangled within both constructs.

Ok.  Skipping the _Time_bit.

Someday, I'd like to delve into swarm robotics. Or, at least, attempt to replicate organic group behavior within a robot group.  And I thought it might be possible to control a group of robots with a setup similar to those universities or research groups keep showing off. (Jockish Ivy Leagues :P)

Well, I found these desires, information, and tools synergized into a passion.  After two days, I was able to write a basic OpenCV Python script that could control a robot using a static webcam looking down on it.  Let me clarify, I'm of average intelligence, simply obsessive, so when I mentioned "two-days" I'm trying to convey the utter feasibility of this project, for**_anyone_**.  Python, Arduino, and OpenCV make it _so very easy;_ anyidiot like me can hack it out.

Of course, my purpose for this platform is to control robot groups.  The group being the second social collection (one-to-eight) and social interaction seems to be the essential in developing a [positronic brain](http://en.wikipedia.org/wiki/Positronic_brain).  The white-mattered brained being necessary for me to test the above mentioned self-termination formula.  So, maybe, I'll learn if robots will commit suicide, or perhaps, have a better understanding of why humans do.

**Dark and depressing!  I know, right?  Who writes this crap!?**

![](/images/FGK6EXCHMMFAICI.SQUARE.jpg)

**A robot**

It doesn't matter what sort of robot you use, it only needs:

1.  A microncontroller (e.g., [Arduino](http://www.arduino.cc/), [PicAxe](http://www.picaxe.com/), etc.)
2.  Built from material of a bold, solid color.
3.  The ability to change directions and move.
4.  A magnetometer.  I used the [HMC5883L](http://www.ebay.com/itm/HMC5883L-Triple-Axis-Compass-Magnetometer-Sensor-Module-For-Arduino-3V-5V-/400362466832?pt=LH_DefaultDomain_0&hash=item5d37766e10).  They're like 2 USD on eBay.
5.  A wireless serial connection. [Bluetooth](http://www.instructables.com/id/how-to-Control-arduino-by-bluetooth-from-PC-pock/), [Xbee](http://www.ladyada.net/make/xbee/), and [nRF24L01](http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo) would be my recommendation since all are well documented creating a bridge between PC and microcontroller.

I personally built my [own](http://letsmakerobots.com/node/38203) using red cutting-board I stole from Bek (shh).  For my serial connection I used two $10 Bluetooth 4.0 modules, which I've written an instructable on setting up a Bluetooth 4.0 module to work with an Arduino and PC: [Bluetooth 4.0 and Arduino](http://www.instructables.com/id/How-to-Create-an-Arduino-Compatible-Bluetooth-40-M/).

![](/images/F0J3P8EHMMFC1RK.SQUARE.jpg)

**A PC**

Probably something less than 10 years old.  It could be running Linux or Windows;though, I'll be using Windows Vista (hey, I'm first-world poor and can't afford Windows 7 :P).

1.  The PC will need to be running [Python 2.7](http://www.python.org/download/releases/2.7/)
2.  It'll need [OpenCV 2.4.4](http://opencv.org/downloads.html)
3.  It will need a wireless serial connection that pairs with your bot.  Again, I used my [BT 4.0 modules](http://www.instructables.com/id/How-to-Create-an-Arduino-Compatible-Bluetooth-40-M/).

![](/images/FU8RLE6HMMFC1TF.SQUARE.jpg)

**A Webcam**

It's really up to you.  I'm not going to lie, I went with the [cheapest webcam](http://www.fasttech.com/products/0/10003325/1246901-compact-13mp-pc-usb-webcam-with-built-in-microphon) I saw, which costs 6.87 USD. But I would _not _recommend this webcam.  It didn't like my PC, so every time my Python script stopped I had to unplug the webcam and re-plug it in.  A real annoyance for debugging.

1.  I'd suggest a high-resolution webcam.  Maybe even a IP cam, if you're rich?  If you are, would you buy me one too?
2.  Long**male-to-female** USB cable.  Again, I got two 15' USB cables on [eBay](http://www.ebay.com/itm/15ft-15feet-USB2-0-A-Male-to-A-Female-Extension-Cable-White-U2A1-A2-15WHT-/400580131707?pt=US_USB_Cables_Hubs_Adapters&hash=item5d446fbb7b) for around 4.50 USD.  If you get everything setup and you notice problems with the webcam at the end of the cable, you can put a powered hub at the end of the cable with an extension cord and it'll take care of the issue.  Though, I didn't have this problem at 15'.
3.   Or...don't ask...

So, I made my robot, [Dot Muncher](http://letsmakerobots.com/node/38203), using an [Arduino Uno](http://arduino.cc/en/Main/arduinoBoardUno), [Motor Shield](http://www.ebay.com/itm/L298P-Shield-DC-Motor-Driver-Module-2A-H-Bridge-Arduino-Compatible-/321178232095?pt=LH_DefaultDomain_0&hash=item4ac7b6e51f), and a [Bluetooth 4.0 module](http://letsmakerobots.com/node/38009).  The chassis was made from [HDPE](http://en.wikipedia.org/wiki/High-density_polyethylene), a cutting board I stole from my wife. The [motors](http://www.ebay.com/itm/3-6V-DC-Small-Micro-Geared-Box-Electric-Motor-High-Quality-/190576860674?pt=LH_DefaultDomain_0&hash=item2c5f441e02) and [tires](http://www.ebay.com/itm/2pcs-43-19-3mm-D-hole-Small-Smart-car-model-tire-wheel-Robot-Part-for-DIY-/390668300421?pt=Model_Kit_US&hash=item5af5a53085) were from eBay.

Now, about any robot will work, like I've stated, so Google away and select a robot build you like.

Of course, everything you'd every want to know can be found one this site :)

I'm just sayin'.

But the code, that's the part we want to focus on. Really, our robot only has a nerves and muscles, the brain will actually be in the PC, all the robot does is,

1.  Calculates the compass info.
2.  Sends the compass info to the PC.
3.  Reads the movement codes from the PC.
4.  Translates the movement code received into a motor activation.

That's it.  Pretty simple.

```cpp
//I've been using Zombie_3_6_RC in Processing to interact.

// Reference the I2C Library
#include <Wire.h>
// Reference the HMC5883L Compass Library
#include <HMC5883L.h>

// Store our compass as a variable.
HMC5883L compass;

// Record any errors that may occur in the compass.
int error = 0;

//int pwm_a = 10; //PWM control for motor outputs 1 and 2 is on digital pin 10
int pwm_a = 3;  //PWM control for motor outputs 1 and 2 is on digital pin 3
int pwm_b = 11;  //PWM control for motor outputs 3 and 4 is on digital pin 11
int dir_a = 12;  //dir control for motor outputs 1 and 2 is on digital pin 12
int dir_b = 13;  //dir control for motor outputs 3 and 4 is on digital pin 13

int lowspeed = 120;
int highspeed = 140;

//Distance away
int distance;

//Sets the duration each keystroke captures the motors.
int keyDuration = 10;

int iComp;

void setup()
{
  Serial.begin(9600);

  Wire.begin(); // Start the I2C interface.

  Serial.println("Constructing new HMC5883L");
  compass = HMC5883L(); // Construct a new HMC5883 compass.

  Serial.println("Setting scale to +/- 1.3 Ga");
  error = compass.SetScale(1.3); // Set the scale of the compass
  error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous

  pinMode(pwm_a, OUTPUT);  //Set control pins to be outputs
  pinMode(pwm_b, OUTPUT);
  pinMode(dir_a, OUTPUT);
  pinMode(dir_b, OUTPUT);

  analogWrite(pwm_a, 0);
  //set both motors to run at (100/255 = 39)% duty cycle (slow)
  analogWrite(pwm_b, 0);

  pinMode (2,OUTPUT);//attach pin 2 to vcc
  pinMode (5,OUTPUT);//attach pin 5 to GND
  // initialize serial communication:
  Serial.begin(9600);

}

void loop()
{

  // Retrive the raw values from the compass (not scaled).
  MagnetometerRaw raw = compass.ReadRawAxis();

  // Retrived the scaled values from the compass (scaled to the configured scale).
  MagnetometerScaled scaled = compass.ReadScaledAxis();

  // Values are accessed like so:
  int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis)

  // Calculate heading when the magnetometer is level, then correct for signs of axis.
  float heading = atan2(scaled.YAxis, scaled.XAxis);

  // Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location.
  // Find yours here: http://www.magnetic-declination.com/
  // Mine is: 237' W, which is 2.617 Degrees, or (which we need) 0.0456752665 radians, I will use 0.0457
  // If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
  float declinationAngle = 0.0457;
  heading += declinationAngle;

  // Correct for when signs are reversed.
  if(heading < 0)
    heading += 2*PI;

  // Check for wrap due to addition of declination.
  if(heading > 2*PI)
    heading -= 2*PI;

  // Convert radians to degrees for readability.
  float headingDegrees = heading * 180/M_PI;

  // Normally we would delay the application by 66ms to allow the loop
  // to run at 15Hz (default bandwidth for the HMC5883L).
  // However since we have a long serial out (104ms at 9600) we will let
  // it run at its natural speed.
  // delay(66);

  //This throttles how much data is sent to Python code.
  //Basically, it updates every second (10 microsecond delay X 100 iComps)
  if (iComp >= 30){

    int adjHeading = 0;
    //The "floor" part makes the float into an integer, rounds it up.
    headingDegrees = floor(headingDegrees);
    if (headingDegrees >= 280){
        adjHeading = map(headingDegrees, 280, 360, 0, 79);
    }
    else if (headingDegrees <= 279) {
        adjHeading = map(headingDegrees, 0, 279, 80, 360);
    }

    Serial.println(adjHeading);
    iComp=0;
  }
  iComp++;

  delay(10); //For serial stability.

  int val = Serial.read() - '0';

  if (val == 1)
  {
    Back();
  }

  else if (val == 2)
  {
    Right();
  }

  else if (val == 3)
  {
    Forward();
  }

  else if (val == 4)
  {
    Left();
  }

  else if (val == 5)
  {
    Stop();
  }
}

void Back(){
//Straight back
      analogWrite(pwm_a, highspeed);
      analogWrite(pwm_b, highspeed);

      digitalWrite(dir_a, HIGH);  //Reverse motor direction, 1 high, 2 low
      digitalWrite(dir_b, LOW);  //Reverse motor direction, 3 low, 4 high

delay(keyDuration);
}

void Left(){
      //Left
      analogWrite(pwm_a, lowspeed);
      analogWrite(pwm_b, lowspeed);

      digitalWrite(dir_a, HIGH);  //Reverse motor direction, 1 high, 2 low
      digitalWrite(dir_b, HIGH);  //Reverse motor direction, 3 low, 4 high

delay(keyDuration);
}

void Right(){
      //Right
      analogWrite(pwm_a, lowspeed);
      analogWrite(pwm_b, lowspeed);

      digitalWrite(dir_a, LOW);  //Reverse motor direction, 1 high, 2 low
      digitalWrite(dir_b, LOW);  //Reverse motor direction, 3 low, 4 high

delay(keyDuration);
}

void Forward(){
  //set both motors to run at 100% duty cycle (fast)
  analogWrite(pwm_a, highspeed);
  analogWrite(pwm_b, highspeed);

  //Straight forward
  digitalWrite(dir_a, LOW);  //Set motor direction, 1 low, 2 high
  digitalWrite(dir_b, HIGH);  //Set motor direction, 3 high, 4 low

  delay(keyDuration);
}

void Stop(){
  //set both motors to run at 100% duty cycle (fast)
  analogWrite(pwm_a, 0);
  analogWrite(pwm_b, 0);

  //Straight forward
  digitalWrite(dir_a, LOW);  //Set motor direction, 1 low, 2 high
  digitalWrite(dir_b, HIGH);  //Set motor direction, 3 high, 4 low

  delay(keyDuration);
}
```

The first bit of robot code I'd like to focus on is the compass.  Now, I've not detailed how to use the [HMC5883L](https://www.sparkfun.com/tutorials/301), since SparkFun has done this for me.  I also won't go into [tilt-compensation](http://www.loveelectronics.co.uk/Tutorials/13/tilt-compensated-compass-arduino-tutorial), since I was more worried about proving the concept here than dead-on accuracy.    Just be sure and share the code with us all when you're done :P

No.  Instead, I want to focus on adjusting the compass heading from a value respective to true North, to what we want it to think is north, in our case, whatever is the top of our screen.  This process takes a little involvement, since the numbers must be set manually and with a little guesstimation.

***See code above.***

So, I got my compass module lying flat as possible and then bolted it to my robot.  This helps assure your getting a full 360º and will keep you from having to re-calibrate what we'd like to call north every time the compass module gets knocked out of place.

**106-114:** These modules and the Arduino library are both designed to have 0º be North, but we want to set our own north, video-game north.  Which is exactly what lines 106-114 are about.  I found 80º is what value my robot was reading when he was headed towards the top of the screen.  I had to find a way to adjust this to give me the reading 0º.  I ended with this simple code to spin the compass.

I had to divide the adjustments into two sections for the math to stay simple.  Lines 109-111 handle [mapping](http://arduino.cc/en/Reference/map) 0-79º onto 280-0º, making the robot think 0-79º is 280-0º.  Lines 112-114 do the same for 80-360º, converting it to 0-279º.

Honestly, I've got some spatial-retardation, so I have a hard time thinking through this,**I just know it works**.  So, if you have problems I'll answer emails and Skypes and we can work through it together.  And, if you want to submit a better explanation, I'll post it and be sure to give you credit.

![](/images/F2AFT0SHMVJ9ADF.MEDIUM.jpg)

Do know, my redneck solution was to change the orientation of the camera. **Pfft.  Too easy**.

Moving on,

**116:** Sends the robot's heading to the PC.

**117:**iComp is a variable allowing us to decide when to start sending data to the PC.  We don't want to send data to the PC before it's ready or before the robot is warmed-up, we'd be dealing with poor readings.

**118:**This is a delay that makes sure we are not bogging down the serial line, since every time we call**Serial.println("whatever")**both the PC and the robot have to take some processing power to deal with it.  In short, it's to make sure the robot is not talking the computer's ear off.

***See code above.***

This bit is pretty easy.  It reads the codes being sent from the PC and translates them into a function call.  I write all my robot-PC interactions this way, since if I want a code to mean something completely different, for instance I want to swap the robot's right and left movements, I'd just swap lines 134 and 144.

Easy.

**125:**If I remember correctly, this line reads serial data being sent from the PC and assures the**val** variable isn't getting a bunch of zeros.

Easy one.

This is one of the functions called to make the motor move, or in the case of this function, stop.

**188-189:** This actually tells which pin on the Arduino, specified by the variables**pwm_a** and**pwm_b**to decrease to 0\.  This effectively stops our robot.

**192-193:** This bit actually tells the motor which direction to turn.  The pins (**dir_a** and**dir_b)**are set either HIGH or LOW and this changes the direction of how the motor moves.

Tell you what, my good friend [ChickenParmi](http://www.duino-robotics.com/) explains it better [here](http://www.youtube.com/watch?feature=player_embedded&v=XZLVpfydUdw)

***See code above.***

Now we have a our little robot setup, let's setup our Python environment.

**[Python 2.7 download](http://www.python.org/download/releases/2.7/)**

For windows, use the MSI Install respective to your architecture, either x86 or x64\.  Of course, Linux and Mac are versions are there as well.  Go ahead and install Python 2.7, but I'm not a fan of their [IDE](http://en.wikipedia.org/wiki/Integrated_development_environment).  Instead, I use:

[**Geany**](http://www.geany.org/Support/RunningOnWindows)

![](/images/FK4HWSSHMVJGC35.SMALL.jpg)

Though, this IDE is a little tricky to get running on Windows, since it's meant for Linux.  [These posts](http://stackoverflow.com/questions/126753/is-there-a-good-free-python-ide-for-windows) over at Stack Overflow go through some popular Windows Python IDEs.  Pick what you feel comfortable in.  I suggest running 'Hello World' in each until you decide you like one.

Here we are, the hardest part of this whole project; if not careful, we fall into [dependency hell](http://en.wikipedia.org/wiki/Dependency_hell).

I'm going to try and help you setup all the modules needed to run the Python code.  It's been difficult for me to do this right, so I'll try to be descriptive.

There are seven modules we will use.

1.  [OpenCV](http://opencv.org/downloads.html) (which we'll call cv2).
2.  [Numpy](http://www.numpy.org/)
3.  [Serial](http://pyserial.sourceforge.net/pyserial.html)
4.  [Time](http://docs.python.org/2/library/time.html)
5.  [Math](http://docs.python.org/2/library/math.html)
6.  [Random](http://docs.python.org/2/library/random.html)
7.  [Threading](http://docs.python.org/2/library/threading.html)

Of these**we will need to install OpenCV, Numpy, and Serial,** since the rest come built into Python 2.7.

The main trick with _**any**_**module you install in Python is to make sure the exact path you install it to gets added to the Environment Variable (this is true for both Windows and Linux).**

To explain this I'm going to hand it over to Lovely Ada as she tells us how to install the Serial module:

**[pySerial](http://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/installing-python-and-pyserial) installation**

Note the bit about adding the environment variable, since none of the other modules will explain this, but each will need to be there.

Now, let's try OpenCV and Numpy.  My favorite installation guide (meaning it worked for me) was written by [Abid Rahman](https://plus.google.com/118298613334549762938/posts):

[**OpenCV 2.4.4 installation**](http://opencvpython.blogspot.com/2012/05/install-opencv-in-windows-for-python.html)

At this point, you might bring up Python and try some simple webcam capture test code (if you have problems copying and pasting, I've added web capture code as an attachment as well):

***See code above.***

If you see a live feed from your webcam, you're almost good to go.

![](/images/FFMAZIFHMVJGCAS.MEDIUM.jpg)

If there any problems, like I said, you and me buddy.  Feel free to ask questions here or Skype me:**thomas_ladvien**

Okay.  Here's all the Python code in one go. _Don't be scared _if this looks confusing.  I feel the same way.  In fact, some of it I _still _don't understand.  (Hey, honesty a is a rare fault I seem to possess.)  Again, don't worry, we're going to walk through it one section at a time, you and me, buddy.  Until the end.

On the flip side, if you are a Python guru, or yanno, just a sassy-pants: Feel free to add corrections and comments on this page.  I'd love to make this code grow through critique.  Do know, I guarantee the following: Typos, grammar problems, illogical coding, artifacts from debugging, and the like.

I should state, the basic code for color tracking was written by [Abid Rahman](https://plus.google.com/118298613334549762938/posts) in a reply on [Stack Overflow](http://stackoverflow.com/questions/12943410/opencv-python-single-rather-than-multiple-blob-tracking).

Also, I've included the code as an attachment, it's at the bottom.  Video-game south.

***See code above.***

Ok.  The beginning.

So lines 3-10 pull in the [modules](http://docs.python.org/2/tutorial/modules.html) we will need.  My take on a module is the following, "Code some smart guy wrote and doesn't want anymore, so he gave it to me to use."

To be specific

*   [**cv2** ](http://opencv.org/downloads.html)is the OpenCV module.
*   [**Numpy**](http://www.numpy.org/), which we'll call "**np**" throughout the code, is used for higher number functions needed for OpenCV to do her magic.
*   [**Serial** ](http://pyserial.sourceforge.net/pyserial.html)is the module which will allow us to establish a serial connection between the PC and the robot, via whichever wireless device you've chosen.
*   [**Time** ](http://docs.python.org/2/library/time.html)allows us to basically idle the code.  This is important in controlling many things, for instance, how far the robot moves.  We tell the motors to turn on, wait 10 secs, then turn off.  Because the sleep function actually puts the code into an idle state, we must have the threading module, since our code requires the PC to do several things at once.
*   [**Math**](http://docs.python.org/2/library/math.html).  From the math module we get the code to help us simplify the trigonometry calculations, like the angle between the robot and target.
*   The [**random** ](http://docs.python.org/2/library/random.html)module is only used to gives us a random target.
*   [**Threading**](http://docs.python.org/2/library/threading.html).  Important module.  Basically, threading allows the computers to do two tasks at the same time.  This becomes important when we are both trying to track the robot and receive his position.  Throughout this code we will have three threads
    1.  The thread running the OpenCV stuff.  This tracks the robot and is also the largest.
    2.  A thread controlling the serial connection between the robot and PC.
    3.  And a thread with the small job of telling the motors how long to be on, thereby controlling how far the robot will move.

***See code above.***

13: This is where we actually open a serial connection to the wireless device you are using.  Note, we've named the serial connection we opened "**ser**" so when we go to send information it will be something like,**ser.write("What you want to send here")**

15-38: Here we declare a bunch of [variables.](http://www.tutorialspoint.com/python/python_variable_types.htm) The "[global variable](http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them)" lets the code know that this variable is going to jump between all threads. Next, the**variable = 0** actually declares the variable.  Do know, you'll have to remind each thread a variable is global by stating "global variable."

One thing I should state,**iFrame = 0** is an actual variable declaration, as well as setting it to 0.  Of course, this is how one would declare an integer variable with an initial value of 0.  On the flip,**rx = " "** isalso a variable declaration but this time a string.  You'll know I switched information from a integer to a string if you see something like this:

**headingDeg = str(intHeadingDeg)**

That tells the code, "I want to convert the value in intHeadingDeg, which is an integer, into a string and call it 'headingDeg'"

The comments indicate what each variable is meant for.  Not going to lie, not sure I don't have some declared variables I meant to use, didn't, and forgot to remove.

One important variable is the**iFrame** variable, since it tracks which frame we are on.  This becomes key in all aspects of tracking our robot.

![](/images/FB16OS8HMMF9408.SMALL.jpg)

***See code above.***

**42**: Here we start this [function](http://docs.python.org/2/library/threading.html) that does most of the work,**OpenCV():**.  It is one of the functions that**will be threaded at lines 345-347**.

**44**: We open up the webcam and give it the nickname**cap**.  If I remember right the "0" in the parenthesis refers to whatever camera comes first on your USB bus, so if you have more than one camera you can specify by changing this number, e.g.,**cap = cv2.VideoCapture(3)**.  Notice we called the OpenCV module cv2, so we are using the OpenCV module to access the webcam.

**46-52**: Just making the variables we declared work within this function.  This might not be needed, but hey, I don't read the _whole_ Python manual.

**55:**This is just a string flag that is flipped to tell the PC to generate a new target for the robot.  Note, we initially set it to "Yes" meaning the first time we run through this function a target needs to be generated.

**58:**This is an integer variable to count how many dots the robot has "ate."

Ok, before I get to the next bit I need to take a minute and explain how we approach actually getting the coordinates of our robot.  As you know, OpenCV does the hard work for us, giving us the X and Y coordinate of the largest red blob on the screen.  Though, the coordinates it gives us are the center of the mass.  Now, this is all just a logical guess because I didn't read the whole OpenCV manual, but I believe the X or Y coordinate that refers to the center of this mass is called the [centroid](http://en.wikipedia.org/wiki/Centroid).

![](/images/F3DYKW5HMNNG8MH.SMALL.jpg)

This might seems simple.  That's because it is, I'm not sure why we don't just call it the damn center or something.  Eh, oh well.  Though, it will become important when we do collision detection between the robot and its target.

**61-62**: All that to say, the "c" in**cyAvg**and**cxAvg**stands for centroid.  So, these are variables that will hold the running average for the X and Y coordinates of the red blob's centroid.

**65-66:**These are back-up variables of the**cxAvg** and**cyAvg**and will be important around line**122-127**when  we are trying to decide if the color we are tracking is actually the robot or some other piece of junk with enough red in it to fool OpenCV.

**69:**This simply clears the string variable with data that came from the robot, like the robot's heading, before another iFrame starts.

***See code above.***

**71**: Creates a loop within the OpenCV() function.

**73-81:**Ok, I need to be humble here and say I'm not sure what the [Cthulhu's](http://en.wikipedia.org/wiki/Cthulhu) Kitchen I was doing.  I know**printRx = str(intRx)**is taking the information received from the robot and converting it into a string. **intRx**is as a global variable and it is loaded with robot data at line 326.**headingDeg = printRx**is moving the heading data from one variable to another; the idea here was if I wanted more information to come from the robot besides the compass heading it would come in through**printRx**, then I could chop it up and load it into variables respective to their purpose.

For instance, printRx.split(",") should give a list of strings based on how many commas are currently held within printRx.

**printRx = "2, 23, 88"
 compass, sonar, battery_life = printRx.split(",")**

Now,

**compass = 2
 sonar = 23
 battery_life = 88**

But the part that confuses me is I turn right back around and convert the string back to an integer?  I'm not sure, guys.  I might have Southpark while coding again.

At the end of that poor coding we end up with two variables to use:**intHeadingDeg** and**headingDeg.**We the integer**intHeadingDeg** to do any calculations that involve the robot's heading.  The other,**headingDeg**, is to print the robot's heading to the screen, which is done at line 263.

**84-85:**These are string variables that will will hold the "Target Locked X" or "Target Locked Y" if we are tracking the robot.  These strings are needed so we can print this to the screen on line 259-260.

***See code above.***

We're in the meat now.

**88:** This increments our frame counter.

**91:**We read a single frame from the webcam we declared, cap, at line 44.

**OPENCV!**Sorry, I just love it so much.

So, by now you know I've not read the OpenCV manual.  And please don't tell me, "What! Go [RTFM](http://en.wikipedia.org/wiki/RTFM)!"   I've got a wife, kid, and a job I love.   But this attitude will begin to show as we go through the OpenCV calls, since I don't know their inner working.  Instead, I'm going to offer my best guess, and as always, if someone wants to correct me or offer better explanation, I'll post and give credit.

**94:**This [blurs](http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=blur#blur) the image we got.  You may say, "But I thought higher resolution was better?" It is.  But jagged edges and color noise are not.  A simple shape is much easier for math of OpenCV to wrap around then a complex one.  Therefore, we blur the image a little, giving us softer edges to deal with.

Also, blur melds colors, so if there are 2 blue pixels and 1 red pixel in a group, then it become 3 blue-purplish pixels.  This has the nifty benefit of speeding up the image processing _a lot_.  How much? I don't know I didn't RTFM.

**97-100:**Our image is converted to a [histogram](http://en.wikipedia.org/wiki/Histogram) here.  Having the image in a histogram format allows us to use [comparative statements](http://en.wikipedia.org/wiki/Histogram) with it.  What we use it for is to get rid of all the colors except the one we are trying to find.  This will give us a black and white image, the white being only the color we are looking to find.**Line 98 is where your color is defined (it's the two "np.array"s).

In the next step I'll go through how to select your robot's exact color.**

![](/images/FYRK54LHMVJCR5D.MEDIUM.jpg)

**103:**Finds the contours of the white area in the resulting image.

![](/images/F39IAO6HMVJCR94.SMALL.jpg)

**107-112:**OpenCV then counts how many pixels are in each contour it finds in the webcam image.  It assumes whichever has the most white area (aka, "mass") is our object.

![](/images/F9DUH63HMVJCRAS.MEDIUM.jpg)

**114-117:**After we decided which object we want to track, now we need to come up with the centroid coordinates.  That is what lines 115-116 do.  I've not done the research on the math there, but I believe it averages the [moments](http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=moments#moments) of the polygon and calls the average either centroid X or Y, depending on the calculation.  But, feel free to correct or explain better.

![](/images/FMFJV82HMVJCRB8.MEDIUM.jpg)

**121-127:**Here we lock onto the mass we believe is the robot.  It begins by collecting a 150 samples before it will state is tracking the largest mass.  But after it begins to track the largest mass, then we try to stay locked on to it.  This is line 122-127\.  In essence, we allow the mass to move enough to be considered a movement by the robot, but not so much that noise (like a stray hand in the webcam image) will cause the tracking to switch off the robot.
![](/images/FD4XTKAHMVJCRKM.MEDIUM.jpg)

***See code above.***

This particular line defines what color you are looking for, specifically, the two sets of values:**130, 170, 110 and 190, 190, 200.**  These two values set the lower limit and the upper limit of the color you are looking to find.  The reason we use upper and lower limits, which we'll call color thresholds, is because our robot will move through different lights.  Different light sources have a tendency to change how the webcam reads the color.

The color format we are using is HSV, which stands for**hue, saturation, value**.  Later, I'll probably write code to select the robot within our actual program, but for now I use**[Gimp](http://www.gimp.org/downloads/)**and the following method:

1.  Setup your webcam the in the area you'll be using, just like you're ready to control him.
2.  Run the webcam program attached in step 10.
    ![](/images/FI9HH9GHMVJH9RL.MEDIUM.jpg)
3.  While the webcam program is watching your robot, hit**Ctrl + Print Screen**
4.  Open Gimp.
5.  Hit Ctrl + V to paste the screen capture into gimp.
    ![](/images/FIOKPUZHMVJH9SP.MEDIUM.jpg)
6.  Now, find the Color Selector tool.
    ![](/images/F4BHJ1RHMVJH9U0.MEDIUM.jpg)
7.  Select the main color of your robot.
8.  Now double click on the color square on the toolbar.
    ![](/images/FM1ZV3QHMVJH9US.MEDIUM.jpg)
9.  A window should pop open with color information regarding the color you selected, your robot.
    ![](/images/FMC8T5PHMVJH9VI.MEDIUM.jpg)
10.  Now, the three numbers listed should be close to what we need.  Sadly, we have to convert from Gimp's HSV number range to OpenCV's HSV number range.  You see, HSV value range in Gimp is H = 0- 360, S = 0-100, and V = 0-100\.  In OpenCV, H = 0-180, S = 0-255, V = 0-255\.  So, some conversion needs to take place.
11.  From my selection I ended with Gimp numbers of, H: 355, S:50, and V:61\.  I could get all fancy and calculate the right numbers, but I figure 180 (OpenCV) is half of 360, so**for my H I just divided by two: 177.**The other two I kinda guess at a little.  I doubled and added 25,**S: 125 and V: 147.**
12. **In the end, this gave me middle numbers.  But I wanted an upper and lower threshold, so I took each number and subtracted 20 to give me a lower, and added 20 to give me an upper.**
13. **The result for my robot was:**

***See code above.***

I'll try to code a color selector into the program to make this whole damn thing a cinch.

If you'd like to read more, two good posts on Stack Overflow.

1.  [Choosing HSV](http://stackoverflow.com/questions/10948589/choosing-correct-hsv-values-for-opencv-thresholding-with-inranges)
2.  [Finding HSV in image.](http://stackoverflow.com/questions/14551154/best-way-to-find-hsv-values)

***See code above.***

**132-136:** Here we actually take the running average of the centroids' X and Y.  We load this into the  variables**cxAvg** and**cyAvg**, again, this is to assure we are tracking the robot.

**142-145**: Here the target, or "dot," for the robot to run after is randomly generated.  As you may notice I restricted the generation area of the dots towards the center of my webcam's field-of-view.  That's because I'm messy and dots were going where the little robot couldn't get.

**147-153:**This is a rough collision detection function.  Basically, if the robot gets so close to the target (45px) then it has considered to have "eaten" the dot.  If it did, then the**dot** variable is incremented showing the total amount he's done ate and the**newTarget** string variable is flipped so it can generate a new target the next run through.

***See code above.***

**156-177:**Here we are trying to find the angle between the robot and his target.  We basically divide the entire screen up into four quadrants but always using the robot's centroid as the point of origin.  We then calculate the slope between the target's X and Y (**tY**,**tX**) and the robot's X and Y (**cxAvg** and**cyAvg**).

**Something like this:**![](/images/FAILHZVHMVJCRN2.MEDIUM.jpg)

If the target were to be located in the quadrant III, it would go something like this.

![](/images/FNOYR6FHMVJCSCO.MEDIUM.jpg)
If you'd like to dig further into [Trigonometric Functions](http://docs.python.org/2/library/math.html#trigonometric-functions) in Python, have fun.  Share if you find better math :)

***See code above.***

**181:**When we find the angle between the robot and the target, then convert it into degrees, it ends up giving us a number which is a [float](http://en.wikipedia.org/wiki/Floating_point). That's more than we need, so here we convert the float**(****degs)** to and integer**(targetDegs)** so we can compare to the robot's compass heading.

**184:**We declare an empty string called**strTargetDegs**.
**187:** Then we convert the float**degs** into a string so we can print the target angle onto the screen at line 264.

***See code above.***

This is where I need help guys.  My turning code has a bug, so if you find it and come up with a correction I'll send you a prize.  I dunno? A lint ball? It'd probably be one of my left over circuit boards, or some piece of hardware I hacked together.

But for now, let's take a look.

The idea is like:

![](/images/F2JHJ9JHMVJHBLN.MEDIUM.jpg)

The code is supposed to go as follows:

**if target1 = True then:**

**MoveForward()**

**elif target2 = True then:**

**TurnRight()**

**elif target3 = True then:**

**TurnLeft()**

And for the most part that happens, but occasionally it is dumb and turns left when it should right.  Not sure what I'm doing wrong.  Hey, that "You and me buddy, until the end" is a two-way street. :P

Let's step through it

**195:**We want to make sure we are deep into tracking the robot before we start moving it towards the target.

**198:**We compare**intHeadingDeg**, which is the robot's heading angle, with**targetDegs,** which is the angle between the robot and the target.  But we do this + or - 30º.  This means the robot does not have to have its heading angle _exactly_ the same as the angle to the target it.  It only need to be approximately pointing in the right direction.

**199:**The movement code for the robot to go forward is**3**, so here, given the robot is approximately headed in the right direction, we tell the robot to move forward.  This happens by loading**3**into the variable**tranx,** which is transmitted to the robot at line 307\.  When this code gets transmitted to my robot, the Arduino code at line 137 tells the**Forward();** function to fire.

**202:**If our robot isn't headed in the right direction, then which way should he turn?

**203-232: **Still debugging here.  I'm sorry guys.  I can tell you this code works "Ok."  But once I'm done with this tutorial, I'll go back and focus on making it turn perfect.  Sorry, this code took me two days to right, but this tutorial has taken too many days.

Though, within each of the if statements we have two variable assignments:**tranx = X**and**motorDuration = 10**.  The tranx tells the robot which direction to move and the motorDuration tells it how long to move that way (this is not yet being utilized in my code).

***See code above.***

Here, we are drawing every thing to the screen before we show the frame.

**242:**Red circle for target.

**247:**White box to display black text on.  Note, we are drawing things bottom up.  So, if you want something to have a particular Z level you'll need to put it towards the top of this section.

**250:**This is the green line between the target and our robot.

**253-267:**We display all our info here.  Compass heading, target-lock, etc.

**270:**This actually shows the color window (the window we wrote everything on).

**271:**This shows the HSV copy of the captured frame.  Notice the white area to be assessed as our target.

***See code above.***

**276:**An if-statement that waits for the ESC to be pressed.  If it gets pressed, we close stuff.

**278:**This releases our webcam.

**279:**This closes the windows we were displaying the color and HSV frames.

**281:**We send the code to stop our robot.  If we don't do this and we hit the ESC in the middle of a robot movement, that move will continue forever.

**282:**Here we closed the serial connection.

**283:**We quit.

Towards the beginning of this article I stated my webcam had crappy drivers; well, while writing this I noticed I had placed the**cv2.destroyAllWindows**before**cap.release().** This is what was causing the problem.  My interpretation of this was our camera being sucked into the void where the destroyed windows go.  Anyway, I switched the order and it seems to have solved the problem.

***See code above.***

Finally, we are opening our second threaded function.  This function is much smaller than the OpenCV function.  Here all serial communication takes place.

**289:**This helps in translating ASCII.

**292-296:**Global variables for passing robot information to other threads.

***See code above.***

**303:**We read information into the variable**rx**. The information is coming from the serial line we opened at the code's beginning.

**307:**This is a flag gate that makes it where our Python code can only send a motor command to the robot if the robot isn't already in the middle of a movement.

**308:**We write whatever value is in**tranx**, which should be loaded with some sort of movement from lines 192-232.

**313:**I think I threw this in there so the serial-line would bog down the my code.

**316:** We strip the number down to three digits only;remember, this is the compass heading in degrees, e.g,**000-360****º.**

**319:**When something is sent over serial it gets an end-of-line character. We don't want that.

**323:**The robot collected this number from a compass, which gave a number with a decimal involved.  This removes the decimal so we are only dealing with whole numbers.

**326-329:**I'm not sure what I was doing here, I think it had to do with the oddities of zero.  Eh.  I'll try to remember.

***See code above.***

This is a short threaded function.  It only really has one job, to control how long the motors on the robot stay on.  It works like this, if we send the robot a message to move forward, it continues to do so until line**341\. **There, the command to stop is sent to the robot and the**motorBusy** flag is set back to "No" meaning the motor is ready to be used again.

**340:**This sets how long the motor will stay on.  For instance, if it were changed to**sleep(1)** the robot's motor would continue in the direction they were told for 1 second.

**342:**This makes the robot wait in between movements.  In theory, this was meant to ensure OpenCV could keep up with the little guy.  So, if you have a fast robot, you might set this higher.

***See code above.***

Ok.**Code's End.**

This bit starts all three threads:**OpenCV**,**rxtx**, and**motorTimer.**

And here is my poor attempt to explain Python threading.  Most Python code is run sequentially; the order it comes is the order it is executed.  One problem is timing.  If we have to cause a delay in code, then the**whole program** has to pause.  Threading allows us to get around this.    I dunno, just how I see it.

![](/images/FGSGBQ0HMVJHBGS.SMALL.jpg)
Well, like I said,**"You and me, buddy, until the end." **And here we are.  The end.**

I hope this code has been helpful.  But do know, you're not alone.

<EMAIL_ADDRESS>
Skype: thomas_ladvien**

Skype or email me if you have any questions.

I still want to develop this into a Swarmie platform; so you might keep an eye out on [www.letsmakerobots.com](http://www.letsmakerobots.com) since I'll post my unfinished work there.  Alright, I'm off to work on the 8th iteration of my Swarmie...ugh.


text:
# zeroTune - a pi zero turer

Could run on a [Pi Zero W] with a
[ReSpeaker 2-Mics Pi HAT]
to capture 48kHz 2 channel audio and process it
with the [McLeod's WSNAC] pitch detection algorithm,
thus implementing a low latency tuner and intonation
monitor.

*N.B.* it should run on your Linux too.

# How it works
Tha audio samples are captured using ALSA and than
processed with the SNAC algorithm in a tiny C backend.

Using the rawrtc implementation of the WebRTC DataChannel,
the pitch data could then be sent to a web application
for visualization.

The WSNAC implementation uses currently multiple FFTs
of size 2048 for processing an audio frame captured
every 1024/48kHz seconds.
Using the [kiss_fft] on the Zero Pi needs less than 40% CPU,
and with [GPU_FFT] it comes down to 18% CPU.

# How to run it
First make sure you have CMake 3.2+ and the ALSA dev libs:

    sudo apt-get install cmake libasound2-dev

To build and install (locally with a prefix under `./bulid/prefix`):

	export PKG_CONFIG_PATH=${PWD}/build/prefix/lib/pkgconfig
	cd build
	cmake -DCMAKE_INSTALL_PREFIX=${PWD}/prefix ..
	make install

*N.B.* You might want to

    sudo apt-get install libssl-dev

before doing `./make-dependencies.sh` on the Zero Pi, as compliling openssl from sources would take quite some time.

To check if it works:

	export LD_LIBRARY_PATH=${PWD}/prefix/lib/:${LD_LIBRARY_PATH}
	./build/prefix/bin/zerotune-test hw:1,0

*N.B.* When using [GPU_FFT] you might have to run it with sudo.

# References
[Pi Zero W]: https://en.wikipedia.org/wiki/Raspberry_Pi#Pi_Zero
[ReSpeaker 2-Mics Pi HAT]: http://wiki.seeedstudio.com/ReSpeaker_2_Mics_Pi_HAT/
[McLeod's WSNAC]: http://www.cs.otago.ac.nz/research/publications/oucs-2008-03.pdf
[kiss_fft]: https://sourceforge.net/projects/kissfft/
[GPU_FFT]: http://www.aholme.co.uk/GPU_FFT/Main.htm

[Raspberry Pi Zero W](https://en.wikipedia.org/wiki/Raspberry_Pi#Pi_Zero)

[ReSpeaker 2-Mics Pi HAT](http://wiki.seeedstudio.com/ReSpeaker_2_Mics_Pi_HAT/)

[McLeod, Philip - Fast, Accurate Pitch Detection Tools for Music Analysis, 2008.](http://www.cs.otago.ac.nz/research/publications/oucs-2008-03.pdf)

[Kiss FFT](https://sourceforge.net/projects/kissfft/)

[Accelerating Fourier Transforms using the GPU](https://www.raspberrypi.org/blog/accelerating-fourier-transforms-using-the-gpu/)

[hello_fft at RaspberryPi Firmware](https://github.com/raspberrypi/firmware/blob/master/opt/vc/src/hello_pi/hello_fft/gpu_fft.txt).

repository: kpe/zerotune

repo_name: kpe/zerotune


text:
# Movies application
<img src="../docs/movies.gif" align="right"/>

This example showcases multi-index search, presented either as [tabs](https://github.com/algolia/instantsearch-android-examples/blob/master/movies/src/main/java/com/algolia/instantsearch/examples/movies/MoviesTabsActivity.java) or as [sections](https://github.com/algolia/instantsearch-android-examples/blob/master/movies/src/main/java/com/algolia/instantsearch/examples/movies/MoviesSectionsActivity.java).

- Search in the **movie's title**, **movie's actors**, and **actor's name**
- Filter by *number of views*, *rating*, *video quality* or *captioning*


text:
# ChatNoir Map File Generator

Hadoop MapReduce tool to map raw WARC files to HDFS map files.
This is the very first step when indexing a new corpus. The map files
will serve as input to the actual indexer and will later be used
to retrieve the raw HTML contents of a document through the web frontend.

## Compiling the Sources
To build the sources, first checkout the [`webis-uuid`](https://github.com/chatnoir-eu/webis-uuid)
repository and put it in a folder called `webis-uuid` next to this source directory.
Then from here, call
```
gradle shadow
```
from this source directory to download other third-party dependencies and compile the sources.

The generated shadow (fat) JAR will be in `build/libs`. The JAR can be submitted to run on
a Hadoop cluster. For ease of use, there is a helper script `src/scripts/run_on_cluster.sh` for
starting the mapping process.


text:
---
title: Why Project Managers should have children
author: ipedrazas
layout: post
date: 2013-02-19
url: /2013/02/19/why-project-managers-should-have-children/
categories:
  - startups
tags:
  - anti-patterns
---
Sometimes when I’m out with my children people makes comments about how busy we must be with three little monsters. Yes, we are… but there’s nothing you cannot solve with a bit of organisation, loads of patience and chocolate. Bribing is a must!

[<img class="aligncenter size-medium wp-image-44" alt="ID-10081433" src="http://ivan.pedrazas.me/wp-content/uploads/2013/02/ID-10081433-300x223.jpg" width="300" height="223" />][1]

But there’s a particular case that gest the whole thing wrong: Parents with only one child. They think that one child takes so much time, that 3 will take at least 3 times more.

Very Wrong.

Children, like a team, don’t add up but mix. It’s all about how well organised you are and don’t get me wrong, it’s not about planning 2 weeks ahead, it’s about planning what are they going to do next or tomorrow, not in 2 weeks, or summer. Yes, registering for summer camps, like managing training of your team has to be done with plenty of time.

Managing software projects and managing children is quite similar. There are very big unknowns. Planning two weeks ahead makes not much sense. Alas, planning what are they going to do after school is never easy because you never know how tired they will be, or which mood they will come out with… Plan this big dinner to find out that they had this massive Birthday party and they’ve been fuelled by sugar and noise… So, yes, you have to plan, planning is key… as much as being able to be flexible an improvise.

How? software development left in hands of improvisation? well, don’t get me wrong, it’s not the improvisation that comes with “Don’t have a clue… let’s try this” but the improvisation that comes with experience of being now and there. Key is to plan this or that and if it fails (for any reason) do that other thing or try this other approach.

So, here we are, it’s not about reading the right books, it’s about doing the wrong thing and learning from it. Notice the LEARN bit… any parent with children know their children very well, so when they come home with a foul mood, or tired or XXXX they know how to smooth the transition from school to bed, or how I tell my wife, Bed deployment was success. All unit tests are green, house is quiet.

She text back something along the lines “nerd! … love you”

Life is never easy, but it’s about being flexible

 [1]: http://ivan.pedrazas.me/wp-content/uploads/2013/02/ID-10081433.jpg

gha_language: HTML


text:
### [CVE-2019-19067](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-19067)
![](https://img.shields.io/static/v1?label=Product&message=n%2Fa&color=blue)
![](https://img.shields.io/static/v1?label=Version&message=n%2Fa&color=blue)
![](https://img.shields.io/static/v1?label=Vulnerability&message=n%2Fa&color=brighgreen)

### Description

** DISPUTED ** Four memory leaks in the acp_hw_init() function in drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c in the Linux kernel before 5.3.8 allow attackers to cause a denial of service (memory consumption) by triggering mfd_add_hotplug_devices() or pm_genpd_add_device() failures, aka CID-57be09c6e874. NOTE: third parties dispute the relevance of this because the attacker must already have privileges for module loading.

### POC

#### Reference
- https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.3.8

#### Github
No PoCs found on GitHub currently.

repository: trickest/cve

repo_name: trickest/cve


text:
# structured-log-http-sink
A NodeJS structured-log sink that outputs logs via HTTP POST.

Designed to work with Real Serious Games [Log Server](https://github.com/Real-Serious-Games/LogServer)

repository: structured-log/structured-log-http-sink

repo_name: structured-log/structured-log-http-sink


text:
# Laravel 5 Snippets

[`Laravel 5 snippets`](https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel5-snippets) extension for Visual Studio Code.

## Screenshot

![Screenshot](https://github.com/onecentlin/laravel5-snippets-vscode/raw/master/images/screenshot.gif)

## Usage

Snippet prefix follows Laravel Facades. For example: `Request::`, `Route::`

## Support Snippet Prefix

* Auth
* Cache
* Config
* Console
* Cookie
* Crypt
* DB
* Event
* Hash
* Helper
* Log
* Mail - Contains `Mail::` and `Mailable::` prefix for mail related settings
* Passport (Laravel v5.3 - [API Authentication](https://laravel.com/docs/5.3/passport))
* Redirect
* Relation
* Request
* Response
* Route
* Schema - Contains `Schema::` and `Column::` prefix for database related settings
* Session
* Storage
* View

> Blade - Please install [`Laravel Blade Snippets` extension](https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade) for blade syntax highlighting and better support with blade and emmet.

## Contact

Please file any [issues](https://github.com/onecentlin/laravel5-snippets-vscode/issues) or have a suggestion please tweet me [@onecentlin](https://twitter.com/onecentlin).

## Credits

* Snippets based on [Laravel 5 Snippets for Sublime Text](https://github.com/Lykegenes/laravel-5-snippets)

## License

Please read [License](https://github.com/onecentlin/laravel5-snippets-vscode/blob/master/LICENSE.md) for more information.

repository: swaneck/dotfiles

repo_name: swaneck/dotfiles


text:
## Environment Reporter Payload Examples

With the current GPII implementation, the Environment Reporter detects and reports environmental information to the context manager every 20 seconds. For now, this information only contains the system timestamp. An example of the current environment report:

```
{
    "http://registry.gpii.net/common/environment/timestamp":<PHONE_NUMBER>548,
    "http://registry.gpii.net/common/environment/timeOfDay": "14:39"
}
```

### The Environment Report at Brightness Change

This context change example shows the desired payload flow when the brightness is changed.

Below is an example payload of the environment report when the brightness changes. In this example, the value of ```http://registry.gpii.net/common/environment/illuminance``` is changed from ```200``` to ```500``` and the value of ```"http://registry.gpii.net/common/environment/auditory.noise"``` stays unchanged:

```
{
    "http://registry.gpii.net/common/environment/timestamp":<PHONE_NUMBER>548,
    "http://registry.gpii.net/common/environment/timeOfDay": "14:39",
    "http://registry.gpii.net/common/environment/illuminance": 500,
    "http://registry.gpii.net/common/environment/auditory.noise": 10000
}
```

repository: GPII/gpii-payloads

repo_name: GPII/gpii-payloads


text:
# Bugs

-   Centering issues with page contents on pages. create one layout that all pages are using.

*   When using chrome incognito a user will be logged into a different account. This needs to be discussed with the product manager and Okta. We believe this is an Okta issue.

*   Login page shouldn't be available when logged in.

*   Scanner should clear state instead of the redirect page.

*   If emoji on redirect page is off centered with animation - we think it has to do with font and styling- we suggest using an Emoji Image on the Redirect Page instead of the Emoji code.

repository: donavynhaley/bg-emotion-tracker-fe-b

repo_name: donavynhaley/bg-emotion-tracker-fe-b


text:
# AlloUnity

Developed by [Tibor Goldschwendt, Four Eyes Lab, UCSB](https://ilab.cs.ucsb.edu/index.php/people/6-visitors/86-tibor-goldschwendt-).

AlloUnity will enable the full-surround display of Unity3D-rendered scenes in the AlloSphere. Therefore Unity3D renders the scene to a cubemap. The cubemap is then extracted from Unity3D, H.264 encoded and sent over RTSP/RTP. In the AlloSphere the stream is decoded, drawn as the background of a omni-stereo rendering and displayed.

Work in progress.

## Modules

AlloUnity currently consists of these five modules:

1. **CubemapRenderingPlugin**: C# script for rendering a cubemap in Unity3D.
2. **CubemapExtractionPlugin**: Extracts the cubemap from Unity3D and copies the texture data from the GPU to the CPU.
3. **AlloServer**: Encodes the cubemap as six streams and provides the stream via RTSP/RTP.
4. **AlloPlayer**: Receives the cubemap in the AlloSphere, decodes it and displays it.
5. **AlloShared**: Resources shared between the modules explained above.

## Building

Install dependencies:

- [boost](http://www.boost.org/)
- [FFmpeg](https://www.ffmpeg.org/)
- [x264](http://www.videolan.org/developers/x264.html)
- [live555](http://www.live555.com/liveMedia/)
- [AlloSystem](https://github.com/AlloSphere-Research-Group/AlloSystem)
- [Unity3D 5](https://unity3d.com/)
- [CMake](http://www.cmake.org/)

Then build **Unit3D scene** and **source**.

### Unity3D Scene

1. Create or open a Unity3D scene (placed in `<UnityProjectFolder>`)
2. Import asset `CubemapRenderingPlugin/RenderCubemap.cs`
3. Add `RenderCubemap.cs` to the camera that should be the viewpoint of the rendered cubemap.
4. Build scene for your operating system (named `UnityProject`)

### Source

Build source with CMake and your favourite build environment, e.g.:

```bash
cmake -G "Unix Makefiles" -DUNITY_PROJECT_PLUGIN_DIR:PATH=<UnityProjectFolder>/Assets/Plugin
make
```
On success, this places

- *CubemapExtractionPlugin* in `<UnityProjectFolder>/Assets/Plugins/`
- *AlloServer* and *AlloPlayer* in `Bin/`
- *AlloShared* in `Lib/`

Compilation tested with Visual Studio 2013 Ultimate on Windows, Xcode 6 on OS X and make on Ubuntu.

## Launching

1. Start `<UnityProject>` on rendering machine
2. Start *AlloServer* on rendering machine
3. Start *AlloPlayer* on display machine

Order matters!

## License

BSDv3 License.

repository: AlloSphere-Research-Group/AlloStreamer

repo_name: AlloSphere-Research-Group/AlloStreamer