text:
# RFC 011: Remove Gas From Tendermint

## Changelog

- 03-Feb-2022: Initial draft (@williambanfield).
- 10-Feb-2022: Update in response to feedback (@williambanfield).
- 11-Feb-2022: Add reflection on MaxGas during consensus (@williambanfield).

## Abstract

In the v0.25.0 release, Tendermint added a mechanism for tracking 'Gas' in the mempool.
At a high level, Gas allows applications to specify how much it will cost the network,
often in compute resources, to execute a given transaction. While such a mechanism is common
in blockchain applications, it is not generalizable enough to be a maintained as a part
of Tendermint. This RFC explores the possibility of removing the concept of Gas from
Tendermint while still allowing applications the power to control the contents of
blocks to achieve similar goals.

## Background

The notion of Gas was included in the original Ethereum whitepaper and exists as
an important feature of the Ethereum blockchain.

The [whitepaper describes Gas][eth-whitepaper-messages] as an Anti-DoS mechanism. The Ethereum Virtual Machine
provides a Turing complete execution platform. Without any limitations, malicious
actors could waste computation resources by directing the EVM to perform large
or even infinite computations. Gas serves as a metering mechanism to prevent this.

Gas appears to have been added to Tendermint multiple times, initially as part of
a now defunct `/vm` package, and in its most recent iteration [as part of v0.25.0][gas-add-pr]
as a mechanism to limit the transactions that will be included in the block by an additional
parameter.

Gas has gained adoption within the Cosmos ecosystem [as part of the Cosmos SDK][cosmos-sdk-gas].
The SDK provides facilities for tracking how much 'Gas' a transaction is expected to take
and a mechanism for tracking how much gas a transaction has already taken.

Non-SDK applications also make use of the concept of Gas. Anoma appears to implement
[a gas system][anoma-gas] to meter the transactions it executes.

While the notion of gas is present in projects that make use of Tendermint, it is
not a concern of Tendermint's. Tendermint's value and goal is producing blocks
via a distributed consensus algorithm. Tendermint relies on the application specific
code to decide how to handle the transactions Tendermint has produced (or if the
application wants to consider them at all). Gas is an application concern.

Our implementation of Gas is not currently enforced by consensus. Our current validation check that
occurs during block propagation does not verify that the block is under the configured `MaxGas`.
Ensuring that the transactions in a proposed block do not exceed `MaxGas` would require
input from the application during propagation. The `ProcessProposal` method introduced
as part of ABCI++ would enable such input but would further entwine Tendermint and
the application. The issue of checking `MaxGas` during block propagation is important
because it demonstrates that the feature as it currently exists is not implemented
as fully as it perhaps should be.

Our implementation of Gas is causing issues for node operators and relayers. At
the moment, transactions that overflow the configured 'MaxGas' can be silently rejected
from the mempool. Overflowing MaxGas is the _only_ way that a transaction can be considered
invalid that is not directly a result of failing the `CheckTx`. Operators, and the application,
do not know that a transaction was removed from the mempool for this reason. A stateless check
of this nature is exactly what `CheckTx` exists for and there is no reason for the mempool
to keep track of this data separately. A special [MempoolError][add-mempool-error] field
was added in v0.35 to communicate to clients that a transaction failed after `CheckTx`.
While this should alleviate the pain for operators wishing to understand if their
transaction was included in the mempool, it highlights that the abstraction of
what is included in the mempool is not currently well defined.

Removing Gas from Tendermint and the mempool would allow for the mempool to be a better
abstraction: any transaction that arrived at `CheckTx` and passed the check will either be
a candidate for a later block or evicted after a TTL is reached or to make room for
other, higher priority transactions. All other transactions are completely invalid and can be discarded forever.

Removing gas will not be completely straightforward. It will mean ensuring that
equivalent functionality can be implemented outside of the mempool using the mempool's API.

## Discussion

This section catalogs the functionality that will need to exist within the Tendermint
mempool to allow Gas to be removed and replaced by application-side bookkeeping.

### Requirement: Provide Mempool Tx Sorting Mechanism

Gas produces a market for inclusion in a block. On many networks, a [gas fee][cosmos-sdk-fees] is
included in pending transactions. This fee indicates how much a user is willing to
pay per unit of execution and the fees are distributed to validators.

Validators wishing to extract higher gas fees are incentivized to include transactions
with the highest listed gas fees into each block. This produces a natural ordering
of the pending transactions. Applications wishing to implement a gas mechanism need
to be able to order the transactions in the mempool. This can trivially be accomplished
by sorting transactions using the `priority` field available to applications as part of
v0.35's `ResponseCheckTx` message.

### Requirement: Allow Application-Defined Block Resizing

When creating a block proposal, Tendermint pulls a set of possible transactions out of
the mempool to include in the next block. Tendermint uses MaxGas to limit the set of transactions
it pulls out of the mempool fetching a set of transactions whose sum is less than MaxGas.

By removing gas tracking from Tendermint's mempool, Tendermint will need to provide a way for
applications to determine an acceptable set of transactions to include in the block.

This is what the new ABCI++ `PrepareProposal` method is useful for. Applications
that wish to limit the contents of a block by an application-defined limit may
do so by removing transactions from the proposal it is passed during `PrepareProposal`.
Applications wishing to reach parity with the current Gas implementation may do
so by creating an application-side limit: filtering out transactions from
`PrepareProposal` the cause the proposal the exceed the maximum gas. Additionally,
applications can currently opt to have all transactions in the mempool delivered
during `PrepareProposal` by passing `-1` for `MaxGas` and `MaxBytes` into
[ReapMaxBytesMaxGas][reap-max-bytes-max-gas].

### Requirement: Handle Transaction Metadata

Moving the gas mechanism into applications adds an additional piece of complexity
to applications. The application must now track how much gas it expects a transaction
to consume. The mempool currently handles this bookkeeping responsibility and uses the estimated
gas to determine the set of transactions to include in the block. In order to task
the application with keeping track of this metadata, we should make it easier for the
application to do so. In general, we'll want to keep only one copy of this type
of metadata in the program at a time, either in the application or in Tendermint.

The following sections are possible solutions to the problem of storing transaction
metadata without duplication.

#### Metadata Handling: EvictTx Callback

A possible approach to handling transaction metadata is by adding a new `EvictTx`
ABCI method. Whenever the mempool is removing a transaction, either because it has
reached its TTL or because it failed `RecheckTx`, `EvictTx` would be called with
the transaction hash. This would indicate to the application that it could free any
metadata it was storing about the transaction such as the computed gas fee.

Eviction callbacks are pretty common in caching systems, so this would be very
well-worn territory.

#### Metadata Handling: Application-Specific Metadata Field(s)

An alternative approach to handling transaction metadata would be would be the
addition of a new application-metadata field in the `ResponseCheckTx`. This field
would be a protocol buffer message whose contents were entirely opaque to Tendermint.
The application would be responsible for marshalling and unmarshalling whatever data
it stored in this field. During `PrepareProposal`, the application would be passed
this metadata along with the transaction, allowing the application to use it to perform
any necessary filtering.

If either of these proposed metadata handling techniques are selected, it's likely
useful to enable applications to gossip metadata along with the transaction it is
gossiping. This could easily take the form of an opaque proto message that is
gossiped along with the transaction.

## References

[eth-whitepaper-messages]: https://ethereum.org/en/whitepaper/#messages-and-transactions
[gas-add-pr]: https://github.com/tendermint/tendermint/pull/2360
[cosmos-sdk-gas]: https://github.com/cosmos/cosmos-sdk/blob/c00cedb1427240a730d6eb2be6f7cb01f43869d3/docs/basics/gas-fees.md
[cosmos-sdk-fees]: https://github.com/cosmos/cosmos-sdk/blob/c00cedb1427240a730d6eb2be6f7cb01f43869d3/docs/basics/tx-lifecycle.md#gas-and-fees
[anoma-gas]: https://github.com/anoma/anoma/blob/6974fe1532a59db3574fc02e7f7e65d1216c1eb2/docs/src/specs/ledger.md#transaction-execution
[reap-max-bytes-max-gas]: https://github.com/tendermint/tendermint/blob/1ac58469f32a98f1c0e2905ca1773d9eac7b7103/internal/mempool/types.go#L45
[add-mempool-error]: https://github.com/tendermint/tendermint/blob/205bfca66f6da1b2dded381efb9ad3792f9404cf/rpc/coretypes/responses.go#L239

repository: informalsystems/tendermint

repo_name: informalsystems/tendermint


text:
# Space Age Calculator

#### By **Ian Cook Westgate**

## Description

This Space Age Calculator is an exercise assigned by Epicodus to translate a user's age into Mercury, Venus, Mars, and Jupiter years. It will also determine how many years a user may have left to live or, alternatively, how many years they would have lived past life expectancy if they had been born on the planet of their choice of the options above.

## Specs
  * Spec 1: | Return the user's age in Mercury years | Input: "25" | Output: "6" |
  * Spec 2: | Return the user's age in Venus years | Input: "25" | Output: "15.5" |
  * Spec 3: | Return the user's age in Mars years | Input: "25" | Output: "47" |
  * Spec 4: | Return their age in Jupiter years | Input: "25" | Output: "296.5" |
  * Spec 5: | Determine how many years a user has left to live on each planet. | Input: "Age: 25, Life Expectancy: 70, Planet Selection: Mars" | Output: "You have 23 years left to live on Mars." |
  * Spec 6: | If user already exceeds life expectancy for the planet, return how long they have lived past it. | Input: "Age: 40, Life Expectancy: 70, Planet Selection: Mars" | Output: "You have lived 5.2 years past your life expectancy on Mars." |

## Setup

* Clone this repository @ https://github.com/iwestgate931/fivethirtyeight-clone.git
* Use a terminal of your choice (I use Git Bash) to access the webpage and its files by inputting: "git clone {the above clone link}"
* Open the folder you receive and open the index.html link in the web browser of your choice (I use Google Chrome).
* Install Node.js
* Install karma-cli globally: `npm install -g karma-cli`
* Clone the repo
* `npm install` to install dependencies
* `npm run start` to build and start the dev server
* `npm run lint` to explicitly run ESLint
* `npm run test` to run the unit tests with Karma and Jasmine.

## Technologies Used

* HTML
* CSS
  * SASS
* JavaScript
* Node.js
* jQuery 3.3.1
* Bootstrap 4.1.3
* Babel
* Webpack
* ESLint
* Jasmine
* Karma

## Known Bugs
* There are no known bugs at this time.

## Support and contact details

_Email<EMAIL_ADDRESS>with any questions, comments, or concerns._

## License

*{This software is licensed under the MIT license}*
Copyright (c) 2019 **_{Ian Cook Westgate}_**

license: MIT

repository: iancookwestgate/space-age-calculator

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: iancookwestgate/space-age-calculator


text:
[//]: # (Image References)

[ImageNet1]: ./git_images/ImageNet1.jpg "ImageNet part 1"
[ImageNet2]: ./git_images/ImageNet2.jpg "ImageNet part 2"
[jackfruit]: ./git_images/jackfruit.jpg "Jackfruit"

[ToRemove1]: ./invalid/4.jpg "Inavlid Image"
[ToRemove2]: ./invalid/5.jpg "Inavlid Image"
[ToRemove3]: ./invalid/6.jpg "Inavlid Image"

# NotJackFruit-Classifier
Do you watch HBO's Silicon Valley? Because I do and I was inspired by Mr. Jian-Yang to make my own not hotdog classifier. But this is different, its the Indian version, not jackfruit?

"What would you say if I told you there is a app on the market that tell you if you have a jackfruit or not a jackfruit." - Sasi

# Step 1: Setting up

## Usage

#### Step #1 : Install virtualenv

`pip install virtualenv`

#### Step #2 : Create a virtualenv

`virtualenv -p python3 vir`

#### Step #3: Activate Virtualenv

`source ./vir/bin/activate`

#### Step #4 : Clone Repo

* Clone the Repo. *(`cd` into the `dir` after extracing the `.zip`)*

#### Step #5 : Install requirements

* Install the Requirements.

`pip install -r requirements.txt`

### If you just need to use the model without training, I have added a pretrained model. Go to step 7.

# Step 2: Collecting data
The very first step in making a classifier is to collect data. Thus we need to find images of jackfruit and not-jackfruit.

To do this I just used [ImageNet](http://www.image-net.org/) to search for my images, since ImageNet is like a database of images. To find the hotdog images I just searched for “jackfruit”, after downloading all of the images it would me about around 1000 jackfruit images.  For the not-jackfruit images I searched for “food”, “furniture”, “people” and “pets” this give me about 4024 not-jackfruit images.

Now to actually download these images I need to get the URLs, to do that I just need to click on the tab download tab click on link called URLs
![ImageNet1]

then copy the URL of the page your on which will use in a script that we'll write to download all of these images.
![ImageNet2]

Next we need to write our scripts to download and save all of these images, here is my [python code](https://github.com/adamshamsudeen/not-jackfruit/blob/master/images/get_images.py) for saving the images.
The function store_raw_images takes in a list of folders names where you want to save the images to from each of the links.
```
def store_raw_images(folders, links):
    pic_num = 1
    for link, folder in zip(links, folders):
        if not os.path.exists(folder):
            os.makedirs(folder)
        image_urls = str(urllib.request.urlopen(link).read())

        for i in image_urls.split('\\n'):
            try:
                urllib.request.urlretrieve(i, folder+"/"+str(pic_num)+".jpg")
                img = cv2.imread(folder+"/"+str(pic_num)+".jpg")

                # Do preprocessing if you want
                if img is not None:
                    // do more stuff here if you want
                    cv2.imwrite(folder+"/"+str(pic_num)+".jpg",img)
                    pic_num += 1

            except Exception as e:
                    print(str(e))

```

Next I have my main method to drive the code

```
def main():

    links = [

        'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n01318894', \
        'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n03405725', \
        'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n07942152', \
        'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n00021265', \
        'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n07697537', \
        'http://image-net.org/api/text/imagenet.synset.geturls?wnid=n12400720'
       ]

       paths = ['pets', 'furniture', 'people', 'food',  'hotdog','jackfruit']

    store_raw_images(paths, links)
```

## You can also use shell script:

Save all the liks to jack.txt and the script to download it

```
awk '{print "" $0;}' jack.txt | xargs -l1 wget
```

Delete all smaller files, unavailable images and junk files
```
find . -name "*.jpg" -size -10k -delete
```

Now just wait for it to download all of those jackfruits!!!

# Step 3: Cleaning the data
At this point we have collected our data now we just need to clean it up a bit. If you take a look at the data you will probably notice that there are some garbage images that we need to remove, images that look like one of the following

![ToRemove1]
![ToRemove2]
![ToRemove3]

To do this let write some more scripts to do this work for us, first we just need to get a copy of the images that we want to remove and place them in a folder called ‘invalid’.

```
def removeInvalid(dirPaths):
    for dirPath in dirPaths:
        for img in os.listdir(dirPath):
            for invalid in os.listdir('invalid'):
                try:
                    current_image_path = str(dirPath)+'/'+str(img)
                    invalid = cv2.imread('invalid/'+str(invalid))
                    question = cv2.imread(current_image_path)
                    if invalid.shape == question.shape and not(np.bitwise_xor(invalid,question).any()):
                        os.remove(current_image_path)
                        break

                except Exception as e:
                    print(str(e))
```
 Next I made two folders called "jackfruit" and "not-jackfruit" and placed the 'food', 'furniture', 'pets', 'people' folders in the "not-jackfruit" foldder.

# Step 4: Choosing the model.
The retrain script can retrain either Inception V3 model or a MobileNet. In this exercise, we will use a MobileNet. The principal difference is that Inception V3 is optimized for accuracy, while the MobileNets are optimized to be small and efficient, at the cost of some accuracy.

Inception V3 has a first-choice accuracy of 78% on ImageNet, but is the model is 85MB, and requires many times more processing than even the largest MobileNet configuration, which achieves 70.5% accuracy, with just a 19MB download.

Pick the following configuration options:

Input image resolution: 128,160,192, or 224px. Unsurprisingly, feeding in a higher resolution image takes more processing time, but results in better classification accuracy. We recommend 224 as an initial setting.
The relative size of the model as a fraction of the largest MobileNet: 1.0, 0.75, 0.50, or 0.25. We recommend 0.5 as an initial setting. The smaller models run significantly faster, at a cost of accuracy.
With the recommended settings, it typically takes only a couple of minutes to retrain on a laptop. You will pass the settings inside Linux shell variables. Set those shell variables as follows:
```
IMAGE_SIZE=224
ARCHITECTURE="mobilenet_0.50_${IMAGE_SIZE}"
 ```

Other models: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md

To start Tensorboard

```
tensorboard --logdir tf_files/training_summaries &
```

# Step 5: Train The Neural Net
The model we choose is a mobileNet
```
python -m scripts.retrain \
  --bottleneck_dir=tf_files/bottlenecks \
  --how_many_training_steps=500 \
  --model_dir=tf_files/models/ \
  --summaries_dir=tf_files/training_summaries/"${ARCHITECTURE}" \
  --output_graph=tf_files/retrained_graph.pb \
  --output_labels=tf_files/retrained_labels.txt \
  --architecture="${ARCHITECTURE}" \
  --image_dir=images/
```

The first retraining command iterates only 500 times. You can very likely get improved results (i.e. higher accuracy) by training for longer. To get this improvement, remove the parameter --how_many_training_steps to use the default 4,000 iterations.

# Step 6: Using the retrained model

The retraining script writes data to the following two files:

tf_files/retrained_graph.pb, which contains a version of the selected network with a final layer retrained on your categories.
tf_files/retrained_labels.txt, which is a text file containing labels

To train the network we split our data into a tranining set and a test set

# Step 7: The Results
I have added a pretrined model, just use the below code without training. Dont forget to set the architecture from step 4.

```
python -m scripts.label_image \
    --graph=tf_files/retrained_graph.pb  \
    --image=images/test.jpg

```

We are getting good accuracy, All the best with JackFruit Hunting.

# License:
MIT

# To-Do

- [ ] Create a Flask app to read the image and print result.

repository: adamshamsudeen/not-jackfruit

repo_name: adamshamsudeen/not-jackfruit


text:
---
# Documentation: https://sourcethemes.com/academic/docs/managing-content/

title: "Inhalable Insulin Carrier V1"
subtitle: "See a need, fill a need."
summary: "A 3D print to solve the pain that is carrying inhalable insulin around."
authors: []
tags: ["3D Printing"]
categories: ["3D Printing"]
date: 2021-07-16T17:39:24-07:00
lastmod: 2021-07-16T17:39:24-07:00
featured: false
draft: false

# Featured image
# To use, add an image named `featured.jpg/png` to your page's folder.
# Focal points: Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight.
image:
  caption: ""
  focal_point: ""
  preview_only: false

# Projects (optional).
#   Associate this post with one or more of your projects.
#   Simply enter your project's folder or file name without extension.
#   E.g. `projects = ["internal-project"]` references `content/project/deep-learning/index.md`.
#   Otherwise, set `projects = []`.
projects: []
---

# Background
OK, you know the deal! 😎 I have Type 1 Diabetes, which means I need insulin to survive.
This is usually administered via a syringe, or via an insulin pump.
I have been trying a new medication though, in conjunction with my insulin pump, and it is Inhalable Insulin.
The inhaler looks like this:

![Inhaler](inhaler.jpg)

And the insulin powder which you inhale is stored in these plastic cartridges:

![Cartridges](cart.jpg)

They come in sets of 3, and each 1 gets loaded in the inhaler for use.

# Problem
Here is the problem though, carrying this stuff in your pants pocket is ridiculously annoying.
Especially the catriges, which for some reason are insanely sharp and pokey on the edges.

# How can we make this better?
3D Printing! 🏄

Like all good nifty problems in life, it can be solved with 3D printing (I hope).
Quick disclaimer before we proceed as well, I've only ever 3D printed one thing in my life, and it was a simple box...

# Onto the design phase

One idea I want to call out here, is to use the existing cap as a way to press fit the inhaler into the carrier.
Why reinvent the wheel, I can just superglue that cap to what I design.

![Page1](Page1.jpg)

# Ok now lets make a prototype

![Page2](Page2.jpg)

# Now lets do some measurements

![Page3](Page3.jpg)

# Ok now lets do some modeling

I don't have much expierence with 3d modeling, but from what I read online, Tinkercad seemed the most approachable.
I used that to implement my design.
BTW helpful hint, learn to use the Tinkercad ruler as early as possible,
although as you will find out below, I still have some room to improve in that area.

![Page3](tinkercad.png)

Next I sent it off to a 3D printing service, and was left with the hardest part, waiting for the printed part to arrive.
Wow this was brutal and made me strongly suggest just getting a 3d printer!

# Let's See The Print! 🕺

![Page3](me.jpg)

# That's awesome! Can I download the STL File?

You sure can, I have uploaded the stl file to my github.
You can check it out here.

[https://github.com/dddiaz/models/blob/main/afreeza-holder-v2.stl](https://github.com/dddiaz/models/blob/main/afreeza-holder-v2.stl)

# What's Next?

Ok this was a great first pass! It looks like I didn't nail the width on the cartridges though,
so I actually had to trim them with scissors to get them to fit.

So first order of business would be getting that spacing right. I also wish the walls werent as tall,
so I might work on that for the next version too.

Also rounded corners would be nice. And if I was feeling super fancy, maybe print in metal?

Anyways, thanks for reading, see you next time!

gha_language: JavaScript

gha_license_id: MIT


text:
---
layout: page
categories: articles
title: "Cyclic voltammetry simulation tutorials"
description: Tutorials on cyclic voltammetry simulations
---

Last updated: May 10, 2018

These tutorials will explain the simulation that powers my simple
cyclic voltammetry apps.
I built these apps to better understand the fundamentals of
electrochemistry, and I hope they help you too!

I originally wrote this simulation in MATLAB and later ported it to JavaScript.
The JavaScript version lives [here](/cyclic_voltammetry_simulation/cvwebapp.html).
You can download the MATLAB version on the
[MATLAB File Exchange](https://www.mathworks.com/matlabcentral/fileexchange/64011-cyclic-voltammetry-simulator)
and on [GitHub](https://github.com/petermattia/Cyclic-Voltammetry-Simulator).

My primary source for these simulations is [Bard and Faulkner, *Electrochemical Methods: Fundamentals and Applications*, 2nd edition](https://www.amazon.com/Electrochemical-Methods-Fundamentals-Allen-Bard/dp/0471043729),
Appendix B.
I also validated my simulation with the
[Excel simulation](http://pubs.acs.org/doi/suppl/10.1021/acs.jchemed.5b00225/suppl_file/ed5b00225_si_001.xls) published [in this journal article](https://dx.doi.org/10.1021/acs.jchemed.5b00225).
You can also find an excellent (qualitative) cyclic voltammetry tutorial
[here](http://sop4cv.com/index.html).

I also created similar apps and tutorials for
[galvanostatic simulations](/galvanostatic_simulation/index.html).

Enjoy!

### [Online simulation](/cyclic_voltammetry_simulation/cvwebapp.html)

### [Fundamental electrochemistry](/cyclic_voltammetry_simulation/fundamentals.html)

### [Simulation walkthrough](/cyclic_voltammetry_simulation/simulation.html)

### [Chemical and electrochemical reversibility](/cyclic_voltammetry_simulation/reversibility.html)

### [MATLAB script](/cyclic_voltammetry_simulation/code.html)

repository: petermattia/petermattia

branch_name: refs/heads/main

gha_language: HTML

repo_name: petermattia/petermattia


text:
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.2.7] - 2023-08-19

### Added
- add privacy manifest PrivacyInfo.xcprivacy.

## [1.2.6] - 2022-11-27

### Fixed
- load remote image in background thread.

## [1.2.5] - 2020-01-13

### Fixed
- add `cameraFlashMode`.

## [1.2.4] - 2019-10-22

### Fixed
- present fullScreen on iOS 13.
- make all public methods available form Objective-C.

## [1.2.3] - 2019-08-22

### Added
- support Swift Package Manager.

## [1.2.2] - 2019-07-13

### Changed
- MiniLayout moved to SweeterSwift.

## [1.2.1] - 2019-06-21

### Changed
- Swift 5, CocoaPods 1.7.

## [1.2.0] - 2018-09-06

### Changed
- Swift 4.2

## [1.1.0] - 2018-07-08

### Changed
- use `typealias UIImagePickerController = MockImagePicker`

## [1.0.1] - 2018-07-01

### Fixed
- ensure black background.

repository: yonat/MockImagePicker

repo_name: yonat/MockImagePicker


text:
# Osmose Eloquent Filter

[![Build Status](https://travis-ci.org/franciskisiara/osmose.svg?branch=master)](https://travis-ci.org/franciskisiara/osmose)
[![Latest Stable Version](https://poser.pugx.org/agog/osmose/v/stable)](https://packagist.org/packages/agog/osmose)
[![Total Downloads](https://poser.pugx.org/agog/osmose/downloads)](https://packagist.org/packages/agog/osmose)
[![License](https://poser.pugx.org/agog/osmose/license)](https://packagist.org/packages/agog/osmose)

An elegant way to filter your eloquent collections

## Getting Started
To pull osmose in your project, use the command

```
composer require agog/osmose
```

## Defining Osmose Filters
Osmose provides an artisan command `make-filter` that accepts the name of the filter to be generated, which quickly scaffolds a filter class

```
php artisan osmose:make-filter CharacterFilter
```
A CharacterFilter.php file will be created in the `App\Http\Filters` namespace.

***NB: The Filters folder will be automatically created if it does not exist.***

A filter class extends the `Agog\Osmose\Library\OsmoseFilter` template and implements the `Agog\Osmose\Library\Services\Contracts\OsmoseFilterInterface` interface.

It must define a residue method that returns an array defining the filtration rules

```php
<?php

namespace App\Http\Filters;

use Agog\Osmose\Library\OsmoseFilter;
use Agog\Osmose\Library\Services\Contracts\OsmoseFilterInterface;

class CharacterFilter extends OsmoseFilter implements OsmoseFilterInterface
{
    /**
     * defines the form elements that are to be sieved
     * @return array
     */
    public function residue()
    {
        return [

        ];
    }
}
```

## Usage
In order to use the osmose filter, you define rules as an array within the residue method's

Rules are defined as key => value pairs with the key representing the parameter passed as the request and the value represents the rule construct.

Rules are defined based on the type of filter driver intended. Osmose presents three internal filter drivers

    1. Agog\Osmose\Library\Drivers\DirectFilter
    2. Agog\Osmose\Library\Drivers\CallbackFilter
    3. Agog\Osmose\Library\Drivers\RelationshipFilter

In our business logic, we call Osmose's sieve method on the filter object and pass the eloquent class that we intend to filter
The sieve method will return Eloquent's builder.

`CharacterController.php`

```php
public function index (CharacterFilter $filter)
{
    $characters = $filter->sieve(Character::class)->get();
}
```

----------

Consider the following tables and their related eloquent models

`Character.php`

| id   | name        | gender  |
|------|-------------|---------|
| 1    | Baraka      | male    |
| 2    | Cassie Cage | female  |
| 3    | D'Vorah     | female  |
| 4    | Geras       | male    |
| 5    | Cetrion     | female  |

----------

`Role.php`

| id   | name        |
|------|-------------|
| 1    | hero        |
| 2    | villain     |
| 3    | god         |

----------

`CharacterRole.php`

| id   | character_id   | role_id |
|------|----------------|---------|
| 1    | 1              | 2       |
| 2    | 2              | 1       |
| 3    | 3              | 2       |
| 4    | 4              | 2       |
| 5    | 4              | 3       |
| 6    | 5              | 3       |

----------

### DirectFilter

To use the DirectFilter driver, we define the rule, prefixed with the word 'column'

```php
public function residue ()
{
    return [
        'character_id' => 'column:id'
    ]
}
```

Osmose will then look for the key 'character_id' within the request object and only return the result whose id matches the value passed

/characters?character_id=1
Will return the character record with an id of '1'

### RelationshipFilter

To use the RelationshipFilter driver, we define the rule, prefixed with the word 'relationship', giving the name of the relationship and the column that should be checked in the related table

```php
public function residue ()
{
    return [
        'role' => 'relationship:roles,name'
    ]
}
```
***NB: It is assumed a roles (belongsToMany) relationship exists in the Character model.***

Osmose will then look for the key 'role' within the request object and only return the result based on the rule definition

/characters?role=god
Will return all characters with the role of 'god'

### CallbackFilter

To use the CallbackFilter driver, we pass a callback that takes in the query builder and the value of the request as arguments. The callback must return the result of the builder

```php
public function residue ()
{
    return [
        'gender' => function ($query, $value) {

            return $query->where('gender', $value);

        }
    ]
}
```

Osmose will then look for the key 'gender' within the request object and only return results based on the callback

/characters?gender=male
Will return all male characters

## Filtering Dates

Starting from version 1.1.0, osmose includes a date filter that quickly lets you fetch records whose *created_at* timestamps fall between a certain date range.

*To use this feature, you must publish osmose's configuration file by running;*

```
php artisan vendor:publish --provider="Agog\Osmose\Providers\OsmoseServiceProvider"
```

This will publish an osmose.php file in your app's config folder.

In this file, you will find a ranges array that defines keys and their carbon ranges - d (day), w (week), m (month), y (year) have already been defined :). You can define more ranges here as you deem fit.

In order to filter using these ranges, osmose expects a range parameter in your url whose value is one of the ranges defined in the configuration file

```
/characters?range=m
```

This will filter characters who were created between the beginning and end of the month.

You can change the parameter name osmose expects you to give by overwriting the $range property in your filter class

```php
<?php

namespace App\Http\Filters;

use Agog\Osmose\Library\OsmoseFilter;
use Agog\Osmose\Library\Services\Contracts\OsmoseFilterInterface;

class CharacterFilter extends OsmoseFilter implements OsmoseFilterInterface
{
    protected $range = "dates";

    ...
}
```

By changing the $range property as shown above, our url will then be

```
/characters?dates=m
```

## The Global Osmose Function

Version 1.2.0 introduces a global function, `osmose()`, that can automatically detect a model class from the filter.

*To use this feature, you must publish osmose's configuration file by running;*

```
php artisan vendor:publish --provider="Agog\Osmose\Providers\OsmoseServiceProvider"
```

To automatically detect models, the convention `${ModelName}Filter` should be followed when creating filters
For example, a filter named **CharacterFilter** will look for and automatically load a model called **Character**.

By default, osmose looks for models within the App namespace but this can be configured by changing the namespace's keyfrom within osmose's configuration file.

The `osmose()` function receives the filter's fully qualified class name and an optional model name.

It returns Eloquent's builder just like the sieve() method.

```php
public function index ()
{
    $characters = osmose(CharacterFilter::class)->get();
}
```

if the model name completely differs from the filter or if there isn't a single namespace under which models reside. e.g in a micro service architecture, then you can pass the model's fully qualified name as a second argument to the osmose function.

```php
public function index ()
{
    $characters = osmose(UserSieve::class, Character::class)->get();
}
```

## Feature Requests

If you have any feature requests, security vulnerabilities or just a good ol' thumbs up, dont hesitate to drop an email at [franciskisiara<EMAIL_ADDRESS>

## Inspiration

This project was inspired by laravel's request validation. The name *osmose* comes from the biological word osmosis and how particles are able to *filter* through semi-permeable membranes. :)

## Osmose Authors
### Kisiara Francis
 - [Github](https://github.com/franciskisiara/)
 - [Medium](https://medium.com/@franciskisiara)
 - [LinkedIn](https://www.linkedin.com/in/francis-kisiara-289360ab/)

repository: fallback/osmose

repo_name: fallback/osmose


text:
# Release Checklist

Make sure you have npm + git credentials set up.

- [ ] Make changes and/or merge PRs.
- [ ] `git checkout master`
- [ ] `git pull`
- [ ] Set up semantic release environment variables:

```bash
export GIT_AUTHOR_NAME=<your-github-login>
export GIT_AUTHOR_EMAIL=<your-github-email>
export GIT_COMMITTER_NAME=<your-github-login>
export GIT_COMMITTER_EMAIL=<your-github-email>
export GITHUB_TOKEN=<github-token-with-public_repo-permissions>
```

- [ ] `npm run release`

repository: xformation/synectiks-website

repo_name: xformation/synectiks-website


text:
# DualRobotBottle

## Introduction

As with my previous adventures with python web frameworks I wanted to give bottle a try. Bottle is very similar to Flask but is also different in its syntax.

repository: sentairanger/DualRobotBottle

repo_name: sentairanger/DualRobotBottle


text:
## Hyfs

Simple Distribute File System

## Overview

Hyfs is a high-performance proxy for file system, Hyfs aims to simplify for storage.

## Feature

 - Basic file/dir operation(Create/Delete/Read/Write/Rename)
 - Auto replication recovery
 - Nameserver Ha
 - Disk load balance
 - Chunkserver auto load balance
 - sdk

## Install

```

```

## Usage

```

```

## Design

repository: kobehaha/Hyfs

gha_language: Java

repo_name: kobehaha/Hyfs


text:
# ADS-B Capability Provider

This capability provider captures real-time messages from a telnet server that exposes AVR messages. These AVR messages are then parsed into a meaningful data structure and delivered via actor binding to a processor actor.

## Pre-Requisites

The following must be in place in order to successfully run this provider in a waSCC host:

* TCP connectivity to the telnet server exposed by the [dump1090](https://github.com/MalcolmRobb/dump1090) application.
* A machine connected to an [RTL-SDR](https://www.rtl-sdr.com/) dongle and antenna combination with the appropriate device drivers. Consult the RTL SDR website for advice on purchasing devices, antennas, physical configuration, and device drivers and software installation for your equipment.

Simply run `dump1090 --net` or `dump1090 --interactive --net` to start the telnet server required by this capability provider.

repository: cambricorp/wasm-air

repo_name: cambricorp/wasm-air


text:
CSJSScopes
==========

Demo appplication that shows how to handle scoped variables via client Javascript and Server Side Javascript and vice versa

![Imgur](http://i.imgur.com/QY3uzBH.png)

License
-------
Apache License 2.0


text:
Daily often used commands under Linux (Ubuntu)
==============================================

This is a list of my daily often used commands under Ubuntu Linux server and
desktop. It's for the people like me who do not have a good memory. I hope it
will save you a lot of time if you have this list near at hand and mostly don't
need to search a command online anymore. The comments before every command are
not trying to explain every option in the command. If you have any question
about the options please see the **--help** or **man** manuals.

There are a lot of other tricks to use the commands or combinations of the commands.
If you want to add your often used commands in the list, please **fork** this
and make **Pull Request**. I'm still trying to update the list if I have some
time.

Enjoy the list!

> Fortunately I have the **root** privileges mostly. So the most of the
following commands don't have a **sudo** prefix.

### User administration

```bash

	# create an user with home-dir
	useradd -m -s /bin/bash/ username

	# create a super user, make him the SAME user as root and have home-dir
	# (BUT BE CAREFUL OF DOING THIS ENLESS YOU KNOW WHAT YOU ARE DOING)
	# to delete this super user: change the uid from 0 to other in the /etc/passwd
	useradd -u 0 -g 0 -o -m -s /bin/bash username

	# change the password of an user
	passwd username

	# disable login for an user; sudo -u -i still works
	passwd -d username

	# delete an user and his home-dir
	userdel -r username

	# add a group (with --system is a system group)
	addgroup groupname

	# add an user to a group
	usermod -a -G groupname username

	# delete an user from a group
	gpasswd -d username groupname

	# create a only-local-login-user;
	# if other user should use this special user account through sudo -u, then edit sudo config
	useradd -m -s /bin/bash username
	usermod -L username

	# login to other user with current env
	su username
	# login to other user with his env
	su -l username
	sudo -u username -i

	# show log of users' login
	last -a
	# show log of users' most recently login
	lastlog

	# show all users' name, id, sh/bash
	cat /etc/passwd

	# show all groups' name, id, assigned users
	cat /etc/group

	# login remote server without entering password
	ssh-keygen -t rsa -f keyFileName_rsa
	ssh-copy-id -i keyFileName_rsa.pub username@remote
	ssh username@remote

	# remove public keys on remote machine
	vim $HOME/.ssh/authorized_keys
	# then delete no longer used keys

	# add ssh private key to terminal session (useful for login to server from another server)
	eval $(ssh-agent -s)
	ssh-add ~/.ssh/other_id_rsa

	# copy file content to clipboard
	cat fileName | xclip -sel clip

```

### APT and dpkg stuffs:

```bash

	# update apt repository data
	apt-get update

	# install a package with version number
	apt-get install abc=5.5.29...
	dpkg -i *.deb

	# search a package with name
	apt-cache search packagename

	# uninstall a package
	apt-get remove packagename
	dpkg -r packagename

	# show information about a package
	apt-cache showpkg packagename

	# compare the version of a package in the apt repository and local
	apt-cache policy packagename

	# CLI-gui for apt
	aptitude

	# show a list of upgradeable packages on the machine
	apt-get -u upgrade

	# upgrade only one package
	apt-get install --only-upgrade packagename

	# search a package that contains the given file or command on the machine
	dpkg -S file/command

	# list all installed packages
	dpkg -l

	# search packages that contain the given file name (can be non-installed)
	apt-file search filename

	# delete downloaded files of installation (to free some spaces on disk)
	apt-get autoclean

	# PPA install:
	add-apt-repository ppa:user/ppa-name
	apt-get update
	apt-get install packageInThePPA

	# list all packages in one PPA
	grep ^Package /var/lib/apt/lists/ppaname

	### backup installed packages and restore in another machine
	# create a backup of currently installed packages:
	dpkg --get-selections > packagesList
	# restore installations from the list packagesList:
	dpkg --clear-selections
	dpkg --set-selections < packagesList
	apt-get autoremove
	apt-get dselect-upgrade

	### upgrade system
	# check if new version available
	do-release-upgrade -c
	# upgrade
	do-release-upgrade
```

### Operations for files or directories:

```bash

	# create dir
	mkdir abc

	# remove empty dir and its parents (a, b und c will be all deleted)
	rmdir -p a/b/c

	# remove non-empty dir
	rm -fr abc

	# rename dir
	mv dirname newdirname

	# copy dir (if target exists, copy the file in the target dir)
	cp -r path/to/sourcedir path/to/targetdir

	# create file
	touch filename

	# copy file
	cp path/to/sourcefile path/to/targetfile

	# move file
	mv path/to/sourcefile path/to/target

	# rename file
	mv filename newfilename

	# file/folder operations by name using regex
	find dir/ -maxdepth 1 -iregex "pattern" -exec cp {} distdir/ \;
	# example:
	find . -maxdepth 1 -type d -iregex ".*00[0-1][1-2].*" -exec cp -r {} dist/ \;
	# copy folders with name contains *0001*, *0002*, *0011*, *0012*

	# show list of all files and dirs in current location with permissions and human-readable size
	ls -alh

	# permissions: read = 4, write = 2, execute = 1
	# example: -rw-r--r--  ==> 644

	# modify permissions of a dir and its children
	chmod -R 777 dirname

	# modify owner of a file or dir
	chown uid filename

	# modify group of a file or dir
	chgrp groupname filename

	# make new files and directories in one directory also having the same group
	chmod g+s dirname

	# lock/unlock file or dir (with sudo also can not be deleted)
	chattr +i filename/dir
	chattr -i filename/dir

	# only adding content to file or dir allowed
	chattr +a filename/dir
	chattr -a filename/dir

	# search files or dirs that contain 'abc' in name
	find -name '*abc*'

	# search files with name patterns
	find ./src/ -type f -regextype emacs -regex ".*[^e][^c]\.\(ts\|html\|scss\)$"

	# search files that contain 'abc' in contents
	find . -name '*' | xargs grep -nP -C 3 'abc'
	# or
	fgrep -nr -C 3 somethingToSearch *.*

	# sort files by last changed time
	find -type f -exec stat --format '%y %n' "{}" \; | sort -nr | head -n 100

	# replace strings in all found files using regular expression
	find -type f -name "*" -exec sed -i 's/someStringsToBeReplaced/somethingNew/g' {} \;

	# file monitoring
	tail -f filename

	# show users who are using a specified file
	fuser -u -m filename

	# show the disk usage of files and dirs in current location
	du -ah --max-depth=1 ./

	# show total disk usage of a dir
	du -sh path/to/dir

	# sort files and dirs by disk usage in current location
	du -sh * | sort -h

	# upload a dir to a remote machine
	rsync -zrp(tg -X) /path/to/a user@remote.host.com:/path/to/b/

	# download dir from another machine
	scp -r user@hosturl:/path/to/dir /path/to/local/dir

	# download file from web
	wget file-URL

	# compress tar.gz
	tar -zcf abc.tar.gz dirnameOrFilename

	# extract tar.gz
	tar -zxf abc.tar.gz

	# show list of files in a tar.gz
	tar -tvf abc.tar.gz

	# extract one file from a tar.gz
	tar -zxf abc.tar.gz path/to/filename

	# open file explorer
	nautilus pathToFolder

```

### System and machine:

```bash

	# if I forgot every sudo-users' passwords and cannot enter the machine:
	# restart the maschine, enter "Recovery Mode" and type:
	mount -o remount,rw /

	# add path to evironment PATH for this login session
	export PATH=$PATH:/my/path

	# show enironment variables
	env

	# show the version of operation system
	uname -a; head -n 1 /etc/issue
	uname -a; lsb_release -a

	# show full info about motherboard (-t 2: base info; -t 17: memory info; ...)
	sudo dmidecode -t 2/17... | more

	# show info about CPU
	cat /proc/cpuinfo

	# show mounted devices
	mount | column -t

	### share folders to other machine
	## on server:
	apt install nfs-common nfs-kernel-server rpcbind
	# add info in /etc/exports:
	/path/to/shared/folder clientNameOrIP(rw,sync,no_subtree_check)
	/etc/init.d/nfs-kernel-server restart
	# on client:
	apt install nfs-common
	# check if server with folder visible
	showmount -e serverNameOrIP
	# mount server's folder
	mount -o soft,intr,rsize=8192,wsize=8192 serverNameOrIP:/path/to/shared/folder /path/to/shared/folderClient

	# use lshw
	lshw -c display/memory/cpu/...

	# use nvidia specific commands to show info of nvidia graphic cards
	nvidia-smi

	# list of pci devices
	lspci -tv

	# list of usb devices
	lsusb -tv

	# show info about memory, cache and swap in MB, update every 10 seconds
	free -m -s 5

	# add large swap file for memory
	sudo fallocate -l 32G /swapfile
	sudo chmod 600 /swapfile
	sudo mkswap /swapfile
	sudo swapon /swapfile
	sudo echo "\n/swapfile swap swap defaults 0 0" >> /etc/fstab

	# show info about file system
	df -ahT

	# show info about disks
	hdparm -i/-I /dev/sda1

	# format disk (example: USB)
	# unmount first
	umount /dev/sdd1
	# format to ntfs
	mkfs.ntfs /dev/sdd1
	# format to ext4
	mkfs.ext4 /dev/sdd1

	# show info about network interfaces
	ifconfig

	# show info about firewalls
	iptables -L

	# show info about listened ports (protocol, connections, status, processes)
	netstat -plant

	# scan the status of a port (remote)
	nmap -p 8080 example.com

	# monitor net transfer for processes
	nethogs

	# monitor net transfer for all network-interfaces
	bmon

	# show info about running processes
	ps -ef
	ps -eaux

	# sort processes by current cpu usage using ps
	ps -eaux | sort -k 3

	# sort processes by current mem usage using ps
	ps -eaux | sort -k 4

	# monitor running processes
	top

	# limit top by specific process-name
	top -p `pgrep processName | tr "\\n" "," | sed "s/,$//"`

	# calculate ram usage of processes that contain the same processName
	top -n1 -b | grep processName | sort -u -rk 9 | awk '{print $10}' | sed "s/,/\./" | paste -sd+ - | bc

	# check errors of system or services
	systemctl status serviceName
	journalctl -xe

	# increse max number of watched files, inotify watchers reaches limit:
	# modify or add fs.inotify.max_user_watches in /etc/sysctl.conf
	echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf
	sysctl -p

	# increase number of opened files for all/specific users
	# add in /etc/security/limits.conf
	*               soft    nofile            2048
	*               hard    nofile            2048

```

### Hardware:

```bash

	# Usb sound device not working
	## install PluseAudio Volume Control -> Configuration-Tab: set profiles of other sound devices "off"

	# fix NTFS Drive read-only error after used by Windows
	# get path of the device, unmount, then:
	ntfsfix /dev/....

	# setup wlan over lan
	## change interface metrics of wlan greater than lan

```

### Execution of commands:

```bash

	# scheduling tasks:
	# @reboot @yearly ... @daily commands
	# or
	# 30 2 * * * commands (this means, execute the commands at 2:30 every day)
	crontab -e

	# show scheduled tasks
	crontab -l

	### some methods to record output
	# record all output to a file
	command > output.txt
	# record all output to a file (append)
	command >> output.txt
	# record stderr to a file
	command 2> output.txt
	# record output to file and show it in console at the same time
	command | tee output.txt
	### record output of some commands to a file without sh-file
	script output.txt
	command1
	command2
	command3
	exit
	### record commands and their outputs and replay that
	# record commands and outputs
	script -t 2>commands.time output.txt
	command1
	command2
	command3
	exit
	# replay the commands (nothing will be re-executed, only the typing and results)
	scriptreplay commands.time output.txt
```

## Often used programs' commands:
### Git:

```bash
	# init a new repository
	git init
	# init a new repository on server-site
	git init --bare

	# add github, bitbucket, ... to existing local git-repo
	git remote add origin<EMAIL_ADDRESS>	git push -u origin master

	# push tag to remote
	git push origin tagName
	# push a moved tag
	git push origin tagName --force

	# change remote URL
	git remote set-url origin<EMAIL_ADDRESS>
	# push all branches to all remote repositories
	git remote | xargs -L1 git push
	# push one branch (e.g. master) to all remote repositories
	git remote | xargs -L1 -I R git push R master

	## commit changes
	# stage a file
	git add filename
	# stage all changed files
	git add -A
	# commit with message
	git commit -m "commit comment"
	## or
	git commit -a -m "commit comment"
	# make a empty commit (useful for triggering a hook)
	git commit --allow-empty -m "comment"

	# unstage all staged files
	git reset

	# change message of last commit
	git commit --amend

	# git reset commit HARD (reset pointer and files) and SOFT (reset only pointer)
	git reset HEAD^ --hard (--soft)

	# restore commit after reset
	git reflog
	git reset 'HEAD@{number}' # HEAD@{number} is the reference of throwed commit in reflog

	# change message of a specific commit
	git rebase -i HEAD~number #number: how far is the to changed commit referenced from HEAD
	# change 'pick' with 'reword', then save.
	# change message, then save.

	# change commt message to remote: first change message like above locally, then
	git push --force originOrOther branchOfTheCommit

	# recursive add empty directories to git-repository, except the directories in .git/
	find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

	# show branches
	git show-branch

	# create branch and switch to it
	git checkout -b branchName

	# delete local branch
	git branch -d branchName
	# delete remote branch
	git push originOrOther --delete branchName
	# set branch to other commit/branch...
	git branch -f branchName otherCommitOrBranch

	# merge other branch with current branch
	git merge otherBranchName
	# merge other branch using changes of current branch
	git merge -s ours
	# merge other branch using strategy "recursive", but only by conflicts using changes of current branch
	git merge -X ours
	# merge other branch using strategy "recursive", but only by conflicts using changes of incoming branch
	git merge -X theirs

	# fast forward merge into other branch without checkout it first
	git fetch . master:release # . means using local repo; merge master into release

	# make commits as if they took place after other commits in other branch were made
	git rebase origin/master master

	# use stash to store changes temporarily
	git stash
	git stash list
	git stash apply [stash@{num}]
	# delete all stashed changes
	git stash clear
	# show changes in a stash
	git stash show -p
	git stash show -p stash@{num}

	# list commits which change a spec file
	git log --follow fileName

	# list commits with stat of changes
	git log --stat

	# check changes of lines in commits
	git log -L110,120:src/.../.../filename

	# show diff between 2 commits, branches or changed files
	git diff commitHash1 commitHash2
	git diff HEAD commitHash
	git diff commit1 commit2 -- path/to/fileName

	# show merge request locally
	git diff master...branch

	# show changes of master since branch was created
	git diff branch...master

	# remove "^m" by git diff
	git config --global core.whitespace cr-at-eol

	# try to cache password for the next n seconds (useful for https git remote)
	git config credential.helper 'cache --timeout=2592000'  (30 days)

	# advanced log with graph in terminal
	# (THANK FOR https://stackoverflow.com/questions/1838873/visualizing-branch-topology-in-git/34467298#34467298)
	git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n''          %C(white)%s%C(reset)%n''          %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'

	# search code in one commit and particular file type
	git grep <regexp> <commit> -- '*.ts'
	# search code in all commit history
	git grep <regexp> $(git rev-list --all)
	# and more THANKS TO https://stackoverflow.com/a/2929502

	# show which author in which commit last modified lines of a file
	git blame -L300,+1 fileName

	# list all authors in one repo (n: sort by num of commits)
	git shortlog -sn | awk -F ' ' '{print $2, $3}'

	# count changing lines of authors
	git log --format='%aN' | sort -u | while read author; do echo "$author " && git log --author="$author" --pretty=tformat: --numstat -- . ':!to-be-excluded-dir' | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "lines added: %s, removed: %s, total: %s\n", add, subs, loc }'; done

	# count lines of authors based on HEAD
	git ls-files | while read f; do git blame -w -M -C -C --line-porcelain "$f" | grep "^author "; done | sort -f | uniq -ic | sort -n

	# list num of commits and the date of last commit of each author
	git log --format='%aN <%aE>' | sort -u | while read name; do; echo -ne "$name\t\t\t"; echo -en `git log --author="$name" --pretty=tformat: --numstat | wc -l`; echo -e "\t" `git log --author="$name" --max-count=1 --format=%cd`; done

	# create a patch
	git format-patch <commit/branch> --stdout > named.patch
	# check if a patch can be applied
	git apply --check named.patch
	# check patch info
	git apply --stat named.patch
	# apply patch
	git apply named.patch

	# remove file from index
	git rm --cached filename

```

### Apache2:

```bash

	# start, stop
	service apache2 start/stop

	# restart gracefully
	service apache2 reload

	# enable, disable modules
	a2enmod modName
	a2dismod modName

	# enable, disable sites
	a2ensite siteName
	a2dissite siteName

	# enable, disable config
	a2enconf confName
	a2disconf confName

	# show enabled modules or sites(settings in config files)
	apache2tcl -M / -S
```

### Docker

```bash

	# get docker system info
	docker system info

	# show space usages
	docker system df
	docker system df -v

	# create image using Dockerfile
	docker build -t tagName pathContainsDockerfile

	# create image using running/stopped container
	docker commit -a "author info" -m "message info" containerName imageName[:tag]

	# transfer image not using registry
	docker save --output imageName.tar imageName
	docker load --input imageName.tar

	# run an image with portforwarding and run it in background
	# there are a lot of other useful parameters available for this command such as -v --restart etc.
	docker -d -p 8888:80 imageTagName

	# list all containers
	docker ps -a

	# list all images
	docker images -a

	# stop a container
	docker stop containerID
	# stop a container forcely
	docker kill containerID

	# delete container
	docker rm containerID

	# delete container with volume
	docker rm -v containerID

	# delete all containers
	docker rm $(docker ps -a -q)

	# delete an image
	docker rmi imageTagName

	# delete all images
	docker rmi $(docker images -a -q)

	# manage volumes in /var/lib/docker/volume
	docker volume ls
	docker volume rm volumeName
	docker volume inspect volumeName

	# find out all mounts and volumes of a container
	docker inspect -f {{ .Mounts }} containderId

	### clean up (thanks to https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430)
	# clean temp containers: mostly created by running Dockerfile
	docker rm -v $(docker ps -qa --filter "status=exited" --filter "name=_")
	# clean temp images
	docker rmi $(docker images | grep "none" | awk '/ / { print $3 }')
	# clean unsed volumns
	docker volume rm $(docker volume ls -q --filter "dangling=true")

	# execute commands in container
	docker exec containerName bash -c "commands"
	# execute commands in container with console
	docker exec -it containerName bash -c "commands"

```

## some small tricks

### workaround for meld encoding problems:

```bash

	gsettings set org.gnome.meld detect-encodings "['UTF-8','ISO-8859-1','UTF-16']"
```

### Port forwarding over SSH:

```bash

	# connect 3306 on example.org with username through local port 3316
	ssh -f<EMAIL_ADDRESS>-L 3316:localhost:3306 -N
```

### adding bash script to Unity panel as quick laucher

	# THANK TO https://askubuntu.com/questions/141229/how-to-add-a-shell-script-to-launcher-as-shortcut

### menu bar in gnome top bar
	# use the extention Gnome Global Application Menu(HUD for Gnome) by extensions.gnome.org

### install typescript support for vim

```bash
	git clone https://github.com/pangloss/vim-javascript.git ~/.vim/pack/vim-javascript/start/vim-javascript
	git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/pack/typescript/start/typescript-vim
```

### Windows-Desktop running in VirtualBox under Ubuntu:

```bash

	# auto setup the resolution to the size of the VM-window in the host(Ubuntu)
	# get the name of the running vm
	VBoxManage list runningvms
	VBoxManage controlvm "name_of_the_running_vm" setvideomodehint 1280 900 32

```

### Setup the number of workspaces in Ubuntu : 3*3

```bash

	dconf write /org/compiz/profiles/unity/plugins/core/hsize 3
	dconf write /org/compiz/profiles/unity/plugins/core/vsize 3
	restart

	# actually I don't use the above mentioned 3 commands any more because I found
	# the unity tweak tool.
	apt-add-repository ppa:tualatrix/ppa
	apt-get update
	apt-get install ubuntu-tweak

```

### setup mysql open_files_limit:

##### if using systemd: (Thanks minni's answer https://stackoverflow.com/a/35515570)

In the file /lib/systemd/system/mysql.service you have to add this 2 lines in the [Service] section at the end:

	LimitNOFILE = infinity
	LimitMEMLOCK = infinity

After this restart systemctl and mysql:

```bash

	systemctl daemon-reload
	/etc/init.d/mysql restart

```

To check if the configuration is effective, you can get the parameter from the running mysql process like this:

```bash

	cat /proc/$(pgrep mysqld$)/limits | grep files

```

##### or: (Thanks for https://duntuk.com/how-raise-ulimit-open-files-and-mysql-openfileslimit)

### change mysql default `datadir`:

stop mysql:

```bash

	service mysql stop

```

copy mysql data dir:

```bash

	cp -R -p /var/lib/mysql /new/path

```

edit conf file, change /var/lib/mysql to /new/path:

```bash

	vim /etc/mysql/mysql.conf.d/mysqld.cnf
	vim /etc/apparmor.d/usr.sbin.mysqld
	# reload apparmor conf
	/etc/init.d/apparmor reload

```

restart mysql:

```bash
	service mysql start
```

### certificates:

#### use certbot:

```bash

	# install certbot for apache
	apt install python-certbot-apache
	# install a certificate for a domain
	certbot --apache
```

#### create certificate manually:

create root CA:

```bash
	openssl genrsa -aes256 -out rootCA-privateKey.pem 2048
	openssl req -new -key rootCA-privateKey.pem -out rootCA-req.csr -subj "/C=Country/ST=City/L=Land/O=someCompany/OU=CompanyDepartment/CN=domainName"
	openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey rootCA-privateKey.pem -in rootCA-req.csr -out rootCA-ca.cer

```

use root CA to encrypt server certificate:

```bash
	openssl genrsa -aes256 -out server-privateKey.pem 2048
	openssl req -new -key server-privateKey.pem -out server-req.csr -subj "/C=Country/ST=City/L=Land/O=someCompany/OU=CompanyDepartment/CN=domainName"
	openssl x509 -req -days 3650 -sha1 -extensions v3_ca -CA rootCA-ca.cer -CAkey rootCA-privateKey.pem -CAserial rootCA-ca.srl -CAcreateserial -in server-req.csr -out server-cer.cer

```

use root CA to encrypt client certificate:

```bash
	openssl genrsa -aes256 -out client-privateKey.pem 2048
	openssl req -new -key client-privateKey.pem -out client-req.csr -subj "/C=Country/ST=City/L=Land/O=someCompany/OU=CompanyDepartment/CN=domainName"
	openssl x509 -req -days 3650 -sha1 -extensions v3_ca -CA rootCA-ca.cer -CAkey rootCA-privateKey.pem -CAserial rootCA-ca.srl -CAcreateserial -in client-req.csr -out client-cer.cer

```

export p12:

```bash
	openssl pkcs12 -export -clcerts -inkey client-privateKey.pem -in client-cer.cer -out client-cer.p12
```

#### print certificates:

```bash
	keytool -printcert -file cert.pem
```

#### asym. encrypting:

```bash
	# generate private key
	openssl genpkey -algorithm RSA -out private-key.pem -pkeyopt rsa_keygen_bits:2048
	# generate public key of the private key
	openssl rsa -pubout -in private-key.pem -out public-key.pem
	# encrypt with public key
	openssl rsautl -encrypt -inkey public-key.pem -pubin -in some.txt -out some.txt.encrypted
	# decrypt with private key
	openssl rsautl -decrypt -inkey private-key.pem -in some.txt.encrypted -out some.txt
	# encrypt with private key
	cat some.txt |  openssl rsautl -inkey private-key.pem -sign > some.txt.enc-with-private-key.encrypted
	# decrypt with public key
	openssl rsautl -inkey public-key.pem -pubin -in some.txt.enc-with-private-key.encrypted
```

### awk

```bash
	# analyse apache error log file: count accesses by ip and sort the results
	awk -F "[][{}]" '{print $8}' error.log | awk -F ":" '{print $1}' | sort | uniq -c | sort -n
```

### usb tethering

```bash
	# 1. turn on usb tethering on phone
	# 2. find out network adaptor name
	ifconfig -a
	# or
	ip link
	# then
	ifconfig enp0xxxxxxxxx up
	# 3. add config in /etc/network/interfaces
	# auto enp0xxxxxxxxx
	# iface enp0xxxxxxxxx inet dhcp
	# 4. activate
	ifup enp0xxxxxxxxx

```

### AC 1200 rtl88x Wifi driver

	# check https://github.com/cilynx for newest driver and follow the readme
######################


text:
# Terraform AWS API Gateway container
This module will create an apiGateway Container
Check out `variables.tf` to better understand module parameters.

## Example:
```
module "api-gateway-container" {
  source           = "path-to-this-folder/tf-apigateway-container"
  api-gateway-name = "simple-api-public"
}
```

## Terraform version

No special requirement, but as always try to use an up to date version:)

## Module outputs
This module exposes the following outputs:
 * api-gateway-id : The ApiGateway Container ID
 * api-gateway-root: The ApiGateway Container Root

repository: kallelzied/demo-terraform-aws

gha_language: HCL

repo_name: kallelzied/demo-terraform-aws


text:
# Understand how Bitcoin-Qt encrypt your wallet

I loose my bitcoin wallet password. So decide to investigate how bitcoin-Qt
encrypt wallet to try a brut force my password.

I'm going to try to explain to you how to decrypt your wallet with an known
password. This explation is for people who are expert in cryptography, but it's
a standard procedure to encrypt something. It's more personnal note than a
complete explanation.

The bitcoin wallet it based on AES-256-CBC cipher algorithm and SHA-512
digest<sup>[1][wallet_encryption], [2][wallet_encryption2]</sup>.

## Kowns about AES-256 key and iv

An AES-256 needs to parameters to be procedeed. As you imagine, you need a key.
This key is a bug number of 256 bits and it's used for encrypt and decrypt. But
this key is useless if you don't have the iv (initialization vector).

I don't know how excatly AES-256 algorithm but you have to tell where your
algorithm have to start. IV is used with the first data block. IV is also a big
number, in case of bitcoin wallet is 128 bits long.

You can read more about key and iv on [Wikipedia][initialization_vector].

## Encryption step-by-step

### EVP_BytesToKey

First you enter a passphrase. The passphrase is not key. This size is not fixed
and if you use it as a big number (each characters is one byte of the big
number) you reduce considerably the securty.

For that __bitcoin-qt__ (and I think a lot of other) hash your passphrase to
get a pseudo-random big number with a constant size. The hash used is SHA-512.
It's result in a BIG number. First 32 bytes of the hashed passphrase are the key
and next 16 bytes are iv. The to entry point of your AES algorithm.

But the particularity point of bitcoin wallet result in use of
[OpenSSL EVP_BytestoKey][evp_bytestokey] function.

This function do a hash your passphrase with a selected digest, but instead of
hashing just one time, it's hash _n_ times with _n_ equal to a big number. _N_
it depend of your CPU power (_n_ is about 100 000 on my actual computer).

This method it used to protect from brut force attack, because for each
password you check, you have to calculate _n_ hashes.

You can read the parameters _n_ when you dump your wallet _nDeriveIterations_.
You can also see a _salt_ wich it is a 8 bytes long random number concatenated
to the passphrase during hash process.

The documentation of OpenSSL about EVP_BytestoKey [is wrong][ssleay],
or I mistanderstanding it. You can see below the simplified equivalent
implemantion of EVP_BytestoKey function in [Ruby][ruby].

~~~ruby
def EVP_BytesToKey(password, salt, iterations, digest)
  h = digest.digest password + salt
  (iterations - 1).times { h = Digest::SHA512.digest h }
  return h[0..31], h[32..47]
end
~~~

### Master key encryption

For various cryptographics reasons, The result of previous EVP_BytesToKey is
not used directly to encrypt your private bitcoin keys. Your entire wallet
is encrypted with a very random and very big master key. The hashed passphrase
encrypt the master private key. The avantages of this solution are when you
choose to change your passphrase the software to re-encrypt all your wallet. It
just re-encrypt the master key.

Each private bitcoin keys are encrypted separatly. The master key is the same
for each, but the initialization vector is determined by the first bytes of a
double SHA-256 of your __public bicoin key__ (not the bitcoin address).

[wallet_encryption]: https://bitcointalk.org/index.php?topic=8728.0
[wallet_encryption2]: https://en.bitcoin.it/wiki/Wallet_encryption

[initialization_vector]: http://en.wikipedia.org/wiki/Initialization_vector
[evp_bytestokey]: http://www.openssl.org/docs/crypto/EVP_BytesToKey.html
[ssleay]: https://github.com/openssl/openssl/blob/master/doc/ssleay.txt#L2332
[ruby]: https://www.ruby-lang.org


text:
# SAS Studio Tasks Resembling SAS Enterprise Guide Prompts

These tasks allow you to add prompts of various types into your SAS Studio process flows.  These tasks are structured to display input controls that are similar to Enterprise Guide prompts and to set analagous macro variables.  If you would like to use one of these tasks for input but you need the task to set a different macro variable or series of macro variables, you can make a copy of the task and edit it to meet your specific needs.

Using the Prompt repository in SAS Studio

You can make this repository of tasks available within SAS Studio.

1. In SAS Studio go to the main menu and select Preferences.

2. On the Repositories tab of the Preferences dialog click the Add (+) button.

3. On the Add Repository dialog in the Name field specify the name (Ex. Enterprise Guide Prompt Style Tasks) you would like to appear in the Tasks and Utilities tree.  In the URL field specify https://sassoftware.github.io/sas-studio-tasks/prompts/repository.html for the URL.

4. Save the definition.

5. A node with the name that you specified in the defintion (Ex. Enterprise Guide Prompt Style Tasks) will show up in your Tasks and Utilities panel.  In the Prompts folder you will see sample SAS Studio tasks.

Using the Prompt Tasks

If you would like to modify or combine these tasks, you can copy the tasks you would like to use by selecting "Add to My Tasks" or "Add to Folders" on the task context menu.   You can edit the copied tasks and modify the macro variable names if you would like different values.  You can also pull the appropriate sections out of the tasks into a new task if you would like more than one prompt in your task.

The [SAS® Studio 3.6: Developer’s Guide to Writing Custom Tasks is available here](http://go.documentation.sas.com/?cdcId=webeditorcdc&cdcVersion=3.6&docsetId=webeditordg&docsetTarget=titlepage.htm&locale=en).

repository: Samson-LI/sas-studio-tasks

repo_name: Samson-LI/sas-studio-tasks


text:
# positions.destiny.gg

This is the GitHub repository for the [Destiny Positions website](https://positions.destiny.gg).

It is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator.

## Installation

```console
yarn install
```

## Local Development

```console
yarn start
```

This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.

## Contributing

* Content on this site reflects the views and positions of streamer Steven "Destiny" Bonnell.
* Contributions should be limited to these views and subject to approval.
* This project is hosting agnostic and meant to run on any [JAMStack](https://jamstack.wtf/#what-is-jamstack) provider.
* Questions or comments outside of PRs can be submitted via E-Mail to<EMAIL_ADDRESS>This GitHub repository is not for political discourse.

## Building  / Deployment

Site is deployed to production via [Cloudflare Pages](https://developers.cloudflare.com/pages/) with changes focused on the `main` branch.


text:
# STA304-Final-Project

Two data sets are used in this project.

Raw survey data("2019 Canadian Election Study - Online Survey v1.0.dta.zip") is too large and so has trouble to upload. So I zip the file. Please download it and unzip the file if needed.

Raw census data("AAu01LGi.csv.zip") is also large, and so I zip the file. Please download it and unzip the file if needed.

Cleaned survey data("survey_data.csv.zip") and cleaned census data("census_data.csv.zip") are uploaded to my respository. Please download it and unzip the file if needed.

The followings are some explanations about files:

1. "Change in the 2019 Canadian Federal Election Result if Everyone had Voted.Rmd" is the rmd file about final project.

2. "STA304 FINAL PROJECT.pdf" is the pdf file about final project.

3. "Prepare and clean the survey data.R" is the file used to clean raw survey data and prepare for later post stratification.

4. "Prepare and clean the census data.R" is the file used to clean raw census data and prepare for later post stratification.

5. "gss_labels.txt" and "gss_dict.txt" are used in "Prepare and clean the census data.R" to clean raw census data.

path: /README!!!!!!!!(Some instructions about data).md


text:
## 1347. Minimum Number of Steps to Make Two Strings Anagram

You are given two strings of the same length ```s``` and ```t```. In one step you can choose **any character** of ```t``` and replace it with **another character**.

Return *the minimum number of steps* to make ```t``` an anagram of ```s```.

An **Anagram** of a string is a string that contains the same characters with a different (or the same) ordering.

##### Example 1:
```
Input: s = "bab", t = "aba"
Output: 1
Explanation: Replace the first 'a' in t with b, t = "bba" which is anagram of s.
```
##### Example 2:
```
Input: s = "leetcode", t = "practice"
Output: 5
Explanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.
```
##### Example 3:
```
Input: s = "anagram", t = "mangaar"
Output: 0
Explanation: "anagram" and "mangaar" are anagrams.
```

##### Constraints:

* ```1 <= s.length <= 5 * 10^4```
* ```s.length == t.length```
* ```s``` and ```t``` consist of lowercase English letters only.

repository: stdstring/leetcode

repo_name: stdstring/leetcode


text:
A chat room with dice rolling, user-defined variables and macros, and multiple roles per user.

I wrote this to facilitate playing with my own friends,
almost all in one day so the code structure is pretty awful,
but it might be useful for others...

The initial structure of the code was based on the half-way point in the [vibe.d tutorial on webchat](http://vibed.org/blog/posts/a-scalable-chat-room-service-in-d), but diverged significantly from there.

To get started, you'll need a D compiler and the code, a server to run it on, and a `settings.json` file added to the root project directory that looks something like the following:

    {"addresses":["::1","<IP_ADDRESS>","<IP_ADDRESS>","example.com"]
    ,"port":23456
    ,"users":
      {"luther":
        {"pw":"luther's password"
        ,"roles":["GM","*"]
        }
      ,"player1":
        {"pw":"swordfish"
        ,"roles":["ug","nemo"]
        }
      ,"p2":
        {"pw":"p4$5w0rd"
        ,"roles":["viscount"]
        }
      }
    }

The `addresses` and `port` specify how vibe.d listens;
the `users` gives the HTTP Basic Auth usernames and passwords of all accounts
(this is not secure, don't let users use meaningful passwords without updating the code to use HTTPS and a better authentication scheme)
together with the roles they can be in play.
Names must be single identifiers (as determined by the javascript regexp `/\w+/`{.js}).
The first role in each array is the default; the others may be assumed upon request.
The special role `*` allows becoming any role.
Roles must not contain pipe characters (`|`).

license: Unlicense

repository: tychonievich/dicechat

repo_name: tychonievich/dicechat


text:
Scheduling Recurring Code Execution Through Serverless Framework
================================================================

Motivation
----------

Running code on a regular interval is a pretty common task in software development. With such common
use cases as:

* manual backup of a database
* cleaning up files on a regular interval
* implementing a time to live (TTL) on resources
* polling an API on a regular interval
* re-subscribing to expired event notifications
* sending emails on a regular basis

The first impulse for many developers that need to accomplish such tasks is to start writing
a script of a language of their choice and then scheduling execution via the commandline tool,
`cron`. Then, once the script gains uptime requirements, web hosting, daemonization, scaling, and
continuous deployment all become concerns. These supporting tasks may end up becoming more work
than coding up the actual work you are trying to get done in the first place.

Fortunately, the big players in cloud computing services have solutions aimed at reducing the
boiler-plate involved in running code in the cloud. These solutions are commonly referred to
as `Serverless`. Serverless is one step beyond traditional PaaS offerings. With Severless your code
takes minimal time to "spin up" for the first time, only runs when invoked, is typically
cheaper than persistent servers when those servers are underutilized, autoscales, and requires less
deployment environment configuration than with most PaaS setups.

As Serverless services are a relatively new avenue of cloud code execution, there is not a widely
used standard for shaping your serverless project. There is, however, a few frameworks focused on
abstracting away the differences between Serverless cloud providers. Using one of these frameworks
helps mitigate vendor lock-in.

Setup
-------

This post will use the [Serverless Framework](https://serverless.com/) to deploy an [AWS Lambda](https://aws.amazon.com/lambda/) function that executes Node.js code on a schedule.

Make sure you [install Node.js](https://nodejs.org/en/download/package-manager/) and set up [AWS credentials](https://serverless.com/framework/docs/providers/aws/guide/credentials/) for your development environment. Commands in this tutorial will use the [npx commandline utility](https://www.npmjs.com/package/npx) which was introduced with `npm` version 5.2.0.

Code
-----

Feel free to download and modify the [git hub project](https://github.com/minervas/scheduled-serverless-fn) for this tutorial.

All serverless framework projects start with a simple `serverless.yml` file that contains basic
configuration for your project.

```YAML
# name your project here
service: scheduled-serverless-fn

# config relavent to the cloud provider that will run your serverless function
provider:
  # we will use AWS for this tutorial, but check out the list of all supported providers here:
  # https://serverless.com/framework/docs/providers/
  name: aws
  # this example is coded in node.js but check out all the supported aws lambda runtimes here:
  # https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
  runtime: nodejs8.10

# config for all the functions that make up your service
functions:
  # the name of your function
  scheduleFunction:
    # {{path to the script containing the entrypoint of your function}}.{{the entrypoint function name}}
    handler: entrypoint.scheduleFunction
    # config for what sort of events trigger your function
    events:
      # invoke our function on the first minute of every even 15 minute interval
      # check out
      # https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html
      # for AWS cron syntax
      - schedule: cron(0/15 * * * ? *)
```

After creating this configuration you'll want to create the entry point of your function, I named
mine `entrypoint.js`. Note, exported `scheduleFunction` whose name matches the handler function
name in our `serverless.yml`

```javascript
// the class that contains task logic to accomplish our goals
const ScheduleWorker = require('./ScheduleWorker');
// instantiate the class
const scheduleWorker = new ScheduleWorker();

// start setting up resources that will persist between serverless invocations
const persistantResourcesReady = scheduleWorker.setupPersistentResources();

module.exports.scheduleFunction = async () => {
  // wait for persist
  await persistantResourcesReady;
  // check if any persistent resources expired between invocations
  await scheduleWorker.refreshResources();
  // set up resources that should only exist during the function invocation
  await scheduleWorker.setupEphemeralResources();
  // complete the scheduled task
  await scheduleWorker.doWork();
  // clean up resources that should only exist during the function invocation
  await scheduleWorker.cleanUpResources();
};
```

Here is the ScheduleWorker class, with logging in every method to demonstrate that the method is called and in what order:

```javascript
// class that contains the logic necessary to accomplish our scheduled task
const ScheduleWorker = class {
  constructor() {
    console.log('ScheduleWorker constructor called');
  }

  async setupPersistentResources() {
    console.log('ScheduleWorker setupPersistentResources called');
  }

  async refreshResources() {
    console.log('ScheduleWorker refreshResources called');
  }

  async setupEphemeralResources() {
    console.log('ScheduleWorker setupEphemeralResources called');
  }

  async doWork() {
    console.log('ScheduleWorker doWork called');
  }

  async cleanUpResources() {
    console.log('ScheduleWorker cleanUpResources called');
  }
};

module.exports = ScheduleWorker;
```

If you have downloaded the github project for this tutorial you will want to run `npm install` to
install dependencies. Otherwise, at a minimum you will need to setup the serverless npm package as a dev-dependency by running `npm install serverless --save-dev`. In the github project I have setup
linting and testing boiler plate by way of [eslint](https://eslint.org/) and [jest](https://jestjs.io/). I won't go into the intricacies of
these setups, but you should be able to verify that files in the repo pass linting and test
requirements by executing `npm run lint` and `npm run test`. You can test running our function
locally through the serverless npm package by executing `npx sls invoke local -f scheduleFunction`.
This should produce the following output:

```
ScheduleWorker constructor called
ScheduleWorker setupPersistentResources called
ScheduleWorker refreshResources called
ScheduleWorker setupEphemeralResources called
ScheduleWorker doWork called
ScheduleWorker cleanUpResources called
```

Now we are ready to deploy our function, which can be done with `npx sls deploy`, which will print
something similar to:

```
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service scheduled-serverless-fn.zip file to S3 (84.61 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.....................
Serverless: Stack update finished...
Service Information
service: scheduled-serverless-fn
stage: dev
region: us-east-1
stack: scheduled-serverless-fn-dev
resources: 7
api keys:
  None
endpoints:
  None
functions:
  scheduleFunction: scheduled-serverless-fn-dev-scheduleFunction
layers:
  None
```

We can see the logs of our function execution in AWS by `npx sls logs -f "scheduleFunction"`.
However, if you execute this command before the first scheduled invocation of your function (as
dictated by our cron expression on our `serverless.yml` file) you will get the error:
`No existing streams for the function`. This is because AWS waits for the function to invoke once
before creating the CloudWatch log streams that your function logs will be available on.

Finally, once you are done with your function you can delete all AWS resources allocated for the
service you specified in your `serverless.yml` file by executing `npx sls remove`

repository: minervas/scheduled-serverless-fn

repo_name: minervas/scheduled-serverless-fn


text:
---
title: Popconfirm React component
components: Popconfirm
---

# Popconfirm

A Popconfirm can be used to confirm your actions.

## Anchor playground
Use the radio buttons to adjust the anchorOrigin and transformOrigin positions.

{{"demo": "pages/demos/popconfirm/Popconfirm.js"}}

branch_name: refs/heads/develop


text:
# Contributor's Guide

How to make contributions to this repo.

First fork the repo, and clone your copy onto your local machine, and navigate there from the command line.

Activate a virtual environment. Then install package dependencies:

```sh
pip install -r requirements.txt
pip install -r tests/requirements.txt
```

Run tests (may take 90 seconds):

```sh
pytest tests --disable-pytest-warnings
```

repository: unitaryai/detoxify

gha_language: Python

repo_name: unitaryai/detoxify


text:
---
title: What powers the blog
date: "2020-09-21"
template: "post"
draft: false
slug: "what-powers-the-blog"
category: "Programming"
tags:
  - "Programming"
description: "How this blog is made of"
socialImage: "/media/42-line-bible.jpg"
---

# Tech behind the blog

Gatsby - Gatsby is a React-based open-source framework by which this is been built.

Why I chose Gatsby - Very popular and lot of plugins and community support

DNS provider - Godaddy, where I bought my domain name

Netlify - Hosting service and it is absolutely free for hosting static sites. Gatsby  is very much compatible with Netlify and it is a cake for deploying Gatsby sites on Netlify

Cloudflare - My CNAME is transferred to cloud fare, where I can configure DNS very easily and it gives a wildcard SSL certificate.

[](https://github.com/vzhou842) |[](https://github.com/alehel) |[](https://www.gatsbyjs.com) |
:---: |:---: |:---: |:---: |:---: |:---: |
[Netlify](https://www.netlify.com/) |[Cloudfare](https://www.cloudflare.com/) |[Gatsby](https://www.gatsbyjs.com/) |

repository: kumaraswins/sreejith-blog

repo_name: kumaraswins/sreejith-blog


text:
# BlinkenWindow

A simple ruby library to control the blinken lights setup on my front window. :)

Video of the actual window and simulator running the demo.

## Installation

Add this line to your application's Gemfile:

    gem 'blinken_window', :github => 'akhilstanislavose/blinken-window'

And then execute:

    $ bundle

## Usage

To get started you can use a simulator which runs on the terminal.

    require 'blinken_window/shifters/terminal_shifter'
    require 'blinken_window/screen'

    # Setup a screen with 6 columns and 10 rows
    screen = BlinkenWindow::Screen.new(6,10, BlinkenWindow::Shifters::TerminalShifter.new(6,10))

    # clears the screen
    screen.clear

    # Lights up the bulb at (x,y)
    screen.put(0,0)

    # Resets up the bulb at (x,y)
    screen.put(0,0,0)

    # Sets the pixel but doesnt render it, so call render explicitly to render
    screen.set(5,9)
    screen.render

    # Paints the entire screen with matrix given
    screen.paint(matix)

Once you have the animation/game/wierd idea ready and need to test it on the actual thing, just change the shifter to an object of `BlinkenWindow::Shifters::GPIOShifter`

    screen = BlinkenWindow::Screen.new(6,10, BlinkenWindow::Shifters::GPIOShifter.new(6,10))

**NB: `BlinkenWindow::Shifters::GPIOShifter` requires `wiringpi` gem, and you will need Raspberry Pi to run it.**

## Examples

Also checkout the examples folder to start playing around

  * [canvas.rb](https://github.com/akhilstanislavose/blinken-window/blob/master/examples/canvas.rb) -  A web interface to control the bulbs.
  * [blm_player.rb](https://github.com/akhilstanislavose/blinken-window/blob/master/examples/blm_player.rb) - A simple blm palyer which can play blinken movies
  * [pong.rb](https://github.com/akhilstanislavose/blinken-window/blob/master/examples/pong.rb) - Class pong game that can be controlled using keyboard or websocked client
  * [blinken_string.rb](https://github.com/akhilstanislavose/blinken-window/blob/master/examples/blinken_string.rb) - A string class which can easily generate frames to animate text on blinken window
  * [matrix.rb](https://github.com/akhilstanislavose/blinken-window/blob/master/examples/matrix.rb) - Using matrices to generate frames with patterns really fast

By default all the example are set to use terminal emulator so that you can see the output. Some example use web interface to control them so open up the browser.

    # Examples might need some extra gems to work, eg., sinatra
    bundle install

    bundle exec ruby examples/blinken_string.rb

**NB: Terminal emulator is implemented using curses library, which used to be part of Ruby standard library till 2.0, so you will have to run the examples using version not greater than 2.0**

## Hardware
The requirement was to connect 60 leds to Raspberry Pi, but it doesn't have that many GPIO pins. So the solution was to use an output exapnder, which could provide 60 outputs. Easisest way to do that is to use Shift Registers with latch option, they act as a serial to parallel converter. We can stream the serial data in to the shift register and it will set its outputs corresponding to the bits received. Standard shift registers(CD4094, 74HC595) are 8bits ie., 8 outputs, but by cascading 8 of them we can have 64 outputs. Below is a snap a of expander board I built.

Along with the shift register I also had to use transitors to drive the LEDs as the shift registers couldn't provide enough current to drive the 50mA LEDs I used. To make the project extensible, I have designed a simple module which can be connected like legos and you can extend the number of outputs as per your requirment.

The module idea came late to me as my friends asked me the easiest way to make thier windows blink without all the soldering and stuff. I am in the process of fabricating the actual PCBs and once it is done, I will put some pictures of it. You can download the Eagle files from [http://goo.gl/GG7Nz7](http://goo.gl/GG7Nz7)

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


text:
# rmpatternlanguage
An bookdown theme for A Pattern Language in R Markdown

Example website hosts through this repos github pages option:

[https://crumplab.github.io/rmpatternlanguage/](https://crumplab.github.io/rmpatternlanguage/)

This bookdown theme was written by Matt Crump. It is inspired by the book, "A PATTERN LANGUAGE", by Christopher Alexander, Sara Ishikawa, Murray Silverstein, also Max Jacobson, Ingrid Fiksdahl-King, and Shlomo Angel.

This is indeed an interesting book, worth reading to see a great example of a pattern language. Google pattern language and you can learn more about what it is, and how to make one. This is a theme to make your pattern language  in the same visual style and format as the original book.

This is a minimal reproducible example, fork this repo, then compile in R-Studio with the bookdown package. The formatting should be set-up to work, if you follow the templates in each chapter. Have fun!

repository: CrumpLab/rmpatternlanguage

repo_name: CrumpLab/rmpatternlanguage


text:
# 10) Queryservice tarball {#adr_0010}

Date: 2021-01-20

## Status

accepted

## Context

For the building of the queryservice docker image we are currently using the versioned release tarballs [published by the WMF](https://archiva.wikimedia.org/repository/releases/org/wikidata/query/rdf/service).

This package already contains all the required components to build the docker image and we don't see any reason to alter or publish these releases further.

## Decision

Do not produce a queryservice tarball to be published.

## Consequences

- Use the existing queryservice release tarball for building the docker images.
- When building and tagging the docker image the WMF release version should be used.

repository: wmde/wikibase-release-pipeline

repo_name: wmde/wikibase-release-pipeline


text:
# Tuburcinia eranthidis (Pass.) Liro, 1922 SPECIES

#### Status
SYNONYM

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

#### Published in
null

#### Original name
Urocystis pompholygodes var. eranthidis (Pass.) Pass., 1877

### Remarks
null

repository: mdoering/backbone

path: /life/Fungi/Basidiomycota/Ustilaginomycetes/Urocystidiales/Urocystidaceae/Urocystis/Urocystis eranthidis/ Syn. Tuburcinia eranthidis/README.md

repo_name: mdoering/backbone


text:
Under-Construction
==================
Repository for website templates.

##### Project Template: Under Construction

![First image](images/site_preview.jpg?raw=true "Screenshot")

repository: NIO-Design/Under-Construction

repo_name: NIO-Design/Under-Construction


text:
# Spades

Lightweight Android ORM.

:warning: **This project is still on alpha stage, it's not ready for production use.**

## Roadmap for version 1.0

- [ ] Add a Mapper classes code generator based on annotations.
- [ ] Add a DAO classes code generator based on annotations.
- [ ] Document with Javadoc the main classes.
- [ ] Create a tutorial.

repository: ppicas/spades

repo_name: ppicas/spades


text:
#CONTRIBUTING.md

# Introduction

Thank you for considering to contribute to MediKnight. Its people like you whose contributions will make it a great tool. We welcome your help, so feel free to submit pull requests. Don't worry if you are a beginner, MediKnight has enough to offer something to every level of Java developers.

## How to make a [clean] pull request
We follow the "fork-and-pull" Git workflow.

Fork the repo on GitHub
Clone the project to your own machine
Commit changes to your own branch
Push your work back up to your fork
Submit a Pull request so that we can review your changes
NOTE: Be sure to merge the latest from "upstream" before making a pull request!

- [Pull Request from a forked repository](https://help.github.com/articles/fork-a-repo/)

	-	Fork the repository by clicking on the *Fork* button on the top right.
	-	Clone the repository on your local machine.
    -	Create a new branch to work on! Branch from `development` branch.
    -	Implement/fix your feature, comment your code.
    -	Follow the code style of the project, including indentation.
    -	Write or adapt tests as needed. There are not many so you could write.
    -	Add or change the documentation as needed.
    -	Squash your commits into a single commit with git's interactive `rebase`. Create a new branch if necessary.
    -	(In case of )Push your branch to your fork on Github, the remote origin.
    -	From your fork open a pull request in the project's `development` branch!

  Once the pull request is approved and merged you can pull the changes from upstream to your local repo and delete your extra branch(es).
And last but not least: [Commits need to be in this format](https://chris.beams.io/posts/git-commit/)

repository: MediKnight/mediknight

repo_name: MediKnight/mediknight


text:
![](https://img.shields.io/badge/Microverse-blueviolet)

# Project : Active records

> This project is implementing model active record for a Micro-Reddit project

![reddit](https://user-images.githubusercontent.com/60273425/111809615-c8cab100-889a-11eb-9e7c-46535c368e70.PNG)

## Built With

- RoR

## Getting Started

How ot use it:

- run
- Import enumerable.rb in your project "require './enumerable' "

Model included:

- user
- comment
- post

### Setup

- Install [git](https://git-scm.com/downloads)
- Open Terminal
- Change directory to folder to download repository
- Use `cd <file-path>`
- Run `git clone https://github.com/EroAuditore/ruby_enums.git`
- Install [Ruby](https://ruby-doc.org/downloads/)
- Run `ruby main.rb`

## Dependencies

- bundle Install
  It will install all the dependecies needed
  - Run `install rubocop`

## Author

👤 **Eduardo Auditore**

- GitHub: [@EroAuditore](https://github.com/EroAuditore)

## 🤝 Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the [issues page](https://github.com/issues).

## Show your support

Give a ⭐ if you like this project!

## Acknowledgments

- [Micoverse team](https://microverse.pathwright.com/library/fast-track-curriculum/69047/path/step/57421588/)

## 📝 License

## Credit to Esty for the images used

This project is [MIT](https://opensource.org/licenses/MIT) licensed.


text:
# Introduction

This folder contains the C implementation of the communication interfaces (DPDK and Sockets) used for TSSDN. Each of these implementation has a sender application and a receiver application. The sender sends time-triggered (periodic) messages with the current time-stamp to the receiver. The receiver computes end-to-end latency for the messages and later puts it on a log file. Our implementation basically tests the suitability of the communication primitives for time-triggered networks, like TSSDN. In our future work, we will extend the usage of these interfaces for live cyber-physical systems.

# Folder Structure

- Socket: Contains C programs (sender & receiver) that use socket interfaces
- DPDK: Contains C programs (sender, receiver & sender_receiver) that use DPDK interfaces.

# Prerequisites

- Implementations tested on Linux machines.
- Intel's DPDK must be installed on the machine. Refer to the [installation details](http://dpdk.org/download).

# Building the applications

- Socket Applications: Execute the makefiles in the folder
- DPDK Applications: This implementation offers both a sender/receiver only as well as a sender_receiver. The sender_receiver is required if the sender and receiver network interfaces are on the same machine as only one DPDK application can be executed on a machine at a given time.

# Running the applications

- Socket Applications:
	```
	sudo nice -adjustment=-20 ./receiver_c <port_num>

	sudo nice -adjustment=-20 ./sender_c <dest_ip_addr> <dest_port_num>
	```
- DPDK Applications:
After make, dpdk has to be run with the application as an input parameter. Running the sender_receiver app would for instance look like this when ran from the DPDK folder:

	```
	sudo nice -adjustment=-20 sender_receiver/build/app/sender_receiver -0xe -n4
	```

where sender_receiver is the dpdk app to be ran and 0xe is the bitmask for which cores are to be used.

Parameters of the DPDK application can be configured by changing the definitions in common/config.h

- Time-triggered transmissions
  - **SEND_PERIOD_SEC:** The number of seconds for the sending interval
  - **SEND_PERIOD_USEC:** The number of microseconds for the sending interval
  - **SEND_PERIOD_NSEC:** The number of nanoseconds for the sending interval calculated from USEC
- Debug Parameters
  - **NUM_SAMPLES:** Number of Packets to be sent
  - **DEBUG:**0 means no debug messages are printed
- Traffic Parameters
  - **VLAN_PKT:** If 1, VLAN field is added to the packet
  - **VLAN_TAG:** The VLAN tag ID, only valid if VLAN_TAG is 1
  - **VLAN_PRIO:** Priority of the VLAN tag, only valid if VLAN_TAG is 1
  - **DSCP:** The DSCP priority of the packet
  - **TX_PORT_NO:** Port (Interface number as interpreted by DPDK) for transmitting packets (output)
  - **RX_PORT_NO:** Port (Interface number as interpreted by DPDK) for receiving packets (input)
  - **TX_CORE_NR:** The CPU core the sender task should run on
  - **RX_CORE_NR:** The CPU core the receiver task should run on

# Results
We measured the end-to-end latencies for 10,000 samples between the a sender and a receiver using DPDK and sockets. The latency variance is shown below:
![Latencies](latency.png)