text:
## Hybrid Logical Clock

`@consento/hlc` is a [Hybrid Logical Clock][HLC] implementation in JavaScript.
You can use this in a decentralized system to sort statements created by tow
separate devices.

> **TL;DR**: This clock will use the system clock unless the system clock is behind
another known timestamp, in which case it will increment a counter.

It is comparable to [CockroachDB's implementation][CockroachHLC].
It creates Timestamps with a nanosecond WallClock _(using [bigint-time][bigint-time])_ that supports de-/encoding
to fixed size 96bit Uint8Arrays _(compatible with [codecs][codecs])_ or JSON object.

[HLC]: https://muratbuffalo.blogspot.com/2014/07/hybrid-logical-clocks.html
[CockroachHLC]: https://github.com/cockroachdb/cockroach/blob/663fcf17cb8789a2c46a719e0107a15400eee918/pkg/util/hlc/hlc.go
[bigint-time]: https://github.com/consento-org/bigint-time
[codecs]: https://github.com/mafintosh/codecs

## Usage

```javascript
const HLC = require('@consento/hlc')
const clock = new HLC({
  wallTime: require('bigint-time'), // [default=bigint-time] alternative implementation, in case `bigint-time` doesn't solve your needs
  maxOffset: 0, // [default=0] Maximum time in nanosecons that another timestamp may exceed the wall-clock before an error is thrown.
  toleratedForwardClockJump: 0, // [default=0] Maximum time in nanoseconds that the wall-clock may exceed the previous timestamp before an error is thrown. Setting it 0 will disable it.
  wallTimeUpperBound: 0, // [default=0] will throw an error if the wallTime exceeds this value. Setting it to 0 will limit it to the uint64 max-value.
  last: null, // [default=undefined] The last known timestamp to start off, useful for restoring a clock's state
})

const timestamp = clock.now()

// Makes sure that the next timestamp is bigger than the other timestamp
clock.update(new HLC.Timestamp(1))

// Turn the clock into an Uint8Array
const bytes = timestamp.encode() // Shortform for HLC.codec.encode(timestamp)
const restored = HLC.codec.decode(bytes)

const buffer = timestamp.encode(Buffer.allocUnsafe(16)) // If you prefer a Buffer instance
```

## FAQ

- [When to use HLCs?](https://github.com/consento-org/hlc/blob/main/faq/when-hlc.md)
- [Why HLC timestamps are not unique?](https://github.com/consento-org/hlc/blob/main/faq/non-unique.md)
- [Why use 96bit instead of 64bit?](https://github.com/consento-org/hlc/blob/main/faq/why-96bit.md)

## Clock Drift

> **TL;DR** There is no one-size-fits all solution to clock drifts, so you need to consider your strategy for this.

In a decentralized system, the wallclock of a different device may be ahead of the current device's wall-clock
_(see ["Clock Drift" at Wikipedia](https://en.wikipedia.org/wiki/Clock_drift))_. This means we need to allow
wallclocks in updates to be newer/bigger than our own.

But if we allow this a malicous or broken implementation could create a timestamp that is set to `UINT64_MAX_VALUE`
with a logical clock of `UINT32_MAX_VALUE` and then we can not have a newer clock.

The `maxOffset` option comes into play when syncing with other devices and how accurate the timestamp is on these
devices. If they are perfectly in sync a `maxOffset=0` might be a good idea, but in real life conditions: 20 seconds
up to a minute should be considered a good idea [[ref](https://superuser.com/a/1212945)].

_Provoking a clock-drift error with a set `maxOffset`:_
```javascript
const clock = new HLC({
  maxOffset: 60 * 1e9 /* 1 minute in nanoseconds */
})
const timestamp = clock.now()
clock.update(
  new HLC.Timestamp(timestamp.wallTime + BigInt(120 * 1e9))
)
```
```
ClockOffsetError: The received time is 119061ms ahead of the wall time, exceeding the 'maxOffset' limit of 60000ms..
    at HLC.update (/consento/hlc/index.js:166:15) {
  type: 'ClockOffsetError',
  offset:<PHONE_NUMBER>18n,
  maxOffset:<PHONE_NUMBER>0n
}
```

## Wallclock Limits

> **TL;DR** Timestamps can be broken and you may want to set a limit in order for the broken timestamps to not ruin the whole system.

Additional to the previous explanation, a clock of a users/server device may be set to any given number.

This means that your physical clock could simply be set to a ridiculous value that breaks the clocks functionality.
The `wallTimeUpperBound` option allows you to prevent this and make sure that even if a devices clock is tuned to
11 your application/service can be fixed with an update.

For example: If you know that any application running **will** be updated within a two year period and you are okay
for the older versions to not work anymore, then it makes sense to set `wallTimeUpperBound` to a fixed `bigint`
timestamp of "now + 2years". Applications older than 2 years will stop working. Maybe 2 years is a bit tight, then
you could set it to a 100 years.

_Provoking a wall-time-verflow error with a set `wallTimeUpperBound`:_
```javascript
const wallTimeUpperBound = BigInt(new Date('2022-01-01T00:00:00.000Z').getTime()) * BigInt(1e6)
const clock = new HLC({
  wallTime: () => wallTimeUpperBound + 1n, // Faking a wallTime that is beyond the max we allow
  wallTimeUpperBound
})
clock.now()
```
```
WallTimeOverflowError: The wall time<PHONE_NUMBER>000ms exceeds the max time of<PHONE_NUMBER>000ms.
    at HLC.update (/consento/hlc/index.js:185:13)
    at HLC.now (/consento/hlc/index.js:154:17) {
  type: 'WallTimeOverflowError',
  time:<PHONE_NUMBER>000000001n,
  maxTime:<PHONE_NUMBER>000000000n
}
```

## Runtime Clock Manipulation

> **TL;DR** The system clock can be manipulated and you need to some extra effort to have some safeguard against it.

An alternative way to `wallTimeUpperBound` for restricting clock drifts is `toleratedForwardClockJump`. It will
prevent that the `wallClock` exceeds the last known wall-clock by a given amount. Combined with an interval this
makes sure that an error occurs when the physical clock suddenly jumped too far like this:

```javascript
const clock = new HLC({
  toleratedForwardClockJump: 10 * 1e9 /* 10 seconds in nanoseconds */
})
// We update the clock every second, which should prevent that error from happening
setInterval(() => clock.now(), 1)
```

If we forget to update the clock in time or someone manipulates the clock an error is thrown:

```javascript
const clock = new HLC({
  toleratedForwardClockJump: 1e6 /* 1 ms in nanoseconds */
})
setTimeout(() => clock.now(), 10) // we didn't update the clock in 10 seconds
```
```
ForwardJumpError: Detected a forward time jump of 11ms, which exceed the allowed tolerance of 1ms.
    at HLC.update (/consento/hlc/index.js:165:13)
    at HLC.now (/consento/hlc/index.js:157:17) {
  type: 'ForwardJumpError',
  timejump: 11036527n,
  tolerance: 1000000n
}
```

## Clock drift monitoring

Running a system you may want to track how much a clock drifts.

The cockroach db counts how often the 1/10th of `maxOffset` is reached in the [`monotonicityErrorCount`][monotonicityErrorCount] property.

Since there may be various ways how to track this, you can just extend the
`HLC` class for monitoring any way you like:

```javascript
const HLC = require('@consento/hlc')

class CockroachHLC extends HLC {
  constructor (opts) {
    super(opts)
    this.monotonicityErrorCount = 0
  }
  validateOffset (offset) {
    super.validateOffset(offset)
    if (this.maxOffset > 10n && offset > this.maxOffset / 10n) {
      this.monotonicityErrorCount += 1
    }
  }
}

const clock = new CockroachHLC({ maxOffset: 20 })
```

[monotonicityErrorCount]: https://github.com/cockroachdb/cockroach/blob/663fcf17cb8789a2c46a719e0107a15400eee918/pkg/util/hlc/hlc.go#L65-L67

## Deserialization

The system allows not just the de-/serialization of timestamps using **sortable** Uint8Array or Buffers:

```javascript
HLC.codec.encode(timestamp, [byob, offset])
HLC.codec.decode(uint8Array, offset=0)
```

The deserialization to `JSON` works simply using `.toJSON`:

```javascript
const jsonObject = clock.now().toJSON()
const timestamp = new HLC.Timestamp(json)
```

However unlikely, it is also possible to save/restore the entire clock using `JSON`:

```javascript
const clock = new HLC()
const restored = new HLC(clock.toJSON())
```

## License

[MIT](./LICENSE)

repository: consento-org/hlc

repo_name: consento-org/hlc


text:
PeerBlock

v518.

a slightly modified version of PeerBlock,

with an updater (external-program) that removes the old cache
and updates the direct-URL to each list directly to the configuration file,
(it requires PeerBlock to be closed first), on the next run you should click the
update-button so PeerBlock will fetch the updated-content of each of the lists.
works well with the classic lists.

the updater-code is beta/unstable so it is currently password-protected,
to avoid damaging /ones configuration\.

license: Unlicense

repository: vaginessa/eladkarako-software-mods

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: vaginessa/eladkarako-software-mods


text:
This is a simple pong game written in python.  It uses simplegui to display the game.

Keys:

Player 1:

w - up

s - down

Player 2:

keyup: up

keydown: down

It can be played at:

http://www.codeskulptor.org/#user23_cQQt1vxUxkdlJE3.py
![alt tag](https://github.com/lymanwong/Python-projects/blob/master/wong_pong/wong_pong_screenshot.png)

license: MIT

repository: lymanwong/Python-Projects

repo_name: lymanwong/Python-Projects


text:
---
title: 'Documentation Guide'
sidebar_order: 2
---

A part of every development project (especially Open Source projects) is documentation that explains how it works. Sentry and Raven are not any different. Because documentation is a big part of what makes Sentry work we’ve outlined some guidelines about how this documentation is structured and how to extend it.

## Stylistic Choices

These are some general guidelines on the style of the language and text layout:

### Language

The language used in the documentation shall follow American English as much as possible. The exception to that rule are quotations, trademarks or terms that are better known by their British English equivalent.

### Headlines

Capitalization of headlines is always a heavily disputed topic. We generally follow these rules:

-   Headlines are capitalized
-   Words separated by dashes are generally capitalized on the first word only unless it’s a well known term that demands title case (for instance because it’s also known by an acronym). So for instance it’s “Time-series” and “Sans-serif” but “Single Sign-On”
-   A headline must never follow another smaller headline unless there is text in between. If you cannot achieve that, you should leave out one of the headlines.

### The Reader / The Author {#the-reader-the-author}

The documentation prefers “we” to address the author and reader in one go. So for instance “We are going to step through this code snippet.” is a good example of this.

The gender of the reader shall be neutral if possible. Attempt to use “they” as a pronoun for the reader. If that reads bad, “he” is a suitable substitute. Do not use “her” as a pronoun as it confuses non native English readers.

### Paragraphs

Avoid too many short paragraphs in short succession as they read and render terribly. If you end up in a situation where you think you need this, consider using an enumeration instead.

## Documentation Source

The documentation is Markdown format. There are some rules you should follow when editing those files:

For headlines the following styles should be used:

```markdown
# First Level

## Second Level

### Third Level

#### Fourth Level
```

Please do not use more levels than that as they do not display well.

repository: sirinartk/sentry-docs

gha_language: JavaScript

repo_name: sirinartk/sentry-docs


text:
# Theory-Of-Algorithms-CA
# Problem 7 : Maj

Write a function maj in racket that takes three lists x,y and z of equal length and containing only 0's and 1's. It should return a list containing 1 where two or more of the x y or z values are 1,  and 0 otherwise
For example:
>(maj (list 0 0 0 0 1 1 1 1) (list 0 0 1 1 0 0 1 1) (list 0 1 0 1 0 1 0 1))
'(0 0 0 1 0 1 1 1)

repository: Ryan-Gordon/Theory-Of-Algorithms-CA

repo_name: Ryan-Gordon/Theory-Of-Algorithms-CA


text:
First, let's look at a few plain IDL examples, no SSW needed. In the simplest case, we can return some quantity generated by IDL (no inputs required) and return it to our Python session. This example comes from [Coyote's Guide to IDL Programming](http://www.idlcoyote.com/idl_way/smallexamples.html#EXAMPLE2).

```python
import hissw
import matplotlib.pyplot as plt
script = '''
n = 5
i = REBIN(LINDGEN(n), n, n)
j = REBIN(TRANSPOSE(LINDGEN(n)), n, n)
mask = (i GE j)
'''
ssw = hissw.Environment()
results = ssw.run(script)
plt.imshow(results['mask'])
```

This should generate a plot that looks something like this,
![Example 1](../images/ex1.png)

But what if we want to input the size of our upper triangular array with Python? We can use [Jinja templating syntax](http://jinja.pocoo.org/docs/2.10/templates/#synopsis) in our IDL script and then pass in an argument for `n`,

```python
script = '''
n = {{ n }}
i = REBIN(LINDGEN(n), n, n)
j = REBIN(TRANSPOSE(LINDGEN(n)), n, n)
mask = (i GE j)
'''
results = ssw.run(script, args={'n': 100})
plt.imshow(results['mask'])
```
![Example 2](../images/ex2.png)

repository: wtbarnes/hissw

branch_name: refs/heads/main

gha_language: Python

gha_license_id: MIT

repo_name: wtbarnes/hissw


text:
# Mark it Off

Mark it Off is a time sensitive task list where Users will be able to create a to-do list, and each task will automatically be  oraganized from newest to oldest. The tasks will then turn from green to red over the course of seven days, and after seventh day, it will then be marked as failed, and deleated.

## Where is the site?

Mark it Off was originally hosted on Heroku, but after some time, errors occured, and Heroku will no longer support Mark it Off due to some version issues. I will work on figuring out exactly what the issue it, and solve it, but for now, I am in the works on a much larger project.

### Site Navigation

The first thing you will notice is the design! It portrays a very early Linux/Windows look.

Mark it Off displays each task using a well organzied "centered-vertical" flex-box style, along with nice animations to accompany the creation and deletion of each task.

On your first log on, you will be welcomed with a quick tutorial bubble to teach you what to do to get started, just type in the box to create your first task and begin!

When a task is successfully created, a notice bubble will appear to confirm the completion.

![markitoff](http://brandonarmand.com/images/blocitoff1.png "Post Tutorial")

## Built With

* [Ruby on Rails](https://rubyonrails.org) - Back-end framework
* [jQuery](https://jquery.com) - Ajax animations
* [Devise](https://github.com/plataformatec/devise) - User Authentication
* [PostgreSQL](https://rubygems.org/gems/pg/versions/0.18.4) - Production database

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

repository: BrandonArmand/Mark-it-Off

repo_name: BrandonArmand/Mark-it-Off


text:
# Note
This repository is not maintained now. For updates see https://github.com/biorobotics/cmu-dodecapen

# Visual-6-DoF-pose-tracker
This is a repository on top of the DodecaPen base code.
This code is in Python 2.7 but we would like to have the option to port it to Python 3.5 or higher.
For now please write python3 compatible code by adding the folowing lines on top:

```from __future__ import division```

```from __future__ import print_function```

However, do not run the code in python3 as you may have some problems woth ROS OpenCV distro.

DodecaPen is based of Po-Chen Wu's thesis work. This is an implematation of the paper __DodecaPen: Accurate 6DoF Tracking of a Passive Stylus__

Po-Chen's papers, thesis is quite helpful for understanding the theory behind the code.

This is the website: http://media.ee.ntu.edu.tw/personal/pcwu/ . His thesis can be downloaded from here.

# Branch Convention
Please do not commit to master. The master should have fully working codes at all times.

Currently there is a dev branch. If you are adding new features, please commit them to the dev branch and raise pull requests to master. Also, before placing a pull request, please make sure your code is "merge-able" GitHub will let you know if there are issues.

You can start by cloning the dev branch with :

 ```git clone -b dev https://github.com/arkadeepnc/Visual-6-DoF-pose-tracker.git```

# REQUIREMENTS

UBUNTU 16.04 LTS [ not sure if it works with virtual Linux machine in Windows ]

ROS KINETIC

ros point_grey_camera_driver

Read the Docs here: http://wiki.ros.org/pointgrey_camera_driver

Install prebuilt bins from source :

```sudo apt-get install ros-kinetic-pointgrey-camera-driver```

Connect camera to USB 3.1 (blue port). USB 2 would not work!! Start camera with :

```roslaunch pointgrey_camera_driver camera.launch```

Check feed
```rostopic echo /camera/image_color ```

should show a bunch of numbers in the screen within seconds after hitting return! Or else rostopic is dead.

# Library dependencies:
[all are basic and should be there if your Ubuntu-ROS do not hate each other]

numpy (latest)

OpenCV contrib (test it as with the following in the terminal: >python -> >import  cv2 -> >from cv2 import aruco)

rospy

matplotlib

transforms3d (pip install transforms3d)

scipy (check pypi for latest distro)

snakeviz -- for profiling your code

# Get started
Open terminal in /src . Begin by running :

```python video_drawing_with_Dodeca.py ```

This will go through a video of the pen tip moving on a plane and generate the point cloud for the tip of the pen.

If you want to convert the code to C++ this might be a good starting point

https://github.com/neconeconeco/PressPen --> https://github.com/neconeconeco/PressPen/tree/master/Pen%20Tracking%20Algorithm


text:
# Installation
This document contains instructions for installing the Ruby library `learning_studio_authentication` for both development and production environments.

Before we dig further into the installation process, let's see what the pre-requisites are.

-  **Ruby 1.9.3p547** (This library has been developed and tested on this Ruby versions. It should work with 1.9.x and 2.0.x versions of Ruby, but for now, using Ruby 1.9.3p547 is highly recommended.)
- **Crypto++, v5.2.0** Using a native installation for your OS is highly recommended even though it can be installed from the source as well.
    1. **Installing from Source on any platform**
        Download Source from here: http://sourceforge.net/projects/cryptopp/files/cryptopp/5.2.1/cryptopp521.zip/download?use_mirror=kaz and install it.

    2. **Installation on Mac OS X (10.9.2) using Homebrew**
    If you have Homebrew installed, you can install Cypto++ by running the following command:
    ```sh
    brew install cryptopp
    ```
    3. **Installation on Ubuntu 13.04 using apt-get**
    Run the following command from your terminal:
    ```sh
    sudo apt-get install libcrypto++ libcrypto++-dev
    ```
- **RVM** (For dev environments)
To get instructions on how to install RVM and more details, please see https://rvm.io

## Installation on Dev Environments
If you want to play around with the source code for debugging purpose, follow the steps below.

- Get the latest source code and cd into `/your/path/learning_studio_authentication`
- Using RVM, create a new gemset for the project using
```sh
rvm 1.9.3p547@your_gemset_name --create --ruby-version
```
- Install all the dependencies using `bundler`.
```sh
bundle install
```
- Build the native extensions for Crypto++ using the following commands
```sh
cd ext/learning_studio_authentication
bundle exec ruby extconfig.rb
```
- This will create a `Makefile`. Then run the following command to generate the shared object for crtyptopp module which can be loaded using Ruby.
```sh
make
```

**NOTE**: Any project which requires this library needs to have the dependency specified in the Gemfile for development environments. Find the Gemfile of the project that you're working on and update the path to the Authentication Library.

For example, the Gemfile of the Core library should have

```ruby
gem 'learning_studio_authentication', :path=>'/your/path/learning_studio_authentication'
```

After this process, you should be able to require the gem into any Ruby script

```ruby
require 'learning_studio_authentication'

puts LearningStudioAuthentication.version
```

## Installation on Production Environments
For production environments we have to package the library as a `gem` so that anyone can install it. Run the following commands to build the gem and install the library using it.

```sh
cd /your/path/learning_studio_authentication
bundle install
gem build learning_studio_authentication.gemspec
```

This should generate a new file named `learning_studio_authentication-0.0.1.gem`. You can install the gem using the following command (You can copy the gem).
```sh
gem install learning_studio_authentication-0.0.1.gem
```

After this process, you should be able to require the gem into any Ruby script

```ruby
require 'learning_studio_authentication'

puts LearningStudioAuthentication.version
```

To know more in detail about how to use the gem, see README and yard documentation for the project.


text:
## v0.5.5 - 12/12/2011

* bump JSHint to latest (SHA ~> 3585b1eae9b7d218b27cca183d0788bb661a7572)

## v0.5.4 - 09/12/2011

* fix .jshintignore support on Windows (remove trailing `\r`) - [Issue #55](https://github.com/jshint/node-jshint/issues/55)

## v0.5.3 - 06/12/2011

* fixed breakage on Windows (i.e process.argv[0] differs)

## v0.5.2 - 27/10/2011

* allow for Unicode Byte Order Mark in analyzed files
* stop printing "Lint Free!" when no errors are found

## v0.5.1 - 15/10/2011

* fixed process.exit calls being ignored in reporters (and always returning 0)

## v0.5.0 - 12/10/2011

* support node 0.5.x (use minimatch package instead of glob)

## v0.4.0 - 10/10/2011

* updated jshint to latest

## v0.3.1 - 05/09/2011

* fixed reporter logging not getting fully flushed to stdout (when process exited)

## v0.3.0 - 20/08/2011

* added .jshintignore file support
* added cli option to display non error data generated by jshint
* jslint xml reporter exits process with appropriate status code

## v0.2.3 - 22/06/2011

* add bin and lib to "files" array
* added "preferGlobal" to package.json
* allowed comments in config files

## v0.2.2 - 25/05/2011

* fixed a problem that occurs when predef is defined in a project file but there is no homeconfig
* bumped JSHint to 2011-04-16

## v0.2.1 - 06/05/2011

* fixed bug when either the $HOME/.jshintrc or the project specific .jshintrc is missing, neither is used
* added the path to the executable for npm 1.0.x

## v0.2.0 - 06/04/2011

* added the ability for a project specific .jshintrc file (in the current working directory)
* switched custom reporter to be module that exports a reporter function (instead of evaluating a file)
* bumped JSHint to 2011-04-06

## v0.1.9 - 29/03/2011

* remove ./ from file name in jslint xml reporter

## v0.1.8 - 27/03/2011

* jshint already removes shebangs itself
* added a jslint compatible xml output formatter option

## v0.1.7 - 23/03/2011

* fixed line number reporting being off by one when file has a shebang

## v0.1.6 - 21/03/2011

* removed bin property in package.json

## v0.1.5 - 20/03/2011

* exit process with appropriate status code after lint
* use ~/.jshintrc as default options if available
* added --version option

## v0.1.4 - 01/03/2011

* updated JSHint to 2011-03-01 edition (7c4d2acec850beceff8b)

## v0.1.3 - 26/02/2011

* enable require('jshint') when installed through npm
* omitted "node-" prefix in cli and npm package name
* bumped jshint to latest (b81e938959444dd2a9e2)

## v0.1.2 - 24/02/2011

* bumped jshint to latest (3b018b1e454d3917e33c)

## v0.1.1 - 21/02/2011

* reafactored portion of cli into hint module
* switched to jasmine for tests
* custom reporters

## v0.1.0 - 20/02/2011

* initial commit

repository: oconnore/email-plusplus

repo_name: oconnore/email-plusplus


text:
```haskell
module Qcheck where
import Test.QuickCheck
import Data.Char

```
# Property-Based Testing with QuickCheck.
# Kofi Appiah 17 April 2021
# Revised 23/4/21

## Getting QuickCheck [3]

You will need QuickCheck installed to be able `import Test.QuickCheck`.
### Install QuickCheck in Linux - Ubuntu
```
sudo apt-get install hlint haskell-platform libghc-quickcheck2-dev
```
### Install QuickCheck in Linux - Fedora
```
sudo yum install ghc-QuickCheck-devel
```
### Using Cabal
1.	cabal update
2.	cabal install QuickCheck --lib

## Introduction

Up to this point, you have mainly tested your functions/code manually.  However, it is possible to automatically test your functions in Haskell through property-based testing. The tool **QuickCheck**[1], which can be used to quickly generate many tests will be discussed. Testing a program is a core part of the working programmer's toolkit, which plays a key role in maintaining the software quality as well as keeping the code on the straight-and-narrow path. In Haskell, the main testing mechanisms are the traditional unit testing and its more powerful descendant, the type-based "property" testing with a tool like QuickCheck (but there are others). Unit testing tests the smallest atomic units of a code independently of one another and does not necessarily verify that they all work together properly.

Property testing was pioneered in Haskell and now adopted by other languages. It tests the formal properties without requiring formal proofs. A key aspect of property-based testing is to try the entire code with very many tests that would be infeasible to write by hand, mainly to uncover subtle edge cases that wouldn't be found otherwise. Property-based testing is useful in ensuring that the code meets the minimum requirements to satisfy laws, such as the laws of associativity or monads. Hence, when there are no assertable, truth-valued properties, property-based testing would not be an appropriate choice.

In general, the Haskell compiler can be used to judge a well-typed code. However, a Haskell code can be well-typed and still not perform as expected or even have some runtime errors. That is where testing can be used to state an expectation, and then verify that the results of an operation meets that expectation. In summary, unit testing can be viewed as automating manual tests, while property testing is essentially automating unit tests.

## QuickCheck
QuickCheck is a tool which aids the Haskell programmer in formulating and testing properties of programs by describing properties as Haskell functions [1]. The functions can then be tested with randomly generated inputs based on the type. It is also possible to define custom test data for the property based functions. Properties are normally written in the same module as the functions they test, where they serve also as checkable documentation of the behaviour of the code. Test cases are randomly generated and the programmer can control the test data generation as discussed in [1].

As a first example, we will consider the function `isPalindrome` which returns true when applied to a string which reads the same backward as forward.
```haskell

isPalindrome :: String -> Bool
isPalindrome txt = txt == reverse txt

```
The next meaningful thing is to test the function with a few examples (manually) to make sure it works as expected. Apply `isPalindrome` to words like "level", "kayak" and "refer", and expect it to return `True` in all the cases. If the specification demands that both "rotator" and "rotator!" should return true when `isPalindrome` is applied, then the function will have to be redefined or improved.

A simple but more specific fix to the "racecar" and "racecar!" problem is in `isPalindrome'`. But what happens if our next set of test cases include "rotator?"; as in

```haskell
isPalindrome' "rotator?"
```
```haskell
isPalindrome' :: String -> Bool
isPalindrome' txt = alltxt == reverse alltxt
  where alltxt = filter (not . (`elem` ['!'])) txt
```
Now to fully test `isPalindrome'`, it will be important to know how the function behaves with other punctuation. It is clear that the definition of `alltxt` can get very long as more punctuation marks get included and even harder to exhaustively test manually. In order to utilise QuickCheck's testing capabilities and hence the random test generator, a property will have to be defined for the function. In the case of `isPalindrome'`, the property can be a test for any string with or without punctuation. The expression `alltxt` can be refactored into a function like `freeFrom` to include more punctuation marks and the function `isPalindrome''` defined to use `freeFrom`.
```haskell
freeFrom :: String -> String
freeFrom txt = filter (not . (`elem` ['!', '?', ';'])) txt

isPalindrome'' :: String -> Bool
isPalindrome'' txt = alltxt == reverse alltxt
  where alltxt = freeFrom txt

```
The function to be really tested is `freeFrom`, which should be *punctuation invariant* and the function to express this will use `isPunctuation` from `Data.Char` as defined in `prop_pInvariant`.
```haskell
prop_pInvariant :: String -> Bool
prop_pInvariant txt = freeFrom txt == filter (not . isPunctuation) txt

```
In effect, the property defined in `prop_pInvariant` specifies that *applying `freeFrom` to any string `txt` should give the same answer as applying it to a string with no punctuation*. It makes it easier to have the property defined in code, so the QuickCheck library can be used to test it automatically. To use QuickCheck, call the `quickCheck` function on the property:

```haskell
quickCheck prop_pInvariant
```
The function `quickCheck` takes a property as parameter and applies it to a large number of randomly generated arguments (by default 100 but can be increased), it returns "OK" if the results is true in every case and reports counter-examples otherwise. The test at this point is bound to fail. A test output like the one below, shows that in passing values to the property, QuickCheck tried the `String` "%", which is a Unicode punctuation mark, which caused the property to fail.
``` haskell
*** Failed! Falsifiable (after 7 tests and 1 shrink):
"%"
```
To see all the test cases generated by QuickCheck, call `verboseCheck` on the property:
```haskell
verboseCheck prop_pInvariant
```
In the case of `prop_pInvariant`, we test for equality with the simple `==` in Haskell and hence the function application returns `True` or `False`. If we are rather interested in returning the test data, the extensional equality `===` defined in QickCheck can be used as in `prop_pInvariant'`. In the case of `prop_pInvariant'`, a verboseCheck will return the evaluation of the actual terms.
```haskell
verboseCheck prop_pInvariant'
```
Example verboseCheck prop_pInvariant may return:
Failed:
"'\169"

verboseCheck prop_pInvariant' may return:
Failed:
"'\128"
"'\128" /= "\128"

```haskell

prop_pInvariant' :: String -> Property
prop_pInvariant' txt = freeFrom txt === filter (not . isPunctuation) txt

```

As a second example, the commutativity of addition defined in the function `comAddition` can be ascertained using QuickCheck, by defining the property `prop_Comaddition`.
```haskell
comAddition :: Int -> Int -> Int
comAddition i j = i + j

prop_Comaddition :: Int -> Int -> Bool
prop_Comaddition x y = comAddition x y == comAddition y x

```
Testing the property `prop_Comaddition` with QuickCheck should return:
```haskell
quickCheck prop_Comaddition
+++ OK, passed 100 tests.

```
showing that QuickCheck randomly generated 100 `Int` pairs and they all passed the test.
The `Prelude` function `reverse`, satisfies a number of laws like:
* The reverse of a single item list is the same as the list : `reverse [x] == [x]`
* The reverse of the concatenation of two lists `xs ++ ys` is the same as the reverse of the second list `ys` concatenated with the reverse of the first list `xs`: `reverse (xs ++ ys) == reverse ys ++ reverse xs`
* The reverse of the reverse of a list is the same as the original list : `reverse (reverse xs) == xs`

Similar to the previous examples, to check the three laws of `reverse` above using QuickCheck, they will all have to defined using Haskell functions as:
```haskell
prop_revUnit x = reverse [x] == [x]

prop_revConcat xs ys = reverse (xs ++ ys) == reverse ys ++ reverse xs

prop_doubleRev xs = reverse (reverse xs) == xs

```
Calling `quickCheck` on all the three properties above will pass. However, if the `prop_revConcat` property is defined as in `prop_revConcat'`, then the test would fail with a counter-example like

```haskell
quickCheck prop_revConcat'
*** Failed! Falsifiable (after 4 tests and 6 shrinks):
[0]
[1]

```
**Note:** QuickCheck uses the type to generate random test data, so the defined property for testing should have a type. In the case of a list, QuickCheck may use a number of `[]` if the type is not defined.
```haskell
prop_revConcat' :: [Int] -> [Int] -> Bool
prop_revConcat' xs ys = reverse (xs ++ ys) == (reverse xs) ++ (reverse ys)

```
The function `quickCheck` is actually overloaded, in order to be able to handle laws with varying number of types, and the overloading cannot be resolved if the law itself has a polymorphic type. Hence, the need to specify a fixed type at which the law is to be tested.

Another interesting example is a test of *idempotency* (applying a function twice has the same effect as applying once) on a sort algorithm, just as for reverse `prop_doubleRev`. The function to test is `tSort`:
```haskell

tSort :: Ord a => [a] -> [a]
tSort []     = []
tSort (x:xs) = tSort lhs ++ [x] ++ tSort rhs
  where lhs = filter (< x) xs
        rhs = filter (>= x) xs
```
As usual we can manually test `tSort` to ensure its robustness:
```haskell
tSort [21, 20..15]
tSort $ [21, 20..15] ++ [1, 3..9]
```

We can even test that the output of `tSort` is in fact sorted by defining a function `isOrdered` and a property `prop_tSort_Ordered`, which specifies that *applying `tSort` to a list of `Int` result in an ordered list*.
```haskell
isOrdered :: Ord a => [a] -> Bool
isOrdered xs = and (zipWith (<=) xs (tail xs))

prop_tSort_Ordered :: [Int] -> Bool
prop_tSort_Ordered xs = isOrdered (tSort xs)
```
Calling `quickCheck` on the property `prop_tSort_Ordered` should return OK as shown:
```haskell
quickCheck prop_tSort_Ordered
+++ OK, passed 100 tests.

```
The idempotency property can be written as a function `prop_idempotent`, which states an equality must hold for any input data that is sorted.
```haskell

prop_idempotent:: [Int] -> Bool
prop_idempotent xs = tSort (tSort xs) == tSort xs

```
The property defined in `prop_idempotent` can be tested manually as well as automatically using QuickCheck.

```haskell

*Qcheck> prop_idempotent []
True
*Qcheck> prop_idempotent [2, 4, -1, 0, 7, -8]
True
*Qcheck> prop_idempotent [6..29]
True
*Qcheck> quickCheck prop_idempotent
+++ OK, passed 100 tests.
*Qcheck>
```

`prop_doubleRev'`, the alternative definition of `prop_doubleRev`; which is a definition of idempotence, could be used for both sorting and reversing.

```haskell

prop_doubleRev' :: [Int] -> Property
prop_doubleRev' xs = (reverse . reverse) xs === id xs

```

Some properties (like "the head of a sorted list is the minimum value in the list"), hold under some specific conditions and QuickCheck provides an implication combinator to represent such conditional properties. In the case of testing the head of a sorted list to be the minimum element, the precondition is the list should not be empty and the property can be defined in Haskell as:

```haskell

prop_Sorted_min :: [Int] -> Property
prop_Sorted_min xs = not (null xs) ==> head (tSort xs) == minimum xs

```

```haskell
quickCheck prop_Sorted_min
+++ OK, passed 100 tests.

```

The result type of the property `prop_Sorted_min` is not `Bool` but `Property`, because instead of checking the property for 100 random test cases, QuickCheck rather checks the property with 100 test cases that satisfies the condition `not (null xs)`.
QuickCheck is able to formulate properties that quantify over functions as well.

## Programmer-defined types and Arbitrary instances
Up to this point, it is clear that in QuickCheck test data is generated randomly based on the type. But how can QuickCheck generate random data for a programmer-defined type? QuickCheck introduces a type class `Arbitrary`, of which a type is an instance if one can generate arbitrary elements in it. QuickCheck relies on the type class called `Arbitrary`, a newtype called `Gen` for generating its random data and `arbitrary`, which is a value of type `Gen`.

```haskell
class Arbitrary a where
  arbitrary :: Gen a
```

`Gen a` is an abstract type representing a generator for type `a`. The type `Gen` is defined as

```haskell
newtype Gen a = Gen (Rand -> a)

```

`Rand` is a random  number seed; a generator is just a function which can manufacture an `a` in a pseudo random way. `sample :: Show a => Gen a -> IO ()` from the `Test.QuickCheck` module can be used to see some of the random data. It is possible to specify your own data for generating `Gen` values. This is a function `alwaysSOF3`that will always return "SOF3" of type `String`.
```haskell

alwaysSOF3 :: Gen String
alwaysSOF3 = return "SOF3"

```

QuickCheck defines test data generation via an instance of the class `Arbitrary` for each type and relies on the programmer to provide instances for the user-defined types. Combinators are provided to enable the programmer to easily produce generators. The simplest is `oneof`, which makes a choice among a list of alternative generators with a uniform distribution. For example, if the type `College` is defined by:

```haskell

data College = Alcuin | Halifax | Wentworth deriving Show

```

Then, a suitable generator can be defined by:

```haskell

instance Arbitrary College where
 arbitrary = oneof [return Alcuin, return Halifax, return Wentworth]

```

As another example, define a simple data type `Vector` that holds two `Int` values and how to display it:

```haskell

data Vector = TwoD Int Int

instance Show (Vector) where
  show (TwoD a b) = "<" ++ show a ++ "," ++ show b ++ ">"

```

To use the `Vector` data type in QuickCheck, you need to provide an implementation of `Arbitrary` as:

```haskell
instance Arbitrary Vector where
  arbitrary = do
    a <- arbitrary
    b <- arbitrary
    return $ TwoD a b

```

Just `a <- arbitrary` and `a <- arbitrary` in the class instance is enough to get the random `Ints`. Haskell will infer their types from the specification of `Vector` and will provide the appropriate arbitrary implementation, thus QuickCheck can now produce random Vectors with:

```haskell

sample $ (arbitrary :: Gen Vector)

```

It is also possible to define a `Trail` as a list of `Vector`:

```haskell

newtype Trail = Trail [Vector] deriving Show

```

In this case, the implementation of `Abitrary` that will allow the use of the `Trail` type in QuickCheck is:

```haskell

instance Arbitrary Trail where
  arbitrary = do
      list <- arbitrary
      return $ Trail list

```

It is now possible for QuickCheck to produce random list of `Vector` using

```haskell

sample $ (arbitrary :: Gen Trail)

```

## References

[1]: Koen Claessen and John Hughes. 2011. QuickCheck: a lightweight tool for random testing of Haskell programs. SIGPLAN Not. 46, 4 (April 2011), 53–64. DOI:https://doi.org/10.1145/1988042.1988046
[2]: Bryan O'Sullivan, John Goerzen and Don Stewart. 2009. Real World Haskell. O'Reilly.

[3]: https://hackage.haskell.org/package/QuickCheck

```haskell

```

repository: KristoffLiu/YorkCSSolution

repo_name: KristoffLiu/YorkCSSolution


text:
---
title: MySqlDataSource.CreateConnection method
---

# MySqlDataSource.CreateConnection method

Creates a new [`MySqlConnection`](../../MySqlConnectionType/) that can connect to the database represented by this [`MySqlDataSource`](../../MySqlDataSourceType/).

```csharp
public MySqlConnection CreateConnection()
```

## Remarks

The connection must be opened before it can be used.

It is the responsibility of the caller to properly dispose the connection returned by this method. Failure to do so may result in a connection leak.

## See Also

* class [MySqlConnection](../../MySqlConnectionType/)
* class [MySqlDataSource](../../MySqlDataSourceType/)
* namespace [MySqlConnector](../../MySqlDataSourceType/)
* assembly [MySqlConnector](../../../MySqlConnectorAssembly/)

<!-- DO NOT EDIT: generated by xmldocmd for MySqlConnector.dll -->

repository: mysql-net/MySqlConnector

gha_language: C#

repo_name: mysql-net/MySqlConnector


text:
# BurnIn

BurnIn is a web-based music player that introduces you to an all-new experience! A playlist matching your current mood is automatically generated to suit your melodic needs. All you have to do is:
1. Choose one or more images from a gallery of randomly generated pictures.
2. Thanks to Shuttershock AI, the app infers your mood from the selected pics and generates a playlist.
3. Sit back and enjoy the songs!

The basic functionality is there but still a work-in-progress.

repository: konoufo/BurnIn

repo_name: konoufo/BurnIn


text:
# Run An Experiment:
In the terminal, go to this folder. Then type ```python main.py <INITIALS>```, replacing `INITIALS` with your own initials.

# Gaze Density Experiment

There are 13 images. Please take your time to inspect each one of them thoroughly. To advance to the next image and to start the experiment, press space.


text:
# Virtuozzo Volume Provisioner for Kubernetes 1.5+

Using Virtuozzo Storage and Ploop devices

# Test instruction

* Build the ploop-flexvol driver and copy binary file to virtuozzo-storage provisioner directory

https://github.com/avagin/ploop-flexvol

* Build virtuozzo-provisioner and container image

```bash
make
docker build -t virtuozzo-storage .
```

* Start Kubernetes local cluster

* Start Virtuozzo provisioner

Assume kubeconfig is at `/root/.kube` and vstorage mounted on all cluster nodes in /mnt/vstorage:

```bash
docker run -tid -v /mnt/vstorage/kube/:/mnt/vstorage/kube/ -v /root/.kube:/kube --privileged --net=host virtuozzo-storage
```

* Create a Virtuozzo Storage Class

```bash
kubectl create -f class.yaml
```

* Create a claim

```bash
kubectl create -f claim.yaml
```

* Create a Pod using the claim

```bash
kubectl create -f test-pod.yaml
```

# Ploop options

A storage class parameters pass as ploop options to the ploop-flexvol driver.

Another way to pass ploop options is to use labels in claims. In this case all special symbols (e.g. +,/, etc) have to be replaced by dots.

Labels in claims can be used to pass ploop options, but all special symbols has to be replaced by dots.
 kind: PersistentVolumeClaim
 apiVersion: v1
 metadata:
   name: vz-test-claim
   annotations:
     volume.beta.kubernetes.io/storage-class: "virtuozzo-storage"
 spec:
   accessModes:
     - ReadWriteOnce
     - ReadOnlyMany
   resources:
     requests:
       storage: 1Gi
   selector:
     matchLabels:
       vzsTier: "0"
       vzsReplicas: "2.1.3"

# Known limitations
Vstorage must be mounted manually on all cluster nodes

repository: kneumoin/external-storage

repo_name: kneumoin/external-storage


text:
---
title:  POSTPONED - DIME-SHS Closing Conference (December 12, 2019)
date:   2019-10-12T00:00:00
---

** Because of the social protest movements and the transport situation, the organising team for the DIME-SHS closing conference has decided to postpone the event to a later date. See you in 2020 to talk about DIME-SHS! **

Implemented as a result of the development plan for the excellence infrastructures, at this year-end 2019, DIME-SHS* turns the page on 10 years of funding for the Equipex programme. A crucial stage in the life-cycle of an infrastructure, the end of funding is not only an opportunity to look back on what has been achieved and to consider the prospects ahead, but also to develop a joint perspective on the role and function of this type of infrastructure in the national and European research landscape. This conference represents that twofold ambition: to tell the story and consider the future of a social science research infrastructure, but also to debate the purpose and funding of this type of experiment.

{{< sidebar class="last" >}}
[Formulaire d'inscription au colloque](https://framaforms.org/colloque-de-cloture-dime-shs-1570795200)
[Programme de l'atelier "Metadata Management"](https://docs.google.com/document/d/1BwEAuM_jepXth44wPqNn4Tl21kFFGsVAi8U00s6NOz4/edit?ts=5da9e470)
[Programme de l'atelier "Ressources pour l'enseignement des méthodes"](https://docs.google.com/document/d/1Rx7UQWbR_fejWW0WmZeoCoXm77SYu0KMVY2z8Fwp1zM/edit?usp=sharing)

En savoir plus:
[Site de l'instrument Elipss](http://quanti.dime-shs.sciences-po.fr/fr/)
[Site de l'instrument beQuali](http://bequali.fr/fr/)
[Site de l'instrument Dime Web](http://dimeweb.dime-shs.sciences-po.fr/)
{{< /sidebar >}}

# December 12th

## 9h-9h30 : accueil café

## 9h30 - 10h30 : ouverture institutionnelle
- Frédéric Mion (Sciences Po)

- Nicolas Sauger (Sciences Po CDSP, CNRS),

- Magda Tomasini (Ined).

## 10.45 - 12.15pm : Panel on “the funding of research infrastructures”
The question of finance is often central to the day-to-day preoccupations of research infrastructures. Support for investment, self-funding, institutional partnerships, are all possible and potentially complementary solutions. This round table will look both at the different methods of funding infrastructures, and at their consequences for the activities that those methods are employed to develop. The experience of the DIME-SHS programme and of the quest to maintain it in the future can be a touchstone for these discussions.

**Panel of speakers**

- Marie d’Arcimoles (Sciences Po CDSP),

- Fabrice Boudjaaba (CNRS INSHS),

- Alain Chenu (Sciences Po OSC),

- Christine Musselin (Sciences Po CSO),

- Carthage Smith (OCDE).

## 2 - 3.30pm : Round table on “Producing with 4 hands: skills in a research infrastructure”
Infrastructures are a primary meeting point for different skills and roles. The aim of this round table is to explore these encounters, notably in a dialogue between service providers, platform engineers and users. From understanding the project to managing constraints and timetables, the example of DIME-SHS is once again a prism through which to view both the fruitfulness and the difficulties of these encounters and work collaborations.

**Panel of speakers**

- Damien Cartron (CNRS CMH),

- Guillaume Garcia (Sciences Po CDSP, CNRS),

- Anne Gotman (CNRS Cerlis),

- Agathe Grandval (RNM-GP),

- Emeline Juillard (Sciences Po CDSP, CNRS),

- Mathieu Olivier (Sciences Po CDSP, CNRS),

- Benjamin Ooghe-Tabanou (Sciences Po médialab),

- Donato Ricci (Sciences Po médialab).

## 4 - 5.30pm : “DIME-SHS Panel: an infrastructure in development”
This panel concludes the day with a more direct discussion of the achievements and prospects of DIME-SHS. How to understand the changes in a project that has been developing for 10 years? What lessons can be learned to build the future of this research infrastructure? It is also an opportunity to think about future needs in terms of social science infrastructure for the coming decade.

**Panel of speakers**

- Dominique Joye (Université de Lausanne FORS),

- Nicolas Sauger (Sciences Po CDSP),

- Roxane Silberman (CNRS CMH),

- Vincent Tiberj (Sciences Po Bordeaux).

# December 13th
On the sidelines of the symposium, two method workshops focusing on the contextualisation, dissemination and reuse of qualitative and quantitative data were also schedule:

[“Metadata Management” workshop Programme](https://docs.google.com/document/d/1BwEAuM_jepXth44wPqNn4Tl21kFFGsVAi8U00s6NOz4/edit?ts=5da9e470)

[“Resources for the Teaching of Methods” workshop Programme](https://docs.google.com/document/d/1Rx7UQWbR_fejWW0WmZeoCoXm77SYu0KMVY2z8Fwp1zM/edit?usp=sharing)

[^1]: The DIME-SHS scientific project was recognised by the National Research Agency (ANR-10-EQPX-19-01).

repository: CDSP-SCPO/site-DIME-SHS

repo_name: CDSP-SCPO/site-DIME-SHS


text:
# tastyworks-cli

An easy-to-use command line interface for Tastyworks!

## Installation

```
$ pip install tastyworks-cli
```

## Usage

Obtaining a CSV file: On the Tastyworks desktop app, go to the History tab. Under transactions (**not** YTD), pick a custom start date *before the creation of your account*. Scroll down until all of your transactions have loaded, then click "CSV" in the top right to export all the transactions. *You must export your entire transaction history, even if you only want to plot a more recent time period.*

Available commands:
```
tw plot                chart your portfolio's net liquidity or profit/loss over time
tw quant               mathematical and statistical analysis
```
Unavailable commands pending development:
```
tw order               view, replace, and cancel orders
tw watchlist           view current prices and other data for symbols in your watchlists
tw portfolio           view statistics and risk metrics for your portfolio
tw crypto              buy, sell, and analyze cryptocurrencies
tw future              buy, sell, and analyze futures
tw stock               buy, sell, and analyze stock
tw option              buy, sell, and analyze options
```
For more options, run `tw --help`.

## Development/Contributing

This project includes a number of helpers in the `Makefile` to streamline common development tasks.

Creating a virtualenv for development:
```
$ make venv
$ source env/bin/activate
```

It's usually a good idea to make sure you're passing tests locally before submitting a PR:
```
$ make test
```

If you have a feature suggestion, find a bug, or would like to contribute, feel free to open an issue or create a pull request.

## Disclaimer

tastyworks and tastytrade are not affiliated with the makers of this program and do not endorse this product. This program does not provide investment, tax, or legal advice. Stock trading involves risk and is not suitable for all investors. Options involve risk and are not suitable for all investors as the special risks inherent to options trading may expose investors to potentially significant losses. Futures and futures options trading is speculative and is not suitable for all investors. Cryptocurrency trading is speculative and is not suitable for all investors.

repository: def-mycroft/tastyworks-cli

repo_name: def-mycroft/tastyworks-cli