text:
To be renamed to MonitorTests

# What is a MonitorTests

MonitorTests are tests that run while a set of tests (TestSuite) is running and observe the cluster during this time.
Once the TestSuite is finished, the MonitorTests can produce monitorapi.Intervals (these feed the timelines)
and produce junits (succeeded, failed, or skipped).
The junits are represented as TestCases in the job run and influence the pass/fail of the job run.

# Lifecycle of a MonitorTest

1. The TestSuite indicates a stability level to control the set of MonitorTests to be run during the TestSuite.
2. The TestSuite binary then selects the set of MonitorTests and initializes a controller called the Monitor with
   the list of MonitorTests.
3. Before the TestSuite is started, the Monitor controller is started.
4. When the Monitor is started, for every MonitorTest it calls
   1. StartCollection with an admin kubeconfig and a Recorder.
      A MonitorTest may use the admin kubeconfig to create whatever resources are necessary on the running cluster.
      The same cluster host multiple TestSuites at the same time, be sure that your resources will not conflict and
      that you keep track of them to clean them up later.
      MonitorTests may save the admin kubeconfig for later, may spawn go routines, and may use the Recorder to
      save Intervals throughout the test.
5. The TestCases contained in the TestSuite are now run.  Sometimes in parallel, sometimes not.
6. When the TestSuite is done running the Monitor is stopped.
7. When the Monitor stops, for every MonitorTest, it records its beginning and end times and then calls each of these
   functions for all MonitorTests before calling the next one.  So all MonitorTests complete CollectData before any is
   called with ConstructComputedIntervals.
   1. CollectData with a beginning and end time.
      This function can reach out to the cluster or do whatever else is necessary to return a list of Intervals.
      Examples include doing things like streaming node or pod logs for particular messages or querying prometheus.
      Every Interval at this point is considered a source interval that cannot be recalculated.
   2. ConstructComputedIntervals with all the CollectedData, resources recorded during the TestSuite, and a beginning
      and end time.
      This function can then inspect all the Intervals and create derived Intervals.
      This is commonly done to take things like the instantaneous changes of pod or node state and convert them into
      a set of constructed intervals indicating time spans for particular activities.
   3. EvaluateTestsFromConstructedIntervals with the final set of Intervals and a beginning and end time
      The MonitorTest can process the Intervals and use them to decide whether an individual tests should succeed or fail.
      This is used to do things like know if there was too much disruption, too many pod restarts, etc.
   4. Cleanup
      This is where a MonitorTest must clean up the resources it created on the cluster.
      This is the first potentially multiple cleanup calls, since interrupts will also call cleanup.
      Be sure your invariant tolerates multiple parallel and serial calls to Cleanup.
8. After the Monitor is stopped, it will write data to disk by going to every MonitorTest and calling
   1. WriteContentToStorage with a storage directory.
      At this point MonitorTests may write data that will be preserved by the JobRun.
      Do not write Intervals, RecordedResources, or junit xml files.
      You can do things like write summary or metadat files for the run, like how many requests a particular client made.

# My MonitorTest doesn't run on X.

This is a problem for each MonitorTest, not a larger piece of logic.
Do not try to add different subsets of MonitorTests that are going to run for different TestSuites.
The only distinction we have is for those TestSuites that take etcd offline and time-travel the cluster by restoring from backup.
Every other situation should be handled by logic inside the individual MonitorTest to know whether it can work or not.
If you cannot determine it with an admin kubeconfig, neither can a customer and this indicates a platform failure that needs correction.

repository: openshift/origin

gha_language: Go

repo_name: openshift/origin


text:
# **PowerVS Prerequisites**
----------------------

## IBM Cloud Account
You'll need to have an IBM Cloud Account to be able to use Power Systems Virtual Server (PowerVS).

## Create Power Systems Virtual Server Service Instance

Login to [IBM Cloud Dashboard](https://cloud.ibm.com) and search for "**Power**" in the **Catalog**.
Select "**Power Systems Virtual Server**" and provide all the required inputs
to create the service instance.

![Search for Power](./media/image1.png)

![Select Power Systems Virtual Server](./media/image2.png)

![Fill Details](./media/image3.png)
1. Provide a meaningful name for your instance in the **Service name** field.
2. Select the proper **resource group**. More details on resource groups is available from the following [link](https://cloud.ibm.com/docs/account?topic=account-rgs)

![Provide service name](./media/image4.png)

![Create service](./media/image5.png)

## Create Private Network

A private network is required for your OCP cluster. Choose the previously created "**Service Instance**" and create a private subnet by selecting "**Subnets**" and providing the required inputs. If you see a screen displaying CRN and GUID, then click "View full details" to access the "Subnet" creation page.

You can create multiple OCP clusters in the same service instance using the same private network. If required you can also create multiple private networks.

Provide the required inputs for private subnet creation
![Select subnet](./media/image6.png)

![Provide Input](./media/image7.png)

![Create subnet](./media/image8.png)

## Raise a Service Request to enable IP communication between PowerVS instances on private network
In order for your instances to communicate within the subnet, you'll need to create a service request.

Click on **Support** in the top bar and scroll down to **Contact Support**, then select "**Create a case**"

![Create a case](./media/image9.png)

Select "**Power Systems Virtual Server**" tile

![Create a case Page](./media/image10.png)

Complete the details as shown using the following template:

- [Subject:] Enable communication between PowerVS instances on private network
- [Body:]
  ```
    Please enable IP communication between PowerVS instances for the following private network:
    Name: <your-subnet-name-from-above>
    Type: Private
    CIDR: <your ip subnet-from-above>
    VLAN ID: <your-vlan-id> (listed in your subnet details post-creation)
    Location: <your-location> (listed in your subnet details post-creation)
    Service Instance: <your-service-name>
  ```

![Sample support request ](./media/image11.png)

Click "**Continue**" to accept agreements, and then Click "**Submit case**".

![Submit Case](./media/image12.png)

## RHCOS and RHEL 8.2 Images for OpenShift
RHEL image is used for bastion and RHCOS is used for the OpenShift cluster nodes.

You'll need to create [OVA](https://en.wikipedia.org/wiki/Open_Virtualization_Format) formatted images for RHEL and RHCOS, upload them to IBM Cloud Object storage and then import these images as boot images in your PowerVS service instance.

Further, the image disk should be minimum of 120 GB in size.

### Creating OVA images

- If you have PowerVC then you can follow the instructions provided in the [link](https://www.ibm.com/support/knowledgecenter/en/SSXK2N_1.4.4/com.ibm.powervc.standard.help.doc/powervc_export_image_hmc.html) to export an existing PowerVC image to OVA image.
- You can also use the following [python script](https://github.com/ocp-power-automation/infra/blob/master/scripts/images/convert_qcow2_ova.py) to convert Qcow2 image to OVA
  - RHEL 8.2 Qcow2 image is available from the following [link](https://access.redhat.com/downloads/content/279/ver=/rhel---8/8.2/ppc64le/product-software)
  - RHCOS Qcow2 image is available from the following [link](https://mirror.openshift.com/pub/openshift-v4/ppc64le/dependencies/rhcos/4.5/)

### Uploading to IBM Cloud Object Storage

- **Create IBM Cloud Object Storage service and bucket**
Please refer to the following [link](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-getting-started-cloud-object-storage) for instructions to create IBM Cloud Object Storage service and required storage bucket to upload the OVA images.

- **Create secret and access keys with Hash-based Message Authentication Code (HMAC)**
Please refer to the following [link](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-uhc-hmac-credentials-main) for instructions to create the keys required for importing the images into your PowerVS service instance.

- **Upload the OVA image to Cloud Object storage bucket**
Please refer to the following [link](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-upload) for uploading the OVA image to the respective bucket. Alternatively you can also use the following [python script](https://github.com/ocp-power-automation/infra/blob/master/scripts/images/upload_image.py).

### Importing the images in PowerVS
Choose the previously created PowerVS "Service Instance", click "View full details" and select "Boot images".
Click the "Importing image" option and fill the requisite details like image name, storage type and cloud object storage details.

Example screenshot showing import of RHEL image that is used for bastion
![Image Import-RHEL](./media/image-import1.png)

Example screenshot showing import of RHCOS image used for OCP
![Image Import-RHCOS](./media/image-import2.png)

Your PowerVS service instance is now ready for OpenShift clusters.

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# Dexter

Dexter is a logging middleware inspired by [expressjs/morgan](https://github.com/expressjs/morgan). It is configurable and can be used throughout the request-resource-response lifecycle.

```typescript
import { Drash } from<EMAIL_ADDRESS>
// Import the Dexter middleware function
import { Dexter } from<EMAIL_ADDRESS>
// Instantiate dexter
const dexter = Dexter();

// The above will instantiate Dexter with default values:
// {
//     enabled: true,
//     level: "info",
//     tag_string: "{datetime} | {level} |",
//     tag_string_fns: {
//       datetime() {
//         return new Date().toISOString().replace("T", " ").split(".")[0];
//     },
// };

// Create your server and plug in dexter to the middleware config
const server = new Drash.Http.Server({
  resources: [
    HomeResource,
  ],
  middleware: {
    before_request: [
      dexter
    ],
    after_request: [
      dexter
    ]
  }
});

server.run({
  hostname: "localhost",
  port: 1447,
});

console.log(`Server running at ${server.hostname}:${server.port}`);
```

## Configuration

If you decide to configure Dexter, make sure you specify the `enabled` flag in the configs as it is required when customizing the configuration.

### `enabled`

Enable or disable the logger from logging based on the value of this config.

```typescript
const dexter = Dexter({
  enabled: true, // or false
});
```

### `level`

Define what log statements should be written based on their log level definition (e.g., debug, info, warn).

```typescript
const dexter = Dexter({
  enabled: true,
  level: "debug", // or all, trace, debug, info, warn, error, fatal
});
```

* `all`: logs all messages below
* `trace`: logs `.trace()` messages and the below
* `debug`: logs `.debug()` messages and the below
* `info`: logs `.info()` messages and the below
* `warn`: logs `.warn()` messages and the below
* `error`: logs `.error()` messages and the below
* `fatal`: logs `.fatal()` messages only

### `tag_string`

Define the display of the log messages' tag string. The tag string is a concatenation of tokens preceding the log message. Available, predefined tags:

* `{level}`
* `{request_method}`
* `{request_url}`

```typescript
const dexter = Dexter({
  enabled: true,
  tag_string: "{level} | {request_method} {request_url} |" // Will output something similar to "INFO | GET /home | The log message."
});
```

### `tag_string_fns`

If you want more customizations with the `tag_string` config, then you can use `tag_string_fns` to define what your tags should resolve to.

```typescript
const dexter = Dexter({
  enabled: true,
  tag_string: "{datetime} | {my_tag} |", // Will output something similar to "2020-07-12 10:32:14 | TIGERRR | The log message."
  tag_string_fns: {
    datetime() {
      return new Date().toISOString().replace("T", " ").split(".")[0];
    },
    my_tag: "TIGERRR"
  }
});
```

### `response_time`

If you want to see how fast your responses are taking, then use this config. This config will output something similar to `Response sent. [2 ms]`.

```typescript
const dexter = Dexter({
  enabled: true,
  response_time: true, // or false
});
```

## Tutorials

### Reusing Dexter in resource classes (or other parts of your codebase)

You can reuse Dexter in your codebase by accessing its `logger`. For example, if you want to use Dexter in one of your resources, then do the following:

1. Create your `app.ts` file.

    ```typescript
    // File: app.ts
    import { Drash } from<EMAIL_ADDRESS>    import { HomeResource } from "./home_resource.ts";
    import { Dexter } from<EMAIL_ADDRESS>
    const dexter = Dexter({
      enabled: true,
      level: "debug",
      tag_string: "{request_method} {request_url} |",
    });

    // Export dexter after calling it with your configurations
    export { dexter };

    const server = new Drash.Http.Server({
      resources: [
        HomeResource,
      ],
      middleware: {
        before_request: [
          dexter
        ],
        after_request: [
          dexter
        ]
      }
    });

    server.run({
      hostname: "localhost",
      port: 1447,
    });

    console.log(`Server running at ${server.hostname}:${server.port}`);
    ```

2. Create your `home_resource` file.

    ```typescript
    import { Drash } from<EMAIL_ADDRESS>    import { dexter } from "./app.ts";

    export class HomeResource extends Drash.Http.Resource {

      static paths = ["/"];

      public GET() {

        // Access Dexter's logger from it's prototype and log some messages
        dexter.logger.debug("This is a log message.");
        dexter.logger.error("This is a log message.");
        dexter.logger.fatal("This is a log message.");
        dexter.logger.info("This is a log message.");
        dexter.logger.trace("This is a log message.");
        dexter.logger.warn("This is a log message.");

        this.response.body = "GET request received!";

        return this.response;
      }
    }
    ```

license: MIT

repository: prisis/deno-drash-middleware

gha_license_id: MIT

repo_name: prisis/deno-drash-middleware


text:
---
Module Name: CosmosDB
Module Guid: 7d7aeb42-8ed9-4555-b5fd-020795a5aa01
Download Help Link:
Help Version: <IP_ADDRESS>
Locale: en-US
---

# CosmosDB Module

## Description

This PowerShell module provides cmdlets for working with Azure Cosmos DB.

## CosmosDB Cmdlets

### [ConvertTo-CosmosDbTokenDateString](ConvertTo-CosmosDbTokenDateString.md)

Convert a DateTime object into the format required for use
in a Cosmos DB Authorization Token and request header.

### [Get-CosmosDbAccount](Get-CosmosDbAccount.md)

Get the properties of a Cosmos DB account in Azure.

### [Get-CosmosDbAccountConnectionString](Get-CosmosDbAccountConnectionString.md)

Get the connection strings for a Cosmos DB account in Azure.

### [Get-CosmosDbAccountMasterKey](Get-CosmosDbAccountMasterKey.md)

Get a master key for a Cosmos DB account in Azure.

### [Get-CosmosDbAttachment](Get-CosmosDbAttachment.md)

Return the attachments for a Cosmos DB document.

### [Get-CosmosDbAttachmentResourcePath](Get-CosmosDbAttachmentResourcePath.md)

Return the resource path for an attachment object.

### [Get-CosmosDbCollection](Get-CosmosDbCollection.md)

Return the collections in a Cosmos DB database.

### [Get-CosmosDbCollectionResourcePath](Get-CosmosDbCollectionResourcePath.md)

Return the resource path for a collection object.

### [Get-CosmosDbContinuationToken](Get-CosmosDbContinuationToken.md)

Return the continuation token from a response header object.

### [Get-CosmosDbDatabase](Get-CosmosDbDatabase.md)

Return the databases in a Cosmos DB account.

### [Get-CosmosDbDatabaseResourcePath](Get-CosmosDbDatabaseResourcePath.md)

Return the resource path for a database object.

### [Get-CosmosDbDocument](Get-CosmosDbDocument.md)

Return documents from a Cosmos DB database collection.

### [Get-CosmosDbDocumentJson](Get-CosmosDbDocumentJson.md)

Return documents from a Cosmos DB database collection as a JSON string.

### [Get-CosmosDbDocumentResourcePath](Get-CosmosDbDocumentResourcePath.md)

Return the resource path for a document object.

### [Get-CosmosDbOffer](Get-CosmosDbOffer.md)

Return the offers in a Cosmos DB account.

### [Get-CosmosDbOfferResourcePath](Get-CosmosDbOfferResourcePath.md)

Return the resource path for a offer object.

### [Get-CosmosDbPermission](Get-CosmosDbPermission.md)

Return the permissions for a Cosmos DB database user.

### [Get-CosmosDbPermissionResourcePath](Get-CosmosDbPermissionResourcePath.md)

Return the resource path for a permission object.

### [Get-CosmosDbStoredProcedure](Get-CosmosDbStoredProcedure.md)

Return the stored procedures for a Cosmos DB database collection.

### [Get-CosmosDbResponseHeaderAttribute](Get-CosmosDbResponseHeaderAttribute.md)

Return an attribute from a response header object.

### [Get-CosmosDbStoredProcedureResourcePath](Get-CosmosDbStoredProcedureResourcePath.md)

Execute a new stored procedure for a collection in a Cosmos DB
database.

### [Get-CosmosDbTrigger](Get-CosmosDbTrigger.md)

Return the triggers for a Cosmos DB database collection.

### [Get-CosmosDbTriggerResourcePath](Get-CosmosDbTriggerResourcePath.md)

Return the resource path for a trigger object.

### [Get-CosmosDbUri](Get-CosmosDbUri.md)

Return the URI of the Cosmos DB that Rest APIs requests will
be sent to.

### [Get-CosmosDbUser](Get-CosmosDbUser.md)

Return the users in a Cosmos DB database.

### [Get-CosmosDbUserDefinedFunction](Get-CosmosDbUserDefinedFunction.md)

Return the user defined functions for a Cosmos DB database collection.

### [Get-CosmosDbUserDefinedFunctionResourcePath](Get-CosmosDbUserDefinedFunctionResourcePath.md)

Return the resource path for a user defined function object.

### [Get-CosmosDbUserResourcePath](Get-CosmosDbUserResourcePath.md)

Return the resource path for a user object.

### [Invoke-CosmosDbRequest](Invoke-CosmosDbRequest.md)

Execute a new request to a Cosmos DB REST endpoint.

### [Invoke-CosmosDbStoredProcedure](Invoke-CosmosDbStoredProcedure.md)

Execute a new stored procedure for a collection in a Cosmos DB database.

### [New-CosmosDbAccount](New-CosmosDbAccount.md)

Create a new Cosmos DB account in Azure.

### [New-CosmosDbAccountMasterKey](New-CosmosDbAccountMasterKey.md)

This will regenerate a specific master key for an existing Cosmos DB account
in Azure.

### [New-CosmosDbAttachment](New-CosmosDbAttachment.md)

Create a new attachment for a document in a Cosmos DB database.

### [New-CosmosDbAuthorizationToken](New-CosmosDbAuthorizationToken.md)

Create a new Authorization Token to be used with in a
Rest API request to Cosmos DB.

### [New-CosmosDbCollection](New-CosmosDbCollection.md)

Create a new collection in a Cosmos DB database.

### [New-CosmosDbCollectionExcludedPath](New-CosmosDbCollectionExcludedPath.md)

Creates an indexing policy excluded path object that can be
added to an Indexing Policy.

### [New-CosmosDbCollectionIncludedPath](New-CosmosDbCollectionIncludedPath.md)

Creates an indexing policy included path object that can be
added to an Indexing Policy.

### [New-CosmosDbCollectionIncludedPathIndex](New-CosmosDbCollectionIncludedPathIndex.md)

Creates an indexing policy included path index object that
can be added to an Included Path of an Indexing Policy.

### [New-CosmosDbCollectionUniqueKey](New-CosmosDbCollectionUniqueKey.md)

Creates a unique key object that can be passed to the
New-CosmosDbCollectionUniqueKeyPolicy function when generating a unique key
policy.

### [New-CosmosDbCollectionUniqueKeyPolicy](New-CosmosDbCollectionUniqueKeyPolicy.md)

Creates a unique key policy object that can be passed to the
New-CosmosDbCollection function.

### [New-CosmosDbCollectionIndexingPolicy](New-CosmosDbCollectionIndexingPolicy.md)

Creates an indexing policy object that can be passed to the
New-CosmosDbCollection function.

### [New-CosmosDbContext](New-CosmosDbContext.md)

Create a context object containing the information required
to connect to a Cosmos DB.

### [New-CosmosDbDatabase](New-CosmosDbDatabase.md)

Create a new database in a Cosmos DB account.

### [New-CosmosDbDocument](New-CosmosDbDocument.md)

Create a new document for a collection in a Cosmos DB database.

### [New-CosmosDbInvalidArgumentException](New-CosmosDbInvalidArgumentException.md)

Creates and throws an invalid argument exception.

### [New-CosmosDbInvalidOperationException](New-CosmosDbInvalidOperationException.md)

Creates and throws an invalid operation exception.

### [New-CosmosDbPermission](New-CosmosDbPermission.md)

Create a new permission for a user in a Cosmos DB database.

### [New-CosmosDbStoredProcedure](New-CosmosDbStoredProcedure.md)

Create a new stored procedure for a collection in a Cosmos DB database.

### [New-CosmosDbTrigger](New-CosmosDbTrigger.md)

Create a new trigger for a collection in a Cosmos DB database.

### [New-CosmosDbUser](New-CosmosDbUser.md)

Create a new user in a Cosmos DB database.

### [New-CosmosDbUserDefinedFunction](New-CosmosDbUserDefinedFunction.md)

Create a new user defined function for a collection in a Cosmos DB database.

### [Remove-CosmosDbAttachment](Remove-CosmosDbAttachment.md)

Delete an attachment from a Cosmos DB document.

### [Remove-CosmosDbCollection](Remove-CosmosDbCollection.md)

Delete a collection from a Cosmos DB database.

### [Remove-CosmosDbDatabase](Remove-CosmosDbDatabase.md)

Delete a database from a Cosmos DB account.

### [Remove-CosmosDbDocument](Remove-CosmosDbDocument.md)

Delete a document from a Cosmos DB collection.

### [Remove-CosmosDbPermission](Remove-CosmosDbPermission.md)

Delete a permission from a Cosmos DB user.

### [Remove-CosmosDbStoredProcedure](Remove-CosmosDbStoredProcedure.md)

Delete a stored procedure from a Cosmos DB collection.

### [Remove-CosmosDbTrigger](Remove-CosmosDbTrigger.md)

Delete a trigger from a Cosmos DB collection.

### [Remove-CosmosDbUser](Remove-CosmosDbUser.md)

Delete a user from a Cosmos DB database.

### [Remove-CosmosDbUserDefinedFunction](Remove-CosmosDbUserDefinedFunction.md)

Delete a user defined function from a Cosmos DB collection.

### [Set-CosmosDbAccount](Set-CosmosDbAccount.md)

Update the properties of an existing Azure Cosmos DB account.

### [Set-CosmosDbAttachment](Set-CosmosDbAttachment.md)

Update am attachment for a Cosmos DB document.

### [Set-CosmosDbAttachmentType](Set-CosmosDbAttachmentType.md)

Set the custom Cosmos DB Attachment types to the attachment
returned by an API call.

### [Set-CosmosDbCollectionType](Set-CosmosDbCollectionType.md)

Set the custom Cosmos DB Collection types to the collection
returned by an API call.

### [Set-CosmosDbDatabaseType](Set-CosmosDbDatabaseType.md)

Set the custom Cosmos DB Database types to the database
returned by an API call.

### [Set-CosmosDbDocument](Set-CosmosDbDocument.md)

Update a document from a Cosmos DB collection.

### [Set-CosmosDbDocumentType](Set-CosmosDbDocumentType.md)

Set the custom Cosmos DB document types to the document returned
by an API call.

### [Set-CosmosDbOffer](Set-CosmosDbOffer.md)

Update an existing offer in a Cosmos DB database.

### [Set-CosmosDbOfferType](Set-CosmosDbOfferType.md)

Set the custom Cosmos DB Offer types to the offer
returned by an API call.

### [Set-CosmosDbPermissionType](Set-CosmosDbPermissionType.md)

Set the custom Cosmos DB User types to the permission
returned by an API call.

### [Set-CosmosDbStoredProcedure](Set-CosmosDbStoredProcedure.md)

Update a stored procedure from a Cosmos DB collection.

### [Set-CosmosDbStoredProcedureType](Set-CosmosDbStoredProcedureType.md)

Set the custom Cosmos DB stored procedure types to the
stored procedure returned by an API call.

### [Set-CosmosDbTrigger](Set-CosmosDbTrigger.md)

Update a trigger from a Cosmos DB collection.

### [Set-CosmosDbTriggerType](Set-CosmosDbTriggerType.md)

Set the custom Cosmos DB trigger types to the trigger returned
by an API call.

### [Set-CosmosDbUser](Set-CosmosDbUser.md)

Set the user Id of an existing user in a Cosmos DB database.

### [Set-CosmosDbUserDefinedFunction](Set-CosmosDbUserDefinedFunction.md)

Update a user defined function from a Cosmos DB collection.

### [Set-CosmosDbUserDefinedFunctionType](Set-CosmosDbUserDefinedFunctionType.md)

Set the custom Cosmos DB User Defined Function types to the user
defined function returned by an API call.

### [Set-CosmosDbUserType](Set-CosmosDbUserType.md)

Set the custom Cosmos DB User types to the user
returned by an API call.

repository: PlagueHO/CosmosDB

branch_name: refs/heads/main

gha_language: PowerShell

repo_name: PlagueHO/CosmosDB


text:
---
title: "Hacking with ChatGPT: Ideal Tasks and Use-Cases"
layout: post
categories:
  - hacking
tags:
  - hacking
  - cybersecurity
---

![](https://i.imgur.com/ciblWMD.png){: width="400" }
I've been using ChatGPT for lots of hacking or engineering tasks. It's extremely useful and much faster than executing on similar tasks without it. The key is knowing when to use it. Here's my thoughts on when to have it help and some awesome use-cases.

## The Ideal Tasks for ChatGPT

There are many ways in which ChatGPT is limited. It can help with almost anything, but I don't think it's an ideal tool for everything.

Very small tasks for which there are existing tools are not the best use cases. If you need to encode some text, replace instances of one word with another, or get the answer to a well-known question, there are better tools for those things. If you're solving a really large problem such as restructuring an organization, it might make sense to ask ChatGPT for ideas, but it won't be able to solve such a large problem for you either.

The sweet spot is when you need a task completed that is small or medium in size, would take more than a couple minues to do, but for which there isn't an existing good tool. And if it's not something ChatGPT can do directly, asking it to write a script to complete the task is a great way to still get a working solution.

### Active Input Processing
The other unique skill of ChatGPT that people underestimate is the fact that it's actively processing the input. That's a super-power compared to googling. If you have an error in a bit of code, you might be able to very quickly google a solution to your issue. But you still have to _find_ that issue in the bit of code. ChatGPT is uniquely suited to be a massive advantage in those situations because you can paste your code into it as a part of the question.

Rather than "I'm getting error xyz, how do I solve this problem?", you can utilitze "Below is my code. I'm getting error xyz. Where is the problem and how do I solve it?". In short, it's more than a smart oracle. It's also a speedy assistant.

Let's jump into use-cases.

## ChatGPT Engineering Use-Cases

Now, let's talk about actual examples. These are the cool ways that I have used ChatGPT in the last few weeks:

**Write data-processing scripts.**

As a hacker or security engineer, there is often data in a format that isn't ideal. Giving ChatGPT a plaintext description of a lengthy process and getting a working script as output just feels like magic.

Example prompt:
```
Write a python script that reads the file "input.zip", unzips it, then reads the csv files inside line by line. It should take the second columns from the csv files, which are urls, and parse out the domain and save those in a new file called domains.txt. It should take the paths from the urls and save those in a file called paths.txt.
```

**Make minified js code easier to read.**

Often there is interesting minified javascript code in web applications that is useful for finding bugs. Parsing it and following what the functions do can be difficult. The files are often too large to paste the entire thing, but you can paste large parts of it into ChatGPT and ask it to comment the code while also making it more readable.

Example prompt:
```
Clean up the following js code by making it more readable and adding comments:

<js code here>
```

**Translate a json POST request into an x-www-form-urlencoded POST request.**

As you probably know, json POST requests aren't vulnerable to CSRF. However, many frameworks and libraries allow urlencoded form POST bodies by default. So if there's not any CSRF protection on a json api request, trying url-encoded forms is a great way to find some bugs. The problem is that it's a lot of work to manually modify the request, especially if there are nested objects. This type of request will have ChatGPT doing it for you.

Example prompt:

```bash
Transform this entire burp request from json into a x-www-form-urlencoded request:

POST /api/files HTTP/2
Host: test.com
Content-Length: 15
Content-Type: application/json

{"file":"rez0"}
```

**Coding error debugging**

This is what I was mentioning in the Ideal Tasks section. If you've got code that isn't working, is doing something weird, or is throwing an error. You can paste the relevant code into ChatGPT and have it help your find the problem (or just fix it for you!).

Example prompt:

```
Below is my code. I'm getting error "EXAMPLE ERROR". Explain the problem, fix my code, and put the output in a code block
```

### Now do it!

Hopefully I've given you some good ideas on how to use ChatGPT for security engineering and hacking. It's been an asset for me. Also, I'm sure other AI tools will pop up. This isn't unique to ChatGPT, it would probably all work nearly as well on GPT3. And it will likely all be way better on GPT4.

Thanks for taking the time to read the post! If you're using ChatGPT in a neat way, let me know!

\- rez0

For more of my thoughts, bug bounty tips, and AI-generated hacker art, [follow me on twitter](https://twitter.com/rez0__).

![](https://i.imgur.com/RaKHAae.png){: width="400" }

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@rez0__" />
<meta name="twitter:creator" content="@rez0__" />
<meta property="og:url" content="https://rez0.blog/hacking/2023/02/21/hacking-with-chatgpt.html" />
<meta property="og:title" content="Hacking With ChatGPT" />
<meta property="og:description" content="Ideal Tasks and Use-Cases" />
<meta property="og:image" content="https://i.imgur.com/ciblWMD.png" />

repository: jthack/hydeout

gha_language: SCSS

gha_license_id: NOASSERTION

repo_name: jthack/hydeout


text:
---
date: 2018-01-18
title: "Hugo 0.33: The New Kinder Surprise!"
description: "Hugo 0.33 comes with resource (images etc.) metadata, `type` and `layout` for all page types, `url` in front matter for list pages …"
categories: ["Releases"]
---

	Hugo `0.33` is the first main Hugo release of the new year, and it is safe to say that [@bep](https://github.com/bep)  has turned off his lazy Christmas mode :smiley:

This is a full makeover of the layout selection logic with full custom `layout` and `type` support (many have asked for this). Also, Hugo now respects the `url` value in front matter for all page types, including sections. Also, you can now configure `uglyURLs` per section.

But this release is also a follow-up to the `0.32` release which was all about bundles with resources and powerful image processing. With this release it is now simple to add metadata to your images and other bundle resources.

[@bep](https://github.com/bep)  has added a section with examples of both `resources` configuration in both `YAML` and `TOML` front matter in his [test site](http://hugotest.bep.is/resourcemeta/). The example below shows a sample of how it would look like in `YAML`:

```yaml
date: 2017-01-17
title: My Bundle With YAML Resource Metadata
resources:
- src: "image-4.png"
  title: "The Fourth Image"
- src: "*.png"
  name: "my-cool-image-:counter"
  title: "The Image #:counter"
  params:
    byline: "bep"
```

This release represents **41 contributions by 3 contributors** to the main Hugo code base.

Hugo now has:

* 22553+ [stars](https://github.com/gohugoio/hugo/stargazers)
* 448+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors)
* 197+ [themes](http://themes.gohugo.io/)

## Notes
* We have re-implemented and unified the template layout lookup logic. This has made it more powerful and much simpler to understand. We don't expect any sites to break because of this. We have tested lots of Hugo sites, including the 200 [themes](http://themes.gohugo.io/).
*  The `indexes` type is removed from template lookup. It's not in the documentation, and is a legacy term inherited from very old Hugo versions.
* If you have sub-dirs in your shiny new bundles (e.g. `my-bundle/images`) and use the `*Prefix*` methods to find them, we have made an unintended change that affects you. See [this issue](https://github.com/gohugoio/hugo/issues/4295).

## Enhancements

### Templates

* Respect `Type` and `Layout` for list template selection [51dd462c](https://github.com/gohugoio/hugo/commit/51dd462c3958f7cf032b06503f1f200a6aceebb9) [@bep](https://github.com/bep) [#3005](https://github.com/gohugoio/hugo/issues/3005)[#3245](https://github.com/gohugoio/hugo/issues/3245)

### Core

* Allow `url` in front matter for list type pages [8a409894](https://github.com/gohugoio/hugo/commit/8a409894bdb0972e152a2eccc47a2738568e1cfc) [@bep](https://github.com/bep) [#4263](https://github.com/gohugoio/hugo/issues/4263)
* Improve `.Site.GetPage` for regular translated pages. Before this change it was not possible to say "get me the current language edition of the given content page if possible." Now you can do that by doing a lookup without any extensions:  `.Site.GetPage "page" "post/mypost"` [9409bc0f](https://github.com/gohugoio/hugo/commit/9409bc0f799a8057836a14ccdf2833a55902175e) [@bep](https://github.com/bep) [#4285](https://github.com/gohugoio/hugo/issues/4285)
* Add front matter metadata to `Resource` [20c9b6ec](https://github.com/gohugoio/hugo/commit/20c9b6ec81171d1c586ea31d5d08b40b0edaffc6) [@bep](https://github.com/bep) [#4244](https://github.com/gohugoio/hugo/issues/4244)
* Implement `Resources.ByPrefix` [46db900d](https://github.com/gohugoio/hugo/commit/46db900dab9c0e6fcd9d227f10a32fb24f5c8bd9) [@bep](https://github.com/bep) [#4266](https://github.com/gohugoio/hugo/issues/4266)
* Make `GetByPrefix` work for Page resources [60c9f3b1](https://github.com/gohugoio/hugo/commit/60c9f3b1c34b69771e25a66906f150f460d73223) [@bep](https://github.com/bep) [#4264](https://github.com/gohugoio/hugo/issues/4264)
* Make `Resources.GetByPrefix` case insensitive [db85e834](https://github.com/gohugoio/hugo/commit/db85e83403913cff4b8737b138932b28e5bf6160) [@bep](https://github.com/bep) [#4258](https://github.com/gohugoio/hugo/issues/4258)
* Update `Chroma` and other third-party deps [64f0e9d1](https://github.com/gohugoio/hugo/commit/64f0e9d1c1d4ff2249fd9cf9749e70485002b36d) [@bep](https://github.com/bep) [#4267](https://github.com/gohugoio/hugo/issues/4267)
* Remove superflous `BuildDate` logic [13d53b31](https://github.com/gohugoio/hugo/commit/13d53b31f19240879122d6b7e4aaeb60b5130a3c) [@bep](https://github.com/bep) [#4272](https://github.com/gohugoio/hugo/issues/4272)
* Run benchmarks 3 times [b6ea6d07](https://github.com/gohugoio/hugo/commit/b6ea6d07d0b072d850fb066c78976acd6c2f5e81) [@bep](https://github.com/bep)
* Support `uglyURLs` per section [57e10f17](https://github.com/gohugoio/hugo/commit/57e10f174e51cc5e1cf5f37eed30a0f3b153dd64) [@bep](https://github.com/bep) [#4256](https://github.com/gohugoio/hugo/issues/4256)
* Update CONTRIBUTING.md [1046e936](https://github.com/gohugoio/hugo/commit/1046e9363f2e382fd0b4aac838735ae4cbbebe5a) [@vassudanagunta](https://github.com/vassudanagunta)
* Support offline builds [d5803da1](https://github.com/gohugoio/hugo/commit/d5803da1befba5446d1b2c1ad16f6467dc7b3991) [@vassudanagunta](https://github.com/vassudanagunta)

## Fixes

* Fix handling of mixed-case taxonomy folders with content file [2d3189b2](https://github.com/gohugoio/hugo/commit/2d3189b22760e0a8995dae082a6bc5480f770bfe) [@bep](https://github.com/bep) [#4238](https://github.com/gohugoio/hugo/issues/4238)
* Fix handling of very long image file names [ecaf1451](https://github.com/gohugoio/hugo/commit/ecaf14514e06321823bdd10235cf23e7d654ba77) [@bep](https://github.com/bep) [#4261](https://github.com/gohugoio/hugo/issues/4261)
* Update `Afero` to avoid panic on "file name is too long" [f8a119b6](https://github.com/gohugoio/hugo/commit/f8a119b606d55aa4f31f16e5a3cadc929c99e4f8) [@bep](https://github.com/bep) [#4240](https://github.com/gohugoio/hugo/issues/4240)
* And now really fix the server watch logic [d4f8f88e](https://github.com/gohugoio/hugo/commit/d4f8f88e67f958b8010f90cb9b9854114e52dac2) [@bep](https://github.com/bep) [#4275](https://github.com/gohugoio/hugo/issues/4275)
* Fix server without watch [4e524ffc](https://github.com/gohugoio/hugo/commit/4e524ffcfff48c017717e261c6067416aa56410f) [@bep](https://github.com/bep) [#4275](https://github.com/gohugoio/hugo/issues/4275)

repository: bep/hugo

repo_name: bep/hugo


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

[image1]: https://user-images.githubusercontent.com/10624937/43851024-320ba930-9aff-11e8-8493-ee547c6af349.gif "Trained Agent"
[image2]: https://user-images.githubusercontent.com/10624937/43851646-d899bf20-9b00-11e8-858c-29b5c2c94ccc.png "Crawler"

# Project 2: Continuous Control

[![Project passed](https://img.shields.io/badge/project-passed-success.svg)](https://img.shields.io/badge/project-passed-success.svg)

### Introduction

For this project, you will work with the [Reacher](https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Learning-Environment-Examples.md#reacher) environment.

![Trained Agent][image1]

In this environment, a double-jointed arm can move to target locations. A reward of +0.1 is provided for each step that the agent's hand is in the goal location. Thus, the goal of your agent is to maintain its position at the target location for as many time steps as possible.

The observation space consists of 33 variables corresponding to position, rotation, velocity, and angular velocities of the arm. Each action is a vector with four numbers, corresponding to torque applicable to two joints. Every entry in the action vector should be a number between -1 and 1.

### Distributed Training

For this project, we will provide you with two separate versions of the Unity environment:
- The first version contains a single agent.
- The second version contains 20 identical agents, each with its own copy of the environment.

The second version is useful for algorithms like [PPO](https://arxiv.org/pdf/1707.06347.pdf), [A3C](https://arxiv.org/pdf/1602.01783.pdf), and [D4PG](https://openreview.net/pdf?id=SyZipzbCb) that use multiple (non-interacting, parallel) copies of the same agent to distribute the task of gathering experience.

### Solving the Environment

This poroject can be done with separated version of the Unity environment.

+ **Single Agent Version:** It contains a single agent.

+ **Multi-Agents Version:** It contains 20 identical agents.

In this project, I choose version 1 with a **single agent**. The environment is considered solved, when  the agent must get an **average score** of *+30* over 100 consecutive episodes.

### Environment Setting

The environment can be downloaded from one of the links below for all operating systems
  - Linux: [click here](https://s3-us-west-1.amazonaws.com/udacity-drlnd/P2/Reacher/one_agent/Reacher_Linux.zip)
  - Mac OSX: [click here](https://s3-us-west-1.amazonaws.com/udacity-drlnd/P2/Reacher/one_agent/Reacher.app.zip)
  - Windows (32-bit): [click here](https://s3-us-west-1.amazonaws.com/udacity-drlnd/P2/Reacher/one_agent/Reacher_Windows_x86.zip)
  - Windows (64-bit): [click here](https://s3-us-west-1.amazonaws.com/udacity-drlnd/P2/Reacher/one_agent/Reacher_Windows_x86_64.zip)

(_For Windows users_) Check out [this link](https://support.microsoft.com/en-us/help/827218/how-to-determine-whether-a-computer-is-running-a-32-bit-version-or-64) if you need help with determining if your computer is running a 32-bit version or 64-bit version of the Windows operating system.

(_For AWS_) If you'd like to train the agent on AWS (and have not [enabled a virtual screen](https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Training-on-Amazon-Web-Service.md)), then please use [this link](https://s3-us-west-1.amazonaws.com/udacity-drlnd/P2/Reacher/one_agent/Reacher_Linux_NoVis.zip) to obtain the "headless" version of the environment.  You will **not** be able to watch the agent without enabling a virtual screen, but you will be able to train the agent.  (_To watch the agent, you should follow the instructions to [enable a virtual screen](https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Training-on-Amazon-Web-Service.md), and then download the environment for the **Linux** operating system above._)

### Project Structure

+ `Continuous_Control.ipynb` -  file containing the main code to initialize dependencies, environment and Agent
+ `ddpg_agent.py` - file that contains the characteristics of the agent and how it behaves through this task
+ `model.py` - file that contains the deep neural networks (DNN) architectures used by the agent
+ `checkpoint_actor.pth` and `checkpoint_critic.pth` - files that with saved DNN’s weights, that solved the environment.

### Project Approach
The notebook Continuous_Control.ipynb contains the code to set up the environment and the outer episode iteration to solve the reinforcement problem. Our solution uses a **Deep Deterministic Policy Gradient (DDPG)** approach (only standard feedforward layers) with experience replay, see this [paper](https://arxiv.org/pdf/1509.02971.pdf).


text:
# qcew-employment-county-to-congress-districts
This code aggregates annual US **county level employment** data from the Quarterly Census of Employment and Wages (QCEW) by industry (NAICS) to the **Congressional district level** for the 108th to 115th Congress (2003 - 2018) and adjusts for redistricting where Congress district boundaries have been changed outside the usual decennial rhythm.

## Code:
The `QCEW_employment_congress_district_level.R` code loads the QCEW county level employment data depending on the **NAICS industries** and **years** specified by the user. It then aggregates this data from the county to the Congress district level while accounting for redistricting. (This code relies on the data source 1-3.)

The `QCEW_employment_state_level.R` code loads the QCEW state level employment data depending on the **NAICS industries** and **years** specified by the user. (This code only relies on the data source 1.)

## Data:

Three data sources are used:

1. `QCEW county level employment data` (CSVs By Industry - Annual Averages). The data can be downloaded here: https://www.bls.gov/cew/downloadable-data-files.htm

    Source: U.S. Department of Labor. Bureau of Labor Statistics (2021) _Quarterly Census of Employment and Wages_.

2. `Census 2000 county to Congress district aggregation factors` provided by the Geographic Correspondence Engine (Geocorr 2000). Data required for this script provided above. The data can otherwise be regenerated here: https://mcdc.missouri.edu/applications/geocorr2000.html

    Source: Missouri Census Data Center (2010) _Geocorr 2000: Geographic Correspondence Engine_ (Version 1.3.3 with Census 2000 Geography).

3. `Redistricting aggregation factors` provided by Autor, Dorn, Hanson and Majlesi. The Political Geography Crosswalk files G1, G2, G3 & G4 can be downloaded here: https://www.ddorn.net/data.htm

    Source: David Autor, David Dorn, Gordon Hanson and Kaveh Majlesi (2020) _Importing Political Polarization? The Electoral Consequences of Rising Trade Exposure._ American Economic Review, 110(10): 3139-3189.

Note: All files should be saved in one parent folder called `Data`, containing a folder called `QCEW` for the QCEW county employment data (1.), a folder called `geocorr2000` for the county to Congress district aggregation data (2.) and a folder called `PoliticalGeography` for redistricting crosswalk files (3.).


text:
# Java Concurrency

## What is concurrency?
* the ability to run several programs or parts of a program in parallel
* improves throughput and interactivity of the program
* leverage multi-cores key for managing high-volume application

## Process vs Threads

### Process

* runs independently
* isolated from other processes
* cannot access shared data in other processes
* resources (memory, CPU time) are allocated via the OS

### Thread

* lightweight process
* have their own call stack (memory cache)
* can access shared data of other threads in the same process
* copies shared data to local memory cache

### Java app

* runs in one process by default
* work with threads to achieve parallel processing or asynchronous behavior
* divide tasks into subtasks and execute in parallel

## Problems

### Two basic problems

visibility

thread A reads shared data which is later changed by thread B and thread A is unaware of change

access

several threads access and change the same shared data simultaneously

### Program failures

liveness failure

program doesn’t react anymore due to deadlocks

safety failure

program creates incorrect data

## Java

* supports threads
    - Thread class — represents a thread
    - java.util.concurrent package — utility classes useful for concurrency
- locks and synchronization
    - lock — protects code which can be executed by several threads simultaneously
    - lock is achieved using “synchronized” keyword
- synchronized keyword
    - only a single thread can execute a block of code at the same time
    - each thread entering a synchronized block sees the effects of all previous modifications that were guarded by the same lock
- synchronization necessary for mutually exclusive access to blocks and for reliable communication between threads
- use synchronized keyword
    - for definition of method; ensures only one thread can enter this method at the same time
    - to protect blocks of code within a method
      - block is guarded by a key, which is either a String or an object
      - key is called lock
- volatile keyword
    - guaranteed that any thread that reads volatile variable will see most recently written value

```java
public synchronized void critical() {
    // some thread critical stuff
    // here
}

public class CrawledSites {
    private List<String> crawledSites = new ArrayList<String>();
    private List<String> linkedSites = new ArrayList<String>();

    public void add(String site) {
        synchronized (this) {
            if (!crawledSites.contains(site)) {
                linkedSites.add(site);
            }
        }
    }
}
```

### Imutability and Defensive

- simplest way to avoid problems is to share only immutable data between threads
- practice defensive coding for values that might be changed (like a List)

```java
public List<String> getList() {
    return Collections.unmodifiableList(list);
}
```

### Threads in Java
- main way to create threads is to use java.lang.Thread
- Thread executes an object of type java.lang.Runnable
- Runnable is interface

    - defines run() method, which is called by Thread object and contains the work which should be done
    - can’t return a result to the caller
- Runnable is the task to perform and Thread is the worker who is doing this task
- disadvantages

    - creating a new thread causes some performance overhead
    - too many threads can lead to reduced performance because of context switching
    - cannot easily control the number of threads and may run out of memory because of too many threads
- java.util.concurrent package offers improved support for concurrency

### Thread Pools

- Thread pools manage a pool of worker threads
- Thread pool is a collection of tasks and running threads
- contains a work queue which holds tasks waiting to get executed
- Executor framework

    - provides implementation of java.util.concurrent.Executor interface — Executors.newFixedThreadPool(int num_threads)
    - tasks are Runnable or Callable
- Executor lifecycle

    - get ExecutorService from Executors.newFixedThreadPool
    - add task

        - add Runnable by calling execute(Runnable)
        - add Callable by calling executor.submit(Callable) (returns Future)
    - service will execute threads
    - call shutdown() on service to begin shutdown process
    - call awaitTermination() on service to allow all threads to complete

```java
public class Main {
    private static final int NTHREDS = 10;

    public static void main(String[] args) {
        ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);
        for (int i = 0; i < 500; i++) {
            Runnable worker = new MyRunnable(10000000L + i);

            executor.execute(worker);
        }
        // This will make the executor accept no new threads
        // and finish all existing threads in the queue
        executor.shutdown();
        // Wait until all threads are finish
        executor.awaitTermination();
        System.out.println("Finished all threads");
    }
}
```

### Futures and Callables

- Callable can also be run by Thread pool
- Callable allows return values after completion, whereas Runnable does not
- if callable submitted to Executor, framework returns a java.util.concurrent.Future
- Future can be used to retrieve the Callable result
- as of Java 8 can use CompletableFuture interface to provide a callback

    - code to be executed when a task completes
    - this is sort of like JavaScript promises

### Fork-Join

* fork-join framework allows you to distribute a certain task on several workers and wait for results

```java
public class Test {

    public static void main(String[] args) {
        Problem test = new Problem();
        // check the number of available processors
        int nThreads = Runtime.getRuntime().availableProcessors();
        System.out.println(nThreads);
        Solver mfj = new Solver(test.getList());
        ForkJoinExecutor pool = new ForkJoinPool(nThreads);
        pool.invoke(mfj);
        long result = mfj.getResult();
        System.out.println("Done. Result: " + result);
        long sum = 0;
        // check if the result was ok
        for (int i = 0; i < test.getList().length; i++) {
            sum += test.getList()[i];
        }
        System.out.println("Done. Result: " + sum);
    }
}
```

repository: daveqr/knowledge

repo_name: daveqr/knowledge


text:
# [643. Maximum Average Subarray I](https://leetcode.com/problems/maximum-average-subarray-i/description/)

![](https://img.shields.io/badge/Difficulty-Easy-green.svg)

Topics

* [`Array`](https://leetcode.com/tag/array/)

Given an array consisting of `n` integers, find the contiguous subarray of given length `k` that has the maximum average value. And you need to output the maximum average value.

**Example 1:**

>**Input:** [1,12,-5,-6,50,3], k = 4

>**Output:** 12.75

>**Explanation:** Maximum average is (12-5-6+50)/4 = 51/4 = 12.75

**Note:**

 1. 1 <= `k` <= `n` <= 30,000.
 2. Elements of the given array will be in the range [-10,000, 10,000].

url: https://raw.githubusercontent.com/InnoFang/algo-set/2419a7d720bea1fd6ff3b75c38342a0ace18b205/LeetCode/0643. Maximum Average Subarray I/README.md

repository: InnoFang/algo-set

repo_name: InnoFang/algo-set


text:
Brew Cask Outdated [![.](http://gaproxy.gstack.io/UA-68445280-1/bgandon/brew-cask-outdated/readme?pixel&dh=github.com)](https://github.com/gstackio/ga-beacon)
==================

by Benjamin Gandon © 2015-2016

Overview
--------

[Homebrew Cask](http://caskroom.io/) is fantastic.

One annoying thing with it though, is it's inability to tell you which
software could be updated. Homebrew provides a `brew outdated` command, but
God knows why, there is no similar `brew cask outdated`. This was driving me
crazy when decided to write this simple script. It does this very specific job
and that's all. The output is very similar to the one provided by
`brew outdated`.

Honnestly I wonder how you did before installing it. That's why I'm sharing it
with you.

Install
-------

Run these commands in a terminal:

    curl https://raw.githubusercontent.com/bgandon/brew-cask-outdated/master/brew-cask-outdated.sh > /usr/local/bin/brew-cask-outdated
    chmod +x /usr/local/bin/brew-cask-outdated

If you know what it's about, please check that it's correct for your setup. If
you don't, it doesn't matter. It shall work anyway.

Usage
-----

Just run

    brew-cask-outdated

…and see the result.

License
-------

`brew-cask-outdated` is released under [the MIT License](LICENSE.txt).

<!--
# Local Variables:
# indent-tabs-mode: nil
# End:
-->

repository: bgandon/brew-cask-outdated

gha_language: Shell

repo_name: bgandon/brew-cask-outdated


text:
# react-components

A collection of reusable React components with their own Flux lifecycle.

[![NPM version][npm-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url]

## What's inside react-components?

#### [Table Component](./docs/table.md)

From a simple table to multi-column filtering, column sorting, row selection, client side pagination, and more.

#### [Pie Chart Component](./docs/piechart.md)

Display complex data with our pie chart's drill in/out functionality, hover animations, and result list.

#### [Modal Component](./docs/modal.md)

A simple single page modal that renders in it's own DOM tree and operates outside the render cycles of an application.

#### [Confirm Dialog Component](./docs/confirmdialog.md)

A page level component that displays a confirmation dialog to the user with OK/Cancel buttons.

#### [Page Message Component](./docs/pagemessage.md)

A page level component that animates in and out for success, error, warning, info, and custom messages.

## Getting Started

#### NPM Install react-components

```
$ npm install dataminr-react-components --save
```

#### If using a component which requests data from your APIs, add a mapping to your webpack config for the component which will be responsible for making requests
```
resolve: {
    alias: {
        RequestHandler$: path.join(__dirname, 'path', 'to', 'request', 'library'),
    }
},
```

#### Add external style sheet
```
<link type="text/css" rel="stylesheet" href="/node_modules/react-components/dist/react-components.css" />
```

## Submitting Issues

##### If you are submitting a bug, please create a [jsfiddle](http://jsfiddle.net/) demonstrating the issue if possible.

## Contributing

##### Fork the library and follow the Install Dependencies steps below.

```
$ git clone https://github.com/dataminr/react-components.git
$ git checkout master
```

#### Important Notes

* Pull requests should be made to the `master` branch with proper unit tests.
* Do not include the distribution files in your pull request. These are only sent to NPM

#### We use the following libraries within our project

* [React](http://facebook.github.io/react/) JavaScript library for building user interfaces
* [Flux](https://facebook.github.io/flux/) Application architecture for building user interfaces
* [lodash](https://lodash.com/docs) JavaScript utility library
* [Moment](http://momentjs.com/docs/) Parse, validate, manipulate, and display dates in JavaScript
* [jQuery](http://jquery.com/) Fast, small, and feature-rich JavaScript library
* [d3](http://d3js.org/) Manipulate documents based on data with Data-Driven Documents

##### Style

* [Compass](http://compass-style.org/) Css authoring framework
* [Sass](http://sass-lang.com/) CSS with superpowers

##### Unit testing and style checking

* [Jasmine](http://jasmine.github.io/2.2/introduction.html) Behavior-driven development framework for testing JavaScript code
* [Istanbul](https://github.com/gotwarlost/istanbul) JavaScript statement, line, function, and branch code coverage when running unit tests
* [ESLint](http://eslint.org/) The pluggable linting utility for JavaScript and JSX

#### Install Dependencies

##### Node

[node.js.org](nodejs.org)

##### Compass & Sass

```
$ gem install compass
```

##### Grunt command line interface

```
$ npm install -g grunt-cli
```

##### Finally, install third-party dependencies and start watchers:

```
$ cd ~/path/to/react-components/root
$ npm install
$ grunt
```

If you find your css build results are empty, update your sass gem.

#### Use the sample app in your browser to develop

> /react-components/examples/index.html

### Grunt Tasks

The default grunt task will start webpack to complile all JS/Sass and startup webpack dev server to server combined files.

```
$ grunt
```

Run Karma unit tests and eslint

```
$ grunt test
```

Same as grunt test, however, this task will run code coverage and launch the code coverage in your browser.

```
$ grunt test:cov
```

## License

MIT

## Special Thanks To:

The developers that made this project possible by contributing to the the following libraries and frameworks:

[React](http://facebook.github.io/react/), [Flux](https://facebook.github.io/flux/), [Compass](http://compass-style.org/),
[Sass](http://sass-lang.com/), [Require](http://requirejs.org/), [Grunt](http://gruntjs.com/), [Jasmine](http://jasmine.github.io/2.2/introduction.html),
[Istanbul](https://github.com/gotwarlost/istanbul), [ESLint](http://eslint.org/), [Watch](https://github.com/gruntjs/grunt-contrib-watch),
[d3](http://d3js.org/), [lodash](https://lodash.com/docs), [jQuery](http://jquery.com/), and [Moment](http://momentjs.com/docs/)

[npm-image]: https://badge.fury.io/js/dataminr-react-components.svg
[npm-url]: https://www.npmjs.com/package/dataminr-react-components

[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE

[travis-url]: https://travis-ci.org/dataminr/react-components
[travis-image]: https://travis-ci.org/dataminr/react-components.svg?branch=master

gha_language: JavaScript


text:
![image](http://f.cl.ly/items/3A1s071l1H0M1c34210k/Schermafbeelding%202013-01-16%20om%2019.02.11.png)

# YellowText - Rails

Editing text shouldn't be a pain. It should be simple. It should be pretty. With Yellow Text it is.

This lightweight jQuery plugin can be used to make your text editing proces a lot easier and more fun. The text editor only contains the most basic functions you need for editing text.

For more information about the plugin, you should check [the official repo](https://github.com/stefanvermaas/yellow-text).

## Installation

Add this line to your application's Gemfile:

    gem 'yellow-text-rails'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install yellow-text-rails

## Usage

**Step 1:**
Make sure you call the plugin by it's name

```javascript
$("#js-your-html-element").texteditor();
```

**Step 2:**
Make sure you're calling the javascript file in your application.js and the css file in your application.css:

`//= require yellow-text` and `*= require yellow-text`

**Step 3:** Annnnnnnnnnd... finished! Wasn't that hard huh?!

## Beer-ware license
As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.

## 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

repository: stefanvermaas/yellow-text-rails

repo_name: stefanvermaas/yellow-text-rails


text:
---
cslItem:
  id: schmidt__2002__game
  call-number: HB144 .G3727 2002
  citation-key: schmidt__2002__game
  collection-number: "1"
  collection-title: Routledge advances in game theory
  editor:
    - family: Schmidt
      given: Christian
  event-place: London ; New York
  ISBN: 978-0-415-25987-3
  issued:
    date-parts:
      - - 2002
  keyword: Economics;Game theory;/unread;collection::strategy::game-theory
  language: eng
  number-of-pages: "193"
  publisher: Routledge
  publisher-place: London ; New York
  source: Library of Congress ISBN
  title: Game theory and economic analysis
  type: book
tags:
  - Economics
  - Game theory
  - /unread
  - issue:strategy
  - topic:strategy/game-theory
rendered:
  bibliography: |-

      Schmidt, C. Ed.. (2002). Game theory and economic analysis. Routledge.

  citation: Schmidt, 2002
bibTex: "@book{schmidt__2002__game,\n\taddress = {London ; New York},\n\tnumber = {1},\n\tseries = {Routledge advances in game theory},\n\teditor = {Schmidt, Christian},\n\tyear = {2002},\n\tpublisher = {Routledge},\n\ttitle = {Game theory and economic analysis},\n}\n\n"
---


text:
---
title: Philosophy
description: |
    Guiding principles for all GopherSource projects
---

All GopherSource projects follow a common [code of
conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
In addition we'd like to suggest other ways to make GopherSource projects
welcoming spaces.

- [Be kind to each other](#be-kind-to-each-other)
- [Make development and testing easy](#make-development-and-testing-easy)
- [Focus on our community](#focus-on-our-community)
- [Ask questions](#ask-questions)

## Be Kind to Each Other

We firmly believe that a kind, welcoming and constructive community comes first,
then code and technology second. If the folks in the community around this
project aren't kind to each other, it doesn't matter how cool our technology is.

- Make newcomers feel welcome.
- Keep debates in Github issues, and be civil and constructive in them.
- [Listen more than you talk](https://hbr.org/2017/02/in-a-difficult-conversation-listen-more-than-you-talk).
- Respect that everyone is in different time-zones, don't exclude people outside
  of the majority time-zone.
- Be kind to yourself, step back from the project when you need to
  take care of you and your life, and avoid burnout.

Most importantly, **be inclusive**. Not everyone will share your opionions,
communication style, and many other things. Consider their point of view
and treat everyone with respect.

## Make Development and Testing Easy

Cognitive load is bad when you're writing code, so let's minimize it.

- Getting started should be a one-liner.
- Make the hard things easier.
- Docs are good, keep them up-to-date in the same PR when the change is made.
- Our code is collectively owned and accessible to everyone.

## Focus on Our Community

There's an African proverb that goes like this:

>If you want to go fast, go alone. If you want to go far, go together.

We want to apply that wisdom to our community.

- It's easy and sometimes tempting to do everything yourself.
- But if we want to keep the project growing, it's hard to have just a few people doing everything.
- Related: [the bus factor](https://en.wikipedia.org/wiki/Bus_factor).
- So let's focus on bringing new people into the community, and getting them started (see: Be Kind to Each Other, above).

## Ask Questions

Questions are a great way for us to share ideas and make the project and community better.

- If you don't know something, try not to be afraid to ask.
- If you think your question is stupid, ask it anyway.
- ... And if you're still uncomfortable asking in public, ask a maintainer in private.
- If someone asks you a question, it's ok to answer it later.
- Put answers on paper where everyone can read them, if you can.
- ... And FAQs are great to have - let's do them!
- Newcomers have the best perspectives, so listen well to their questions.

gha_language: CSS


text:
# Azure Core LRO client library for JavaScript

Azure's Core LRO is a JavaScript library that provides an API that aims to
allow the azure-sdk-for-js public libraries to implement fully featured pollers
to manage Long Running Operations (LROs) with the Azure services.

@azure/core-lro is made following our guidelines here: https://azure.github.io/azure-sdk/typescript_design.html#ts-lro

[Source code](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/core-lro)

## Getting started

### Install the package

To install this package locally, use `npm install --save @azure/core-lro`.

### Configure TypeScript

TypeScript users need to have Node type definitions installed:

```bash
npm install @types/node
```

They will also need to enable `compilerOptions.allowSyntheticDefaultImports` in their
`tsconfig.json`. Note that if you have enabled `compilerOptions.esModuleInterop`,
`allowSyntheticDefaultImports` is enabled by default.
See [TypeScript's compiler options handbook](https://www.typescriptlang.org/docs/handbook/compiler-options.html)
for more information.

## Key concepts

@azure/core-lro makes a distinction between the Long Running Operation and its Poller.

- Whenever we talk about an **operation**, we mean the static representation of a Long Running Operation.
  Any operation will have a definition of a **state**, which has an opinionated default set of properties.
  The definition of the operation will also have functions that will define how to request new information
  about the pending operation, how to request its cancellation, and how to serialize it.
- A **Poller** is an object who's main function is to interact with an operation until the poller is manually stopped,
  the operation finishes (either by succeeding or failing) or if a manual request to cancel the operation has succeeded.
  Some characteristics of the pollers are:
    - Pollers show the status of the polling behavior.
    - Pollers support manual as well as automatic polling.
    - Pollers are serializable and can resume from a serialized operation.
    - Pollers also specify how much of the operation's state is going to be available to the public.
- A **PollerLike** is the public interface of a Poller, which allows for different implementations to be used.

## Examples

You will be able to find some working examples of an implementation of an operation and a poller both in
our test files: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/core-lro/test
as well as in the azure-sdk-for-js libraries that might be currently using core-lro, which can be found here:
https://github.com/Azure/azure-sdk-for-js/search?q="from+%40azure%5C%2Fcore-lro"&unscoped_q="from+%40azure%5C%2Fcore-lro"

### Implementing an operation

To work with a Long Running Operation, we need to define how to update, cancel
and serialize the information related to the remote pending task.
To implement this class for your library or application,
you'll need to import the definitions of a poll operation and its state.

```typescript
import { PollOperationState, PollOperation } from "@azure/core-lro";
```

A `PollOperation` is an interface that defines how to update the local reference of the state
of the remote long running operation, just as well as how to request the cancellation of the same operation.
Besides updating and cancelling, it also defines how to serialize its information,
so that polling can be resumed at any time from a previously serialized operation
(more at [Serializing an operation](#serializing-an-operation)).

`PollOperationState` provides a basic state for the poll operation.
It contains the minimal set of properties needed
to keep track of a long running operation, and it's intended to be extended
with any custom property that your program might need.
The state can be updated any time, but it should be updated at least in three opportunities:
when the operation starts, when it's finished, and when it's cancelled.

To be able to create your custom operations, you'll need to extend the
`PollOperation` class with both your operation's state and the final result
value. For this example, we'll think on the final result value to be `MyResult`,
which can be any type.

```typescript
import { PollOperationState, PollOperation } from "@azure/core-lro";

export interface MyOperationState extends PollOperationState<MyResult> {
  serviceClient: any; // You define all of these properties
  myCustomString: string;
  startedAt: Date;
  finishedAt: Date;
  // ... and so on
}

export interface MyPollOperation extends PollOperation<MyOperationState, MyResult> {}
```

We recommend making a utility function to create new instances of your operation. Just like the following:

```typescript
function makeOperation(
  state: MyOperationState,
): MyOperation {
  return {
    // We recommend creating copies of the given state,
    // just to make sure that no references are left or manipulated by mistake.
    state: {
      ...state,
    },
    update,
    cancel,
    toString
  };
}
```

To properly define an operation, you will need to have implemented these three functions: `update`, `cancel` and `toString`.
A guide on how to write them follows.

#### Your operation's update method

The `update` method defines how to request the remote service for updates on the status of the long running operation.

It optionally receives an object with an `abortSignal` property, from [@azure/abort-controller](https://github.com/Azure/azure-sdk-for-js/tree/f5ad8a25fd399564518f526a060a372e602f30c5/sdk/core/abort-controller)'s `AbortSignalLike`.

A more advanced use allows passing in a `fireProgress` function, which, if called, is responsible for triggering the
poller's `onProgress` callbacks.

Here is an example of how to write an update method for your operation:

```typescript
async function update(
  this: MyOperation,
  options: {
    abortSignal?: AbortSignalLike;
    fireProgress?: (state: MyOperationState) => void;
  } = {}
): Promise<MyOperation> {
  let isDone: boolean = false;
  let doFireProgress: boolean = false;

  // Asynchronously call your service client...

  // You might update the operation's state at any point
  if (isDone) {
    this.state.completed = true;
    this.state.result = "Done";
  }

  // You can also arbitrarily report progress
  if (doFireProgress) {
    options.fireProgress(state);
  }

  return makeOperation(this.state);
}
```

#### Your operation's cancel method

The operation's `cancel` method should attempt to cancel the pending operation, if it's allowed by the remote service.
Otherwise, it should throw.

It only optionally receives an object with an `abortSignal` property, from [@azure/abort-controller](https://github.com/Azure/azure-sdk-for-js/tree/f5ad8a25fd399564518f526a060a372e602f30c5/sdk/core/abort-controller)'s `AbortSignalLike`.

It returns a promise that should be resolved with an updated version of the poller's operation.

```typescript
async function cancel(
  this: MyOperation,
  options: { abortSignal?: AbortSignalLike } = {}
): Promise<MyOperation> {
  // ... Reach out to your service to trigger the cancellation of the operation ...

  return makeOperation(
    {
      ...this.state,
      cancelled: true
    }
  );
}
```

#### Serializing an operation

The operation's method `toString` returns a string with a serialized representation of the operation.
It's useful when a poller wants to be resumed from a previously serialized state.

The deserialization of the operation has to be implemented within the constructor of a class that extends
the Poller class. You can read more at [Resuming from a previous poller](#resuming-from-a-previous-poller).

```typescript
function toString(this: MyOperation): string {
  return JSON.stringify({
    state: {
      ...this.state,
      // Only the plain text properties, for example
    }
  });
}
```

### Implementing a poller

@azure/core-lro's `Poller` is a class that represents the definition of a program that polls
through consecutive requests until it reaches a state of completion.

A poller can be executed manually, by polling request by request by calling to the `poll()` method repeatedly,
until its operation is completed.
It also provides a way to wait until the operation finishes, by calling `pollUntilDone()`, which returns a promise.
Pollers can also request the cancellation of the ongoing process (internally using `PollOperation`'s `cancel()` method).

The Poller needs two types to be defined, a type representing the state of the poller, which
must include a basic set of properties from `PollOperationState<TResult>` (as mentioned in [Implementing an operation](#implementing-an-operation)), and a return type defined by `TResult`, which can be anything.

To implement a poller, you must pull in the definitions of your operation and extend @azure/core-lro's `Poller` class, as follows:

```typescript
import { Poller } from "@azure/core-lro";
import { makeOperation, MyOperation, MyOperationState } from "./myOperation";

// See that "MyResult" here is the type of the result
export class MyPoller extends Poller<MyOperationState, MyResult> {
  constructor(
    baseOperation?: MyOperation,
    onProgress?: (state: MyOperationState) => void
  ) {
    let state: MyOperationState = {};

    if (baseOperation) {
      state = baseOperation.state;
    }

    const operation = makeOperation(state);

    super(operation);

    // Setting up the poller to call progress when the operation decides.
    // This ties to the operation's update method, which receives a
    // fireProgress method in the optional properties.
    if (onProgress) {
      this.onProgress(onProgress);
    }
  }

  async delay(): Promise<void> {
    // Your own implementation of a delay
  }
}
```

Once defined, you'll be able to use your poller as shown below:

```ts
const poller = new MyPoller();

// Polling just once:
await poller.poll();

// We can try to cancel the request here, by calling:
//
//     await poller.cancelOperation();
//

// Getting the final result:
const result = await poller.pollUntilDone();
```

The Poller class implements the `PollerLike` interface, which allows poller implementations that avoid having
to export the Poller's class directly, and instead only export the already instantiated poller with the `PollerLike` type.

An example of the definition of a client that returns an instantiated poller can be seen below:

```ts
class Client {
  public async makePoller: PollerLike<MyOperationState, MyResult> {
    const poller = new MyPoller({});
    // It might be preferred to return the poller after the first request is made,
    // so that some information can be obtained right away.
    await poller.poll();
    return poller;
  }
}

// No knowledge of the class MyPoller:
const poller: PollerLike<MyOperationState, MyResult> = myClient.makePoller();
```

A poller can be created through its constructor, then it can be polled until it's completed.
At any point in time, the state of the poller can be obtained without delay through the getOperationState method.
At any point in time, the intermediate forms of the result type can be requested without delay.
Once the underlying operation is marked as completed, the poller will stop and the final value will be returned.

Here's an example usage of your client's poller:

```ts
const poller = myClient.makePoller();
const state: MyOperationState = poller.getOperationState();

// The intermediate result can be obtained at any time.
const result: MyResult | undefined = poller.getResult();

// The final result can only be obtained after the poller finishes.
const result: MyResult = await poller.pollUntilDone();
```

#### Resuming from a previous poller

Pollers by default have a method called `toString` that invokes the operation's `toString` method.
It can be used to store the state of a poller indefinitely, to then resume by creating another poller at any time in the future.

If an operation's `toString` method is defined as follows:

```ts
function toString(this: TestOperation): string {
  return JSON.stringify({
    state: this.state
  });
}
```

A custom implementation of a poller can deserialize it by receiving this string and converting it back to JSON, like in the following example:

```ts
export class MyPoller extends Poller<MyOperationState, string> {
  constructor(
    baseOperation: string | undefined
  ) {
    let state: MyOperationState = {};
    if (baseOperation) {
      state = {
        ...JSON.parse(baseOperation).state,
        ...state
      };
    }
    const operation = {
      state,
      // ...
    }
    super(operation);
  }
}
```

## Troubleshooting

### Enable logs

Logs can be added at the discretion of the library implementing the Long Running Operation poller.
Packages inside of [azure-sdk-for-js](https://github.com/Azure/azure-sdk-for-js) use
[@azure/logger](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/logger).

## Next steps

Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/f5ad8a25fd399564518f526a060a372e602f30c5/sdk/core/core-lro/samples) directory for detailed examples on how to use this library.

## Contributing

If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/master/CONTRIBUTING.md) to learn more about how to build and test the code.

### Testing

To run our tests, first install the dependencies (with `npm install` or `rush install`),
then run the unit tests with: `npm run unit-test`.

### Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode<EMAIL_ADDRESS>with any additional questions or comments.

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore%2Fcore-lro%2FREADME.png)


text:
## Time Info

Time Info used to display the time in days, hours and minutes. See examples to understand it better.

### Basic usage

:::demo Use `type` [`day`, `hour`, `minute`] to define Button's style.

```html
<div>
  <tm-time-info type="day">2</tm-time-info>
  <tm-time-info type="hour">12</tm-time-info>
  <tm-time-info type="minute">47</tm-time-info>
</div>
```
:::

### Attributes
| Attribute      | Description    | Type      | Accepted values       | Default   |
|---------- |-------- |---------- |-------------  |-------- |
| type     | time info type   | string    |   day / hour / minute |     —    |

branch_name: refs/heads/dev

gha_language: Vue


text:
# CHANGELOG

## 1.0.0

BREAKING CHANGES:

- refactor: IEntity is now typed differently - it requires `typeof` modifier for components.
- feat: All argument types are now correctly inferred for Components which use constructor args.
- feat: `addComponent` now accepts arguments positionally rather than packed in an Array.

Example for above changes:

```tsx
  class FakeComponentWithArgs {
    private _arg1: number;
    private _arg2: string;

    constructor(arg1: number, arg2: string) {
      this._arg1 = arg1;
      this._arg2 = arg2;
    }
  }

  let entity: IEntity<
    [
      typeof FakeComponentWithNoArgs,
      typeof FakeComponentWithArgs
    ]
  >;

  (...)

  entity.addComponent(FakeComponentWithArgs, 1, "test"); // this now correctly infers types.
```

## 0.3.0

- docs: Added CHANGELOG.
- feat: [#11](https://github.com/hemi93/quick-ecs/issues/11) - added `Entity.removeComponent` method.
- chore: When called for non-existent Component, `Entity.getComponent` now returns `undefined` instead of throwing:
  - Should support the functional paradigm better.
  - Makes code more explicit.
- refactor: Source code was reformatted with new linting settings.
- chore: Updated dependencies (mainly to use `TypeScript 4.0.5`).

gha_language: TypeScript


text:
---
layout: post
title: ownYourThoughts.sh
---

# sudo su - && chown -R $user:$user /etc/life/mind/*

> "Until you make the unconscious conscious,
> it will direct your life
> and you will call it fate."
> —Carl Jung

Aimlessness's only end goal is entropy.

Opting out of directing our lives does not in turn opt us out of the overall game of Life. Life continues around us with our active participation or without. No one gets to be an NPC. You're either directing your thoughts, energy and actions or someone/thing else will.

Of every tool at our disposal, the mind is by far the most powerful, and perhaps also the only tool that if not actively used, also has the power to use itself against us.


text:
---
id: 1945
title: 'Updates: Things I’m Doing & Things I’m Reading'
date: 2015-04-06T00:32:56+00:00
author: admin
layout: post
guid: http://emilyesten.com/words/uncategorized/updates-things-im-doing-things-im-reading/
permalink: /highlights/updates-things-im-doing-things-im-reading/
tumblr_sheishistoric_permalink:
  - http://sheishistoric.tumblr.com/post/115620158527/updates-things-im-doing-things-im-reading
  - http://sheishistoric.tumblr.com/post/115620158527/updates-things-im-doing-things-im-reading
tumblr_sheishistoric_id:
  - "115620158527"
  - "115620158527"
original_post_id:
  - "1945"
  - "1945"
categories:
  - Highlights
tags:
  - 5colldh
  - found on twitter
  - umass press
period: undergraduate
---
It’s getting to the end of the semester, but a lot of stuff has been happening.

Things I’m Doing:

  * My internship at UMass Press has been going well – I’ve spent the majority of my semester developing their new blog, which was launched earlier this week. It’s given me a chance to really delve into scholarly publishing and research a number of publications by the Press in the last few years. Check out the blog here!
  * I went to see Angela Davis last Monday! As expected, she was a phenomenal speaker greeted by a standing ovation before and after her presentation. The _Massachusetts Daily Collegian_ has a good summary of the key points in her address.
  * I also went to the Five College Digital Humanities Speaker Series presentation with D. Fox Harrell – you can read my reflection here or the Storify by 5CollDH here.
  * I got to use Google Glass, despite it being way past its prime.

Things I’m Reading:

  * “How Do You Design the Library of the Future?” by Oxford University – What is the history of the library? How do we use it today? Where is it headed?
  * “Museums: Getting in the Game” – Digital Public History – What do museums (or really, GLAMs) think of digitization?
  * “’Jews Aren’t Allowed to Use Phones’: Berlin’s Most Unsettling Memorial” by Ian Johnson – A thought-provoking public history experiment.

gha_language: HTML


text:
# Adding resources

Resources live under `pkg/apis/<group>/<version>/<resource>_types.go`.
It is recommended to use `apiserver-boot` to create new groups,
versions, and resources.

## Creating a resource with apiserver-boot

1. Create the group the resource will live under.

`apiserver-boot create group --domain <domain> --group <group>`

2. Create the version the resource will live under

`apiserver-boot create group --domain <domain> --group <group> --version <version>`

3. Create the resource

The resource name should be all lower case and plural.  e.g. `deployments`.
The resource also has *Kind*, which is the CamelCase singular name of
your resource.  e.g. `Deployment`

`apiserver-boot create group --domain <domain> --group <group> --version <version> --kind <Kind> --resource <resource>`

## Anatomy of a resource

A resource has a go struct which defines the *Kind* schema, and is
annotated with comment directives used by the code generator to
wire the storage and REST endpoints.

Example:

```go
// +genclient=true

// +resource:path=foos
// +k8s:openapi-gen=true
// Foo defines some thing
type Foo struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

    // spec defines the desired state of Foo
	Spec   FooSpec   `json:"spec,omitempty"`

    // status records the observed state of Foo
	Status FooStatus `json:"status,omitempty"`
}

// FooSpec defines the desired state of Foo
type FooSpec struct {
    // some_spec_field defines some desired state about Foo
	SomeSpecField int `json:"some_spec_field,omitempty"`
}

// FooStatus records the observed state of Foo
type FooStatus struct {
	// some_status_field records some observed state about Foo
	SomeStatusField int `json:"some_status_field,omitempty"`
}
```

### Breakdown of example

```go
// +resource:path=foos
```

This tells the code generator to generate the REST
storage endpoints for this resource.

```go
// +k8s:openapi-gen=true
```

This tells the code generator to include this
resource in the openapi spec published by the apiserver

```go
// Foo defines some thing
```

This will appear in the openapi spec and the
generated reference docs as the description of the resource.

```go
type Foo struct {...}
```

This block defines the resource schema

```go
metav1.TypeMeta   `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
```

These define metadata common to most resources - such as
the name, group/version/kind, annotations, and labels.

```go
// spec defines the desired state of Foo
Spec   FooSpec   `json:"spec,omitempty"`
```

This field defines the desired state of Foo that the controller loops
will work towards.

```go
// status records the observed state of Foo
Status FooStatus `json:"status,omitempty"`
```

This field records the state of Foo observed by the controller loops
for clients to read.

```go
// FooSpec defines the desired state of Foo
type FooSpec struct {
    // some_spec_field defines some desired state about Foo
	SomeSpecField int `json:"some_spec_field,omitempty"`
}

// FooStatus records the observed state of Foo
type FooStatus struct {
	// some_status_field records some observed state about Foo
	SomeStatusField int `json:"some_status_field,omitempty"`
}
```

These structures define the schema for the desired and observed
state.

## Generating the wiring

To generate the REST endpoint and storage wiring for your resource,
run `apiserver-boot generate --api-versions "your-group/your-version"`
from the go package root directory.

This will also generate go client code to read and write your resources under `pkg/client`.

repository: jimmidyson/apiserver-builder

repo_name: jimmidyson/apiserver-builder


text:
//[cycle-compose](../../index.md)/[com.chrynan.cycle.compose](index.md)/[stateChanges](state-changes.md)

# stateChanges

[common]\

@ExperimentalCoroutinesApi

@FlowPreview

@[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html)

fun <[State](state-changes.md), [Change](state-changes.md)> [ViewModel](../../../cycle-core/cycle-core/com.chrynan.cycle/-view-model/index.md)<[State](state-changes.md), [Change](state-changes.md)>.[stateChanges](state-changes.md)(context: [CoroutineContext](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html) = EmptyCoroutineContext): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[State](state-changes.md)?>

Obtains the changes to the underlying [State](state-changes.md) as a Jetpack Compose [androidx.compose.runtime.State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) value, so that the changes can cause the [Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html) function to be re-composed.

**Note:** That this function will bind this [ViewModel](../../../cycle-core/cycle-core/com.chrynan.cycle/-view-model/index.md) to the invoking composable function's lifecycle via the [rememberAndBind](remember-and-bind.md) function. Therefore, this function should only be invoked from within the composable function that created the [ViewModel](../../../cycle-core/cycle-core/com.chrynan.cycle/-view-model/index.md).

Example usage:

```kotlin
@Composable
fun Content(viewModel: MyViewModel) {
    val state by viewModel.stateChanges()

    // Create the UI using the 'state' variable
}
```

[common]\

@ExperimentalCoroutinesApi

@FlowPreview

@[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html)

fun <[State](state-changes.md), [Change](state-changes.md)> [ViewModel](../../../cycle-core/cycle-core/com.chrynan.cycle/-view-model/index.md)<[State](state-changes.md), [Change](state-changes.md)>.[stateChanges](state-changes.md)(initial: [State](state-changes.md)?, context: [CoroutineContext](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html) = EmptyCoroutineContext): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[State](state-changes.md)?>

Obtains the changes to the underlying [State](state-changes.md), starting with the provided [initial](state-changes.md) value, as a Jetpack Compose [androidx.compose.runtime.State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) value, so that the changes can cause the [Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html) function to be re-composed.

**Note:** That this function will bind this [ViewModel](../../../cycle-core/cycle-core/com.chrynan.cycle/-view-model/index.md) to the invoking composable function's lifecycle via the [rememberAndBind](remember-and-bind.md) function. Therefore, this function should only be invoked from within the composable function that it was created.

Example usage:

```kotlin
@Composable
fun Content(viewModel: MyViewModel) {
    val state by viewModel.stateChanges(initial = null)

    // Create the UI using the 'state' variable
}
```

[common]\

@ExperimentalCoroutinesApi

@FlowPreview

@[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html)

fun <[State](state-changes.md), [Change](state-changes.md)> [View](../../../cycle-core/cycle-core/com.chrynan.cycle/-view/index.md)<[State](state-changes.md), [Change](state-changes.md)>.[stateChanges](state-changes.md)(context: [CoroutineContext](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html) = EmptyCoroutineContext): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[State](state-changes.md)?>

Obtains the changes to the underlying [State](state-changes.md) as a Jetpack Compose [androidx.compose.runtime.State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) value, so that the changes can cause the [Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html) function to be re-composed.

Example usage:

```kotlin
@Composable
override fun Content() {
    val state by stateChanges()

    // Create the UI using the 'state' variable
}
```

[common]\

@ExperimentalCoroutinesApi

@FlowPreview

@[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html)

fun <[State](state-changes.md), [Change](state-changes.md)> [View](../../../cycle-core/cycle-core/com.chrynan.cycle/-view/index.md)<[State](state-changes.md), [Change](state-changes.md)>.[stateChanges](state-changes.md)(initial: [State](state-changes.md)?, context: [CoroutineContext](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/index.html) = EmptyCoroutineContext): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[State](state-changes.md)?>

Obtains the changes to the underlying [State](state-changes.md), starting with the provided [initial](state-changes.md) value, as a Jetpack Compose [androidx.compose.runtime.State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) value, so that the changes can cause the [Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable.html) function to be re-composed.

Example usage:

```kotlin
@Composable
override fun Content() {
    val state by stateChanges(initial = null)

    // Create the UI using the 'state' variable
}
```

repository: chRyNaN/cycle

repo_name: chRyNaN/cycle


text:
+++
title = "Sensors"
weight = 20
+++

We designed a handful of custom sensor to make the feedback collection easier. One important sensor we designed was a simple quadrature encoder board with a dial knob. This allowed us to integrate the gears onto the encoders with ease, and each board was exceptionally cheap at only $2 per.

<center> {{ resize_image(path="documentation/ece/Sensors/Untitled.png", width=0, height=500, op="fit_height") }} </center>

As 8 quadrature encoders is simply too much information for the STM32 to handle at once, we also developed a simple quadrature interpreter board after we had designed the quadrature encoders. This counted the number of steps the quadrature encoder had performed and stored them so the firmware wouldn't have to keep track manually. These boards were powered by a simple STM8 and output their data over I2C. This gave us an incredible performance boost and allowed us to keep closed-loop control of the robot arms and hip system without the controller breaking a sweat.

<center> {{ resize_image(path="documentation/ece/Sensors/Untitled 1.png", width=0, height=500, op="fit_height") }} </center>

repository: jkelleyrtp/RealSteel

gha_language: Python

repo_name: jkelleyrtp/RealSteel