text:
Poet

A lightweight Chrome extension that displays a new poem every day upon new tab launches.

## Installation
Install Poet from the  Chrome web store.

## Demonstration

Displays a new poem every day.

Add poems to your favourites.

View and manage your saved poems.

Refresh for a new poem.

## Questions and Contributions
Feel free to open an issue and/or make a pull request.

## Copyright and License
Poems are queried from [PoetryDB](https://github.com/thundercomb/poetrydb).

Poet images are queried from [MediaWiki](https://www.mediawiki.org/wiki/MediaWiki).

Poet is released under the [MIT License](https://opensource.org/licenses/MIT).

repository: chuyunshen/poet

repo_name: chuyunshen/poet


text:
---
layout: post
title: Lesson 6 - Student Grade Calculator (Tuples, f-string, built-in function)
categories: [Tuples, f-string, sorted (), min (), max (), sum (), len ()]
---

In this tutorial we are going to write an application allowing us to calculate the lowest, highest and average grade of a student, then displaying the results with some formatting for better visual representation.

Become a Patron!

We will do this by providing you with two variables, the **student's name** and **her/his grades**. We will continue to use built-in functions to calculate the results and then use some basic string formatting to show (echo) the results.

> Although we are using built-in functions for these examples. We will have to learn to do what some of these basic built-in functions accomplish by using conditional statements, loops, none-primitives.

What we need in order to write the program

* Tuples
* Built-in functions: `sorted()`, `min()`, `max()`, `sum()` and `len()`
* Output formatting
* Write the program

You work at a school's IT departament, a teacher asked you to write a simple program that will calculate the lowest, highest, average grade and return the grades sorted of a given students. The grades are final, so they don't have to be edited.

* Go!

>Student information:
>
> * **Student's grades:** 89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9
> * **Student's name:** Beth O'Brien

## Tuples

Up until now we have assigned a single value to a variable but we need to assign all the student grades to one variable, we do this by using a non-primitive type container, there are several as you can see by our diagram, in this case we are going to use a **Tuple** since we don't have to manipulate each grade and **Tuple** is non-mutable.

* **Non-primitive types** are containers or "lists" for multiple objects
* All **except Tuples** are mutable, meaning they can be updated
* Any non-primitive can have multiple types in it `int`, `str`, `float` and so on

[]({{ site.baseurl }}/images/non-primitives.svg)

So we can use a **Tuple** to host all the student's grades. A tuple can be represented by all the values, separated by commas`,`, inside parenthesis `()`

If we open an **Interactive session** in **IDLE** and type the following we can see this "list" of grades is typed as a `tuple`

```python
>>> student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
>>> type(student_grades)
<class 'tuple'>
```

* If you assign the "list" of grades to a variable without the parenthesis, **Python** will **automaticall** type them as **Tuples**.

* Python is a **dynamic type** language, you can assign a value to a variable and Python will automatically type the value.

* This is unique to Python, in other programming languages the programmer has to specify the type.

> In comparison Python is like an automatic car, where you don't have to press the clutch to shift gears

Try it in your IDLE interactive session:

* Notice there are no parenthesis in our tuple below

```python
>>> student_grades = 89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9
>>> type(student_grades)
<class 'tuple'>
```

> **Tuples** can contain all primitives, non-primitives and any other type of object. Remember if you have a list of names (strings) they must be in quotes and separated by commas `,`.

```python
students_name = ("Andy", "Mary", "Jesse", "Steven")
```

## Built-in functions

We are going to introduce a few new **built-in functions** and combine them with others we have used before to write our application.

These functions are little **code packages** allowing us to do sertain tasks with out having to write the entire logic our selves, we will start writing our own detailed logic in the next tutorial

If we use the following built-in functions on a Tuple they would do as described below.

| Function   | Description                                         |
| ---------- | --------------------------------------------------- |
| `len()`    | Returns Length of an Object                         |
| `min()`    | Returns the smallest Object                         |
| `max()`    | Returns the largest Object                          |
| `sum()`    | Returns the sum from a given non-primitive ("list") |
| `sorted()` | Returns a sorted "list" from a given iterable       |

### len()

As mentioned the `len()` function will return the length of a non-primitive iterable Object in our case a **Tuple**.

* the `len()` function will try to iterate though each object inside our `Tuple` or anyother non-primitive.

Our grades must have the correct **Data Type** for the functions to work properly.

If we try to use a function like `len()` with a single value it would give us an error.

```python
>>> grade = 89
>>> len(grade)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object of type 'int' has no len()
```

Notice the last line of the error `TypeError: object of type 'int' has no len()`. It is clear Python was looking for the correct type object.

If we convert that single value variable into a **Tuple** containing a single value, then the `len()` built-in function will work.

* We can do this by putting the single value inside parenthesis `()`
* This tells python you are passing a "list", in this case a **Tuple** of a single object
* The `len()` built-in function will accept it now.

```python
>>> grade = (89)
>>> len(grade)
1
```

> You can also write a single value Tuple in the following form `grade = 89,` - notice the comma `,` after the single value. Reffer to the Tuple example above with no parenthesis

But more specifically to our case, we want the length of our grades.

```python
>>> student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
>>> len(student_grades)
8
```

### min() and max ()

These two functions will return the **highest** and **lowest** grades respectivley.

```python
>>> student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
>>> min(student_grades)
75.3
>>> max(student_grades)
95.0
```

> If we were to "open the hood" of each of these built-in functions, we would see a lot of code and calls to other functions.

### sum()

The sum() built-in function cycles or (loops) through each of the grades adding them all up and returning the total.

```python
>>> student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
>>> sum(student_grades)
677.8000000000001
```

> What built-in function would you use to shorten the number of decimals to one place?.

If you weren't using a built-in function to get the sum of a "list", it might look something like this to get the sum of a "list". It would require something call a `loop` and proper indentation which we will cover in our next tutorial.

```python
>>> student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
>>> grade_sum = 0
>>> for grade in student_grades:
...     my_sum = grade_sum + grade
>>> my_sum
677.8000000000001
```

### sorted()

The `sorted()` built-in function will return a copy of the Tuple with sorted grades, from the smallest to the largest grade.

```python
>>> student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
>>> sorted(student_grades)
[75.3, 75.8, 80.3, 83.5, 87.9, 89.5, 90.5, 95.0]
```

## Output format

We have to think how we are going to visually represent the data to the user. We are going to use something relatively new in Python called the **f-string** (formatted string literals), introduced with Python 3.6, to format the output of our program.

There are two other types of older string formatting  you will encounter and should know. `%-formatting` and `str.format()` we will see these two at a later point.

F-strings allow us to imbed an expression inside a string.

* f-string embed expressions inside a string literel using **brackets** `{}`.
* f-string are easier to use.
* f-strings execute faster than the other two types of string formatting.

```python
>>> student_name = "Beth O'Brien"
>>> f"Student name: {student_name}"
```

So the code above would print to screen as follow, where the variable in **brackets** `{student_name}` gets replaced by its value.

```sql
Student name: Beth O'Brien
```

That is it for the theory portion, lets start coding our program.

## Student Grade Calculator (SGC)

Lets open a new document in IDLE. Under **File**, select **New document**. You might want to save it to a projects folder. IDLE should put the correct file extention at the end of you document `.py`

### Program Description

At the top of your document you want to write a short description of your application within triple quotes.

```python
"""
Calculate the lowest, highest and average grade of a student
"""
```

### Assign given values

Assign the values I gave you to variables, **Student's name** and **Grades**.

```python
"""
Calculate the lowest, highest and average grade of a student
"""
student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
student_name = "Beth O'Brien"
```

### Calculate requested values

Now lets calculate some of the requested values, **highest grade**, **lowest grade**, **sorted grades** and **the sum of the grades** to calculate the **average** which will give us the **final grade**.

1. Start by writing variable names which will represent the **returned value**.
2. **Assign** the the **built-in function** to the **variable** at the same time **passing** the appropriate **value as parameters** to the functions.
   1. `lowest_grade = min(student_grades)`.

```python
"""
Calculate the lowest, highest and average grade of a student
"""
student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
student_name = "Beth O'Brien"

# You are here: built-in function assignment
lowest_grade = min(student_grades)
highest_grade = max(student_grades)
sum_grade = sum(student_grades)
number_of_grades = len(student_grades)
sorted_grades = sorted(student_grades)
```

### Calculate grade average

Now lets write the expression to calculate the grade average.

1. We need to take the **sum_grade** and divide it by **total number of grades**.
   1. `sum_grade/number_of_grades`.
2. We need to round it to a single decimal point.
   1. `round(sum_grade/number_of_grades, 1)`.
3. We need to assign it to a variable.
   1. `grade_average`.

```python
"""
Calculate the lowest, highest and average grade of a student
"""
student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
student_name = "Beth O'Brien"

lowest_grade = min(student_grades)
highest_grade = max(student_grades)
sum_grade = sum(student_grades)
number_of_grades = len(student_grades)
sorted_grades = sorted(student_grades)

# You are here: expression calculating grade average
grade_average = round(sum_grade/number_of_grades, 1)
```

### Format output

Lets format and print the results to screen, we would like it to look like this:

```sql
+------------------------------------------------+
 Student Name: Beth O'Brien
+------------------------------------------------+
 lg: 75.3 | hg: 95.0 | Final grade: 84.7
+------------------------------------------------+
 Semester grades:
 [75.3, 75.8, 80.3, 83.5, 87.9, 89.5, 90.5, 95.0]
+------------------------------------------------+
```

#### First lets make our horizontal separator

```python
'''
+------------------------------------------------+
'''
```

We can use the **total number of characters** in the `sorted_grades` variable as a guide to create the correct legnth horizontal line.

In order to get a total count of all characters, first we convert `sorted_grades` to a string and then getting the count by using the `len()` function.

* `len(str(student_grades))`.

Lets assign it to a variable.

* `line_length = len(str(student_grades))`.
  * For this number set it will produce `48`.

> The number of grades in the Tuple, will determine the size of the horizontal line.

```python
"""
Calculate the lowest, highest and average grade of a student
"""
student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
student_name = "Beth O'Brien"

lowest_grade = min(student_grades)
highest_grade = max(student_grades)
sum_grade = sum(student_grades)
number_of_grades = len(student_grades)
sorted_grades = sorted(student_grades)

grade_average = round(sum_grade/number_of_grades, 1)
# You are here: line_length
line_length = len(str(student_grades))
```

We can use this variable to draw the horizontal line. If we multiply a string, i.e `-`, by `line_length` it will output that string multiplied by the value of our variable, `line_length`.

This is **unique to Python**, because it knows is **a string** and when you **multiply** by a **given interger**, instead of giving you an error, it will take the string and print it that many times.

```python
>>> '-' * line_length
------------------------------------------------
```

We can assign all this to a variable.

* `separator = '-' * line_length`.

Lets add it to our program.

```python
"""
Calculate the lowest, highest and average grade of a student
"""
student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
student_name = "Beth O'Brien"

lowest_grade = min(student_grades)
highest_grade = max(student_grades)
sum_grade = sum(student_grades)
number_of_grades = len(student_grades)
sorted_grades = sorted(student_grades)

grade_average = round(sum_grade/number_of_grades, 1)

line_length = len(str(student_grades))
# You are here: line separator
separator = '-' * line_length
```

#### Printing formatted results to screen

We are going to use the f-string to format our output.

* We will use triple quoats for multiple lines.
* we will add the `+` character inside the **f-string** to the front and end of f-string parameter `+{separator}+` .

Lets add the `print()` to the **f-string**.

```python
"""
Calculate the lowest, highest and average grade of a student
"""
student_grades = (89.5, 80.3, 90.5, 75.8, 95.0, 75.3, 83.5, 87.9)
student_name = "Beth O'Brien"

lowest_grade = min(student_grades)
highest_grade = max(student_grades)
sum_grade = sum(student_grades)
number_of_grades = len(student_grades)
sorted_grades = sorted(student_grades)

grade_average = round(sum_grade/number_of_grades, 1)

line_length = len(str(student_grades))
separator = '-' * line_length

# You are here: print formatting
print(f'''
+{separator}+
 Student Name: {student_name}
+{separator}+
 LG: {lowest_grade} | HG: {highest_grade} | Final Grade: {grade_average}
+{separator}+
 Semester Grades:
 {sorted_grades}
+{separator}+
''')
```

When you run the program it should print the results as formatted.

```sql
+------------------------------------------------+
 Student Name: Beth O'Brien
+------------------------------------------------+
 LG: 75.3 | HG: 95.0 | Final Grade: 84.7
+------------------------------------------------+
 Semester Grades:
 [75.3, 75.8, 80.3, 83.5, 87.9, 89.5, 90.5, 95.0]
+------------------------------------------------+
```

That is it for our grade calculator program, it is very basic, but I got a chance to introduce some new programming concepts.

---

## Next tutorial

We are going to edit this program, Grade Calculator, and add letter grades to be display right next to final grade average.

## Things to try

* In the line generator portion, change the width of the line by adding or removing grades from the Tuple.

## Question

* Why did we put the student_name string in double quotes? What if you changed it to single quotes and ran the program?
* What would happen if we didn't convert the `student_grades` to a string in `line_length`?

Become a Patron!

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# ServiceApp #

ServiceApp app demonstrates how to make a service application which has no UI.

### How to create a `Tizen .Net Service Application` in `Visual Studio`

   ![main page](./Screenshots/CreatingProjectForServiceApp.png)

This application uses Tizen.Application API.

* [Class ServiceApplication][ServiceApp]

In addition, there is a similar native service application.

* [Tizen Native Service sample app](https://developer.tizen.org/development/sample/native/AppFW/%28Tutorial%29_Service_Application)

    App Type
    Guide

    Native
    Service Application

    Web
    Service Application

   [ServiceApp]: <https://developer.tizen.org/dev-guide/csapi/api/Tizen.Applications.ServiceApplication.html>

   [NativeGuide]: <https://developer.tizen.org/development/guides/native-application/application-management/applications/service-application>
   [WebGuide]: <https://developer.tizen.org/development/guides/web-application/application-management/applications/service-application>

repository: lkasana/Tizen-CSharp-Samples

repo_name: lkasana/Tizen-CSharp-Samples


text:
# Andrew, Tutorial & You - React

## Introduction
Welcome to anoter part of my [React.js](https://reactjs.org/) tutorial. This should provide you the basics to get started on any React project. I will be guiding you through a list of tutorials written by the wonderful programmers of the _Internet_ and showing you what React is and how to use it. Whether you kinda know what's going on or have no idea, this is the tutorial for you.

Due to the vast amount of material that I have to cover, I do not have time to go over everything. So we won't. We will however be going over the essential basics that should allow you to start on a React project and to know where to look for help when needed. For this reason, I have not only included tutorials, but also references.

And since I myself have not written these tutorials, some parts may be irrelevant or confusing within this tutorial's context. Therefore, before reading each tutorial, I suggest you also take a look at the section I wrote for it down below first. Basically, if you follow the flow of this document, you should be fine. There are guiding questions as well which pinpoint what kind of topics you should focus on. For your own benefit, try to answer the questions first before looking at the answer.

Finally, without further ado, here is the tutorial.

---

## The Prerequisites
There are also a few things you must do BEFORE you start this tutorial:
1. Install [Node.js](https://nodejs.org) (or update to latest version).
2. Install [Node Package Manager](https://www.npmjs.com) (or update).
3. Know some basic `cmd` or `bash` commands (things like `cd` and stuff, nothing fancy).

> NOTE: When you do any install / updates, be sure to restart your command prompt or terminal.

## The Tutorial

### Part 2: Setting up React
This will help you setup a basic React environment so you can start building stuff! If you prefer a video over text, there's an identical video guide at the top of the page. Before you start however, there is a couple things you need to do.

The setup:
1. First, create a new directory somewhere. This will be the example project folder. Then open command prompt, or a terminal, to that directory.
```bash
cd ./the/path/to/your/project/directory
```
2. Then, run `npm init` in that directory.
3. Next, when following the tutorial, it will first ask you to run `npm install -g create-react-app`. You do not need to use `-g` in the command. Use `npm install create-react-app` (the flag is omitted) instead. The `g` flag will install the package globally, but we will only be using this package for this tutorial. If you did install it globally, don't worry. Just uninstall it later with `npm uninstall create-react-app`.
4. And you should now follow the tutorial! (There are a few more notes below to help you out).

Additional notes:
> NOTE: `chord` is just the project name. You can name it whatever you want :D

> NOTE: If you run into issues with `node` or `npm` commands, try making sure you have the latest npm and node versions. You can check by doing `npm --version` and `node --version`. You can try updating by following this guide:
https://docs.npmjs.com/try-the-latest-stable-version-of-npm

> NOTE: For updating on windows, this may be useful. Just follow the README; you don't need to download the source code on the github page.
https://github.com/felixrieseberg/npm-windows-upgrade

What you should be able to answer from this:
- How do you setup a React environment?

  Answer

    You should follow the tutorial more closely. If that's not helpful, try looking online. There are too many small details to put here.

- How to create a React component and render it?
  - Can you make a React component that renders a static list of fruits?
    - HINT: Try the [`<ul>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul).
    - ANOTHER HINT: You should be able to use the same React component file "template" you used for HelloWorld. If you create a new file, don't forget to `import` it. React won't know what to render if you don't tell it where to find the componet. Look in `index.js` and `App.js` to see how the tutorial tells React what to render.

  Answer

// ... boilerplate code ...
function render()
{
  return (
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
    </ul>
  );
}

> Link: [How To Create Your First React App](https://coderjourney.com/tutorials/how-to-create-your-first-react-app/)

> Progress (2/6)

repository: flapjs/webapp

gha_language: JavaScript

gha_license_id: MIT

repo_name: flapjs/webapp


text:
# API

Alfa exposes a large API surface split across many different packages. As an API consumer, you typically only interact with a handful of these packages and, as shown in the [Usage][] section of the [README][], a complete example of running an audit using Alfa requires only 3 package imports.

Most of the packages provided by Alfa are small, foundational packages that provide shared interfaces, common algorithms and data structures, and more. In keeping with the second [goal of Alfa][goals], it ships with its own implementations of much common functionality, ensuring a cohesive experience for API consumers and developers alike.

The following present an introduction on some overarching principles in Alfa' API, as well as some of the common interfaces commonly used in the code base.

You can get an overview of the packages architecture (grouped thematically) with the [dependency graph](./dependency-graph.png). To take a deep device into the API, start your journey at the [package overview][].

> :warning: Many packages still lack accompanying explanations for their public API. The generated API documentation should therefore be considered a work in progress.

## Design

The APIs of Alfa are all based on the same approach of merging the best aspect of functional programming with the best aspect object-oriented programming: Immutable objects that carry around their methods. This is a pattern you'll find throughout Alfa and which may at first feel somewhat foreign. From foundational data structures to the machinery responsible for carrying out accessibility audits, methods never modify objects, but instead return new objects with the modifications applied. This is a rather drastic shift from how JavaScript APIs are usually designed and can take some getting used to.

To get a quick taste of the benefits of this approach, consider the following code:

```ts
const map = new Map<string, number>();

map.set("foo", 42);
// This call modifies `map`

doSomethingWithMap(map);

map.get("foo");
// ?
```

The call to `doSomethingWithMap()` is free to modify `map` as it wishes and so even though we used a `const` binding for `map`, we're not guaranteed that `map.get("foo")` will return `42`. We were also free to modify `map` with the side effecting call `map.set("foo", 42)`.

Let's take a look at the equivalent code using the `@siteimprove/alfa-map` package:

```ts
import { Map } from "@siteimprove/alfa-map";

const map = Map.empty<string, number>().set("foo", 42);

map.set("foo", 24);
// This call has no effect on `map`

doSomethingWithMap(map);

map.get("foo");
// 42
```

As the `Map<K, V>` class from `@siteimprove/alfa-map` is immutable, we can be sure that `doSomethingWithMap()` has no way of modifying `map`. The call to `map.get("foo")` is therefore guaranteed to always return `42`. This quality is called [referential transparency][] and means that we can substitute any expression with its value without changing the behaviour of the code.

As a result of this quality, it becomes easier to reason about the behaviour of a given piece of code as all modifications of state are made explicit. If, for example, `doSomethingWithMap()` _was_ supposed to modify `map`, we'd have to explicitly change the binding:

```ts
import { Map } from "@siteimprove/alfa-map";

let map = Map.empty<string, number>().set("foo", 42);

map = doSomethingWithMap(map);

map.get("foo");
// ?
```

## Foundations

In this section, we'll take a look at some of the foundational APIs that are used throughout Alfa.

### Equivalence

When dealing with the concept of equivalence in JavaScript, we typically distinguish between two kinds of equivalence:

- **Value equivalence**. For primitive types, such as numbers, booleans, and strings, we can use the `==` and `===` operators to test for value equivalence:

  ```ts
  42 === 42;
  // true

  true === true;
  /// true

  const a = "foo";
  const b = "foo";

  a === b;
  // true

  "foo" === "bar";
  // false
  ```

  That is, two values or bindings are equal if their values are the same.

  Keep in mind that the `==` operator attempts to convert between different types of values and so might produce unexpected results:

  ```ts
  "42" == 42;
  // true
  ```

  For this reason, you'll never see this operator used in Alfa.

- **Referential equivalence**. For object types, which encompass all the non-primitive types, the `==` and `===` operators instead test for referential equivalence:

  ```ts
  [1, 2, 3] === [1, 2, 3];
  // false

  const a = { foo: 42 };
  const b = { foo: 42 };

  a === b;
  // false

  a === a;
  // true
  ```

  That is, two values or bindings are equal if they _reference_ the same object.

The problem with the `==` and `===` operators is that they force us to use value equivalence for primitive types and referential equivalence for object types.

Often times, what we really want is to use _structural equivalence_ for object types, that is consider two values or bindings as equal if the _structure_ of their values are also equal. For arrays, this means testing if the arrays have the same length and if their elements are pairwise equal. For objects, this means testing if the objects have the same set of properties and if the properties are pairwise equal.

For this reason, the `@siteimprove/alfa-equatable` package defines the `Equatable` interface with a single method, `#equals()`, that determines if the implementing class is equal to a given value:

```ts
import { Equatable } from "@siteimprove/alfa-equatable";

class Foo implements Equatable {
  readonly value: number;

  constructor(value: number) {
    this.value = value;
  }

  equals(value: Foo): boolean;

  equals(value: unknown): value is this;

  equals(value: unknown): boolean {
    return value instanceof Foo && value.value === this.value;
  }
}

const a = new Foo(42);
const b = new Foo(42);

a === b;
// false

a.equals(b);
// true
```

Additionally, the companion namespace of the `Equatable` interface defines the `Equatable.equals()` function which can be used for testing unknown values for equivalence, making use of `Equatable#equals()` if either of the values being tested implement `Equatable`:

```ts
Equatable.equals("foo", "foo");
// true

Equatable.equals(a, b);
// true
```

### Comparisons

Similar to the `==` and `===` operators used for testing equivalence, JavaScript also provides operators for comparing values: `<`, `>`, `<=`, and `>=`. These operators perform an [abstract relational comparison][], which we won't go into details with. Suffice to say, it's... complicated. It mostly works as you'd expect when dealing with numbers, booleans, and strings, but gives surprising results for object types:

```ts
{} < {};
// false

{} <= {};
// true
```

To work with objects that can be compared, the `@siteimprove/alfa-comparable` package defines a `Comparable` interface with a single method, `#compare()`, that determines if the implementing class is less than, equal to, or greater than a given value:

```ts
import { Comparable, Comparison } from "@siteimprove/alfa-comparable";

class Foo implements Comparable<Foo> {
  readonly value: number;

  constructor(value: number) {
    this.value = value;
  }

  compare(value: Foo): Comparison {
    if (this.value < value.value) {
      return Comparison.Less;
    }

    if (this.value > value.value) {
      return Comparison.Greater;
    }

    return Comparison.Equal;
  }
}

const a = new Foo(42);
const b = new Foo(21);

a.compare(b);
// Comparison.Greater

b.compare(a);
// Comparison.Less

a.compare(a);
// Comparison.Equal
```

Additionally, the companion namespace of the `Comparable` interface defines the `Comparable.compare()` function which can be used comparing strings, numbers, booleans, and values implementing `Comparable`:

```ts
Comparable.compare("a", "b");
// Comparison.Less

Comparable.compare(2, 1);
// Comparison.Greater

Comparable.compare(true, true);
// Comparison.Equal

Comparable.compare(a, b);
// Comparison.Greater
```

### Hashing

In the design section, we briefly touched on a conceptual difference between the builtin `Map<K, V>` class and the `Map<K, V>` class from the `@siteimprove/alfa-map` package; the former is mutable while the latter is immutable. Another, and perhaps more important, difference is how the two deal with equivalence.

Recall from a couple of sections back when we talked about equivalence: For object types, the `==` and `===` operators force us to use referential equivalence. The builtin `Map<K, V>` is no different and so we cannot use the _structure_ of an object as the key in a `Map<K, V>`:

```ts
const map = new Map<{ foo: number }, number>();

map.set({ foo: 42 }, 42);

map.get({ foo: 42 });
// undefined
```

Instead, we can only use the _reference_ to an object as the key in a `Map<K, V>`:

```ts
const foo = { foo: 42 };

map.set(foo, 42);

map.get(foo);
// 42
```

To get around this limitation, the `Map<K, V>` class from the `@siteimprove/alfa-map` package uses the `Equatable.equals()` function for testing equivalence of keys.

This only solves half the puzzle, however. As `Map<K, V>` relies on hashing for efficiently storing and retrieving values, it also needs a way of computing hash values for object types. What's more, these hash values need to hold the property that if `Equatable.equals(a, b)` is `true` then the hash value of `a` must equal that of `b`.

To this end, the `@siteimprove/alfa-hash` package defines a `Hashable` interface with a single method, `#hash()`, that determines how to hash the implementing class:

```ts
import { Equatable } from "@siteimprove/alfa-equatable";
import { Hash, Hashable } from "@siteimprove/alfa-hash";

class Foo implements Equatable, Hashable {
  readonly value: number;

  constructor(value: number) {
    this.value = value;
  }

  equals(value: Foo): boolean;

  equals(value: unknown): value is this;

  equals(value: unknown): boolean {
    return value instanceof Foo && value.value === this.value;
  }

  hash(hash: Hash): void {
    hash.writeNumber(this.value);
  }
}
```

Our example also provides an implementation of `Equatable` which is required for the aforementioned property to hold. With these two implementations in place, we can do the following:

```ts
import { Map } from "@siteimprove/alfa-map";

const map = Map.empty<Foo, number>().set(new Foo(42), 42);

map.get(new Foo(42));
// 42
```

It's worth pointing out that if we _don't_ implement `Equatable` and `Hashable` for our type, `Map<K, V>` will use referential equivalence and a unique hash value will be assigned to every object, ensuring that the aforementioned property holds.

The observant reader may have noticed that the `Hash` class deviates from the API design outlined previously. The reason for this is rather simple and boils down to performance. Hashes are meant to encode large amounts of data in constant space, and having to allocate a new object for every little piece of data we want to add serves counter to that purpose.

### Serialization

JSON serialization is another common piece of functionality and is supported via the builtin [`toJSON()`][tojson] method. This method is called by `JSON.stringify()` when converting values to JSON:

```ts
class Foo {
  readonly value: number;

  constructor(value: number) {
    this.value = value;
  }

  toJSON(): number {
    return this.value;
  }
}

const foo = new Foo(42);

foo.toJSON();
// 42

JSON.stringify(foo);
// "42"
```

While this works, it's possible for the `toJSON()` method to return values that _cannot_ be represented as JSON, such as an anonymous function:

```ts
class Foo {
  readonly value: number;

  constructor(value: number) {
    this.value = value;
  }

  toJSON() {
    return () => this.value;
  }
}

const foo = new Foo(42);

foo.toJSON();
// () => this.value

JSON.stringify(foo);
// undefined
```

To ensure that all JSON serialization methods are valid, the `@siteimprove/alfa-json` package defines the `Serializable` interface with a single method, `#toJSON()`, that requires the implementing class to return valid JSON as defined by the `JSON` type of the same package:

```ts
import { Serializable } from "@siteimprove/alfa-json";

class Foo implements Serializable<Foo.JSON> {
  readonly value: number;

  constructor(value: number) {
    this.value = value;
  }

  toJSON(): Foo.JSON {
    return this.value;
  }
}

namespace Foo {
  export type JSON = number;
}

const foo = new Foo(42);

foo.toJSON();
// 42

JSON.stringify(foo);
// "42"
```

Another feature of the `Serializable` interface is that it allows us to infer the type of the resulting JSON serialization of container types, such as `Map<K, V>`:

```ts
const map = Map.empty<Foo, string>().set(new Foo(42), "42");

map.toJSON();
// Array<[number, string]>
```

That is, `#toJSON()` knows that `Foo` will serialize to `number` and that `string` will serialize as-is.

In Alfa, JSON serialization is often used as a means of asserting the structure of an object as it can be difficult to spot differences in expected and actual structure if deeply comparing the internals of the object.

### Collections

We've already seen quite a bit about the `@siteimprove/alfa-map` package and its `Map<K, V>` class. The `Map<K, V>` class is, however, just one out of several collections used throughout Alfa. In this section, we'll provide an overview of the most common collections and their intended use. As with any data structures, they each have their own strengths and weaknesses to be mindful of when choosing a collection for a given task.

#### `Collection.Indexed<T>`

##### `List<T>`

The `List<T>` class provides an implementation of a [persistent][] [vector trie][] for storing a list of values of type `T`. It provides effectively constant time `#append()`, `#set()`, and `#get()`.

For values, `List<T>` uses an implementation of `Equatable`, when available. That is, no modifications are made when updating the value at a given index with the current value `a` and the new value `b` if `a.equals(b)`.

**Do use when:**

- You're primarily appending new values to, updating existing values in, or repeatedly removing the last value from the list.

**Don't use when:**

- You're often inserting values either at the begging of or in the middle of the list, especially if it's large.

- You're dealing with performance critical code, which might be better served by the builtin `Array<T>` class.

- You're only interested in a few values of the list, which might be better served by the `Sequence<T>` class.

##### `Sequence<T>`

The `Sequence<T>` class provides an implementation of a [persistent][] [lazy][] list for storing a possibly infinite sequence of values of type `T`. By virtue of being lazy, it provides mostly constant time operations as no computations are actually performed until the corresponding values are requested.

**Do use when:**

- You're performing sequence operations on an arbitrary and possible infinite `Iterable<T>`. This includes generator functions, which can be beneficial to wrap in a `Sequence<T>`.

- You're working with a sequence of values that don't all need to be determined at once. Using `Sequence<T>`, such sequences can be constructed in constant time and only the needed values yielded as necessary.

- You're performing sequence operations where eager evaluation would lead to suboptimal performance, such as `#map()` followed by `#find()`. With eager evaluation, `#map()` will be applied to _every_ value of the sequence, even those _after_ the value returned by `#find()`. With lazy evaluation, `#map()` will only be applied _up to and including_ the value returned by `#find()`.

**Don't use when:**

- You're often modifying the sequence which for each modification, with the exception of prepends, is done in time proportional to the number of values yielded by the sequence.

##### `Slice<T>`

The `Slice<T>` class provides an implementation of a [persistent][] [copy-on-write][] array for storing values of type `T`. It provides constant time `#get()`, `#has()`, and `#slice()`.

**Do use when:**

- You're working with increasingly smaller portions of a backing array, such as when parsing a list of tokens.

**Don't use when:**

- You're working with performance critical code, which may be better served by manually tracking a pointer into the backing array.

#### `Collection.Keyed<K, V>`

##### `Map<K, V>`

The `Map<K, V>` class provides an implementation of a [persistent][] [hash trie][] for associating unique keys of type `K` with values of type `V`. It provides effectively constant time `#set()`, `#has()`, `#get()`, and `#delete()`.

For keys, `Map<K, V>` uses implementations of `Equatable` and `Hashable`, when available. That is, two keys `a` and `b` are considered the same key if `a.hash().equals(b.hash())` and `a.equals(b)`.

For values, `Map<K, V>` uses an implementation of `Equatable`, when available. That is, no modifications are made when updating the value of a key with the current value `a` and the new value `b` if `a.equals(b)`.

**Do use when:**

- Your keys have custom equivalence and hashing constraints.

**Don't use when:**

- You're working with performance critical code, which may be better served by the builtin `Map<K, V>` or `WeakMap<K, V>` class.

#### `Collection.Unkeyed<T>`

##### `Set<T>`

The `Set<T>` class provides an implementation of a [persistent][] [hash trie][] for storing a set of unique values of type `K`. It provides effectively constant time `#add()`, `#has()`, and `#delete()`.

For values, `Set<T>` uses implementations of `Equatable` and `Hashable`, when available. That is, two values `a` and `b` are considered the same value if `a.hash().equals(b.hash())` and `a.equals(b)`.

**Do use when:**

- Your values have custom equivalence and hashing constraints.

**Don't use when:**

- You're working with performance critical code, which may be better served by the builtin `Set<T>` or `WeakSet<T>` class.

[abstract relational comparison]: https://tc39.es/ecma262/#sec-abstract-relational-comparison
[copy-on-write]: https://en.wikipedia.org/wiki/Copy-on-write
[goals]: ../README.md#goals
[hash trie]: https://idea.popcount.org/2012-07-25-introduction-to-hamt/
[lazy]: https://en.wikipedia.org/wiki/Lazy_evaluation
[package overview]: api/index.md#packages
[persistent]: https://en.wikipedia.org/wiki/Persistent_data_structure
[readme]: ../README.md
[referential transparency]: https://en.wikipedia.org/wiki/Referential_transparency
[tojson]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior
[usage]: ../README.md#usage
[vector trie]: https://hypirion.com/musings/understanding-persistent-vector-pt-1

repository: Siteimprove/alfa

branch_name: refs/heads/main

gha_language: TypeScript

repo_name: Siteimprove/alfa


text:
# homebrew-datamade

These formulae provide software created by DataMade, including:

- [`run-one`](https://github.com/datamade/run-one): Run one instance of a unique combination of command and args at a time

## How do I install these formulae?

Just `brew tap datamade/datamade` and then `brew install <formula>`.

You can also install via URL:

```bash
brew install https://raw.githubusercontent.com/datamade/homebrew-datamade/master/<formula>.rb
```

## Docs

brew help, man brew, or the Homebrew wiki.

repository: datamade/homebrew-datamade

repo_name: datamade/homebrew-datamade


text:
# Machine code to bitcode: the life of an instruction

This document describes how machine code instructions are lifted into LLVM bitcode. It should provide a detailed, inside-out overview of how McSema performs binary translation. This document omits some important steps, so consulting the [Navigating the code](NavigatingTheCode.md) document will be helpful.

### Running example

This document will use the instructions in the following basic block as a running example.

![Sample basic block](images/instruction_life_block.png)

## Step 1: CFG protocol buffer representation

The first step to lifting involves getting the machine code instructions of some binary file into a format the McSema understands. These files are generated with the help of external tools for program disassembly (IDA Pro) so that McSema doesn't need to understand the many executable file formats.

The file format used by McSema is a [CFG protocol buffer](/mcsema/CFG/CFG.proto). This file is produced using the [`mcsema-disass`](/mcsema/tools/mcsema_disass) tool. The CFG file for the above code block contains the following data.

```protobuf
Module {
  internal_funcs = [
    Function {
      entry_address = 0x804b7a3;
      symbol_name = "sub_804b7a3";
      local_noreturn = true;
      blocks = [
          Block {
            base_address = 0x804b7a3;
            block_follows = [ ];
            insts = [

              // mov    eax, 0x1
              Instruction {
                inst_addr = 0x804b7a3;
                inst_len = 5;
                inst_bytes = "\xb8\x01\x00\x00\x00";
              },

              // push   ebx
              Instruction {
                inst_addr = 0x0804b7a8;
                inst_len = 1;
                inst_bytes = "\x53";
              },

              // mov    ebx, dword [esp+0x8]
              Instruction {
                inst_addr = 0x0804b7a9;
                inst_len = 4;
                inst_bytes = "\x8b\x5c\x24\x08";
              },

              // int    0x80
              Instruction {
                inst_addr = 0x0804b7ad;
                inst_len = 2;
                inst_bytes = "\xcd\x80";
              } ];
          } ];
    } ];
  ...
}
```

## Step 2: Lifting to bitcode

The second step, which is really a few steps, is to decode the CFG file and produce one LLVM bitcode function for every `Function` message into the CFG file. Below is a portion of the *unoptimized* bitcode produced for the above function.

```llvm
; Function Attrs: noinline
define void @sub_804b7a3(%RegState*) #1 {
entry:
  %EIP_write = bitcast i32* %RIP_read to i32*
  %EIP_read = bitcast i32* %EIP_write to i32*
  ...
  %EAX_read = bitcast i32* %EAX_write to i32*
  %AX_write = bitcast i32* %EAX_read to i16*
  %AX_read = bitcast i16* %AX_write to i16*
  %AL_write = bitcast i16* %AX_read to i8*
  %AL_read = bitcast i8* %AL_write to i8*
  %AH_write = getelementptr inbounds i8, i8* %AL_read, i32 1
  %AH_read = bitcast i8* %AH_write to i8*
  ...
  %EBX_write = bitcast i32* %RBX_read to i32*
  %EBX_read = bitcast i32* %EBX_write to i32*
  ...
  %ESP_write = bitcast i32* %RSP_read to i32*
  %ESP_read = bitcast i32* %ESP_write to i32*
  %SP_write = bitcast i32* %ESP_read to i16*
  %SP_read = bitcast i16* %SP_write to i16*
  ...
  ...
  %ZF_write = getelementptr inbounds %RegState, %RegState* %0, i32 0, i32 20
  %ZF_read = bitcast i8* %ZF_write to i8*
  %SF_write = getelementptr inbounds %RegState, %RegState* %0, i32 0, i32 21
  ...
  %ST0_write = getelementptr inbounds %RegState, %RegState* %0, i32 0, i32 24
  %ST0_read = bitcast x86_fp80* %ST0_write to x86_fp80*
  ...
   They are named according to the `entry_address` field in the `Function` message. The `entry_address` of our example function is `0x804b7a3`, and so the lifted function is named `sub_804b7a3`.

All lifted functions accept a single argument: a pointer to a [`RegState`](/mcsema/Arch/X86/Runtime/State.h) structure. The `entry` block of the function is filled with a series of `getelementptr` and `bitcast` instructions. These instruction index into the fields of the `RegState` structure.

Each field in the `RegState` structure produces at least two variables in the bitcode. These register variants are created by the `ArchAllocRegisterVars` function. In the case of X86, this architecture-neutral function is implemented using the [`X86AllocRegisterVars`](/mcsema/Arch/X86/Register.cpp) function.

Some registers have more derived registers than others. On one end, we have the FPU stack registers like `RegState::ST0` that have only one `_read` and `_write` variant. At the other extreme, we have `RegState::RAX`, which is associated with `RAX_read`, `RAX_write`, `EAX_read`, `EAX_write`, `AX_read`, `AX_write`, `AH_read`, `AH_write`, `AL_read`, and `AL_write`. All of the variants are made available in every lifted function prologue, and a subset of them will usually be used by the semantics bitcode.

We can see the `_read` and `_write` variants of the register variables in action below in the translation of the `push ebx` instruction. This bitcode is produced using the [`doPushR`](/mcsema/Arch/X86/Semantics/Stack.cpp) function.

```llvm
  %1 = load i32, i32* %EBX_read           ; read EBX
  %2 = load i32, i32* %ESP_read           ; read ESP
  %3 = sub i32 %2, 4                      ; decrement ESP
  %4 = inttoptr i32 %3 to i32*            ; cast ESP to a pointer
  store i32 %1, i32* %4                   ; store EBX to the stack
  store volatile i32 %3, i32* %ESP_write  ; write back the new ESP
```

The `_read` and `_write` variants aren't very important for 32-bit code, but come up a lot in 64-bit code. For example, a write to `EAX` in 64-bit code clears the high 32-bits of the `RAX` register. Therefore, in 64-bit code, the `EAX_write` variable is a pointer to the whole 64-bit value of `RegState::RAX`.

Later on we see a call to the `syscall` function. This was generated in the semantics translation function [`doInt`](/mcsema/Arch/X86/Semantics/Misc.cpp) using the following code:.

```c++
  ...
  if (0x80 == interrupt_val && llvm::Triple::Linux == os) {
    ...
    auto syscall_func = M->getOrInsertFunction("syscall", syscall_func_ty);

    std::vector<llvm::Value *> args = {
      R_READ<32>(b, llvm::X86::EAX),  // %9 = load i32, i32* %EAX_read
      R_READ<32>(b, llvm::X86::EBX),  // %10 = load i32, i32* %EBX_read
      R_READ<32>(b, llvm::X86::ECX),  // %11 = load i32, i32* %ECX_read
      R_READ<32>(b, llvm::X86::EDX),  // %12 = load i32, i32* %EDX_read
      R_READ<32>(b, llvm::X86::ESI),  // %13 = load i32, i32* %ESI_read
      R_READ<32>(b, llvm::X86::EDI),  // %14 = load i32, i32* %EDI_read
      R_READ<32>(b, llvm::X86::EBP),  // %15 = load i32, i32* %EBP_read
    };

    // %16 = call i32 (i32, ...) @syscall(i32 %9, ..., i32 %15)
    auto ret = llvm::CallInst::Create(syscall_func, args, "", b);

    // store volatile i32 %16, i32* %EAX_write
    R_WRITE<32>(b, llvm::X86::EAX, ret);

    return ContinueBlock;
  }
```

We can see parallels between the bitcode above and the C++ code implementing the semantics of the `int 0x80` instruction. First, this instruction is interpreted as a system call, but only on Linux. Second, we can see that every call to the `R_READ` function is associated with a `load` from a `_read`-suffixed register variable. Third, we can see that a call to the `R_WRITE` function is associated with a `store` to a `_write`-suffixed register variable.

The translation function ends with a `return ContinueBlock`, which instructions McSema to keep lifted the remaining instructions of the basic block. Yet we see an `unreachable` instruction in the bitcode. Why?

`mcsema-disass` was smart enough to recognize that this particular `int 0x80` system call does not return. Therefore, it marked the `Function` message with `local_noreturn` as `true`. The `Block` containing the `int 0x80` has no successors (`block_follows` is empty), and the `int 0x80` is the last instruction, and so McSema recognized that it should add in an `unreachable` instruction to mark this block as not returning.

### Optimizing the bitcode

The bitcode produced for this particular example expresses the semantics clearly, and is not overly complicated. This particular example did not involve any "interesting" instructions.

Many x86 instructions implicitly modify the [`FLAGS`](https://en.wikipedia.org/wiki/FLAGS_register) register, and McSema models these changes in the bitcode. Often there will be a series of such instructions, and so those behind-the-scenes flag register computations will be "dead."

```assembly
add eax, 1
sub ebx, 1
```

In the above example, both `sub` instructions modify the x86 `FLAGS` register. The updates to the flags register performed by `add` instruction are clobbered by those performed by the `sub` instruction. Eliminating these unnecessary computations can be tricky and involves complex alias analysis.

`mcsema-lift` includes a sophisticated whole-program dead register computation elimination optimization. This optimization, which can be disabled with `-disable-global-opt`, will annotate the lifted bitcode with LLVM's `!alias.scope` and `!noalias` metadata, and it will perform load-forwarding, dead-store elimination, and `store-to-load` forwarding.

## Closing remarks

This document gives a low level view as to what the machine code will look like as bitcode. This is only part of the picture, though. The instructions in our example did not perform any complex control-flow, register computations, or access to global data structures. Not to worry though, McSema also handles these complications.

repository: rainoftime/mcsema

repo_name: rainoftime/mcsema


text:
# GoldenHammer

### Compiling GoldenHammer

Windows: `.\build.cmd`
Linux: `./build.sh`
macOS: `./build.sh`

### Publishing a Release

1. Write draft release notes for the release in `DRAFT_RELEASE.md`
    > If you have [Github-changelog-generator](https://skywinder.github.io/github-changelog-generator/) installed, use [this script](https://gist.github.com/TomGillen/1dbca055a3d582178af40402e8ae15a8) to create `DRAFT_RELEASE.md`.
2. Once happy with the release, call `.\build TagRelease` to create release tag. Push this tag via `git push --follow-tags` to publish the release.
3. Use [this script](https://gist.github.com/TomGillen/62ee9572cd19b40c471f66591e246f9b) to convert these tags into Github releases.
4. Rebuild via `.\build` to create a new NuGet package with updated release metadata.

repository: forki/GoldenHammer

repo_name: forki/GoldenHammer


text:
---
authorName: Robin Fairbridge Gaskell
canDelete: false
contentTrasformed: false
from: Robin Fairbridge Gaskell<EMAIL_ADDRESS>headers.inReplyToHeader: PDQzMDM1RjcyLjAwMDAwMy4wMjAwMEB2LTZ6bW52cnBxdzJjYnk+
headers.messageIdInHeader: PDYuMS4yLjAuMC4yMDA1MDgxOTE4Mjc1Ny4wMmZmM2RiMEBwby5wYWNpZmljLm5ldC5hdT4=
headers.referencesHeader: PDQyRkVEQUY3LjAwMDAzRi4wMTk5NkB2LTZ6bW52cnBxdzJjYnk+IDw0MzAzNUY3Mi4wMDAwMDMuMDIwMDBAdi02em1udnJwcXcyY2J5Pg==
layout: email
msgId: 574
msgSnippet: '... Well,Sorry Nik, I guess I made an incorrect assumption.  I ve probably
  got a bit touchy over time with people sniping at Glosa.  In the past I especially '
nextInTime: 575
nextInTopic: 576
numMessagesInTopic: 10
postDate: '1124442051'
prevInTime: 573
prevInTopic: 572
profile: robynge2000
replyTo: LIST
senderId: sYaXZ2Tssh47Bn7fRd1OE0OAzmKKYp8EQD1ppvq9iKGvcVdWlguyNGOlM3Js_HM2bbxZ-wpTP8rotFdLAKzCm553hpTPzdk9WWNReW5sG994QtgfWYu6TCwoUS6SREbc
spamInfo.isSpam: false
spamInfo.reason: '12'
systemMessage: false
title: 'Re: [glosalist] Hello all!'
topicId: 566
userId: 147970330
---

At 02:01 AM 8/18/05, Nikhil Sinha pa grafo:
>Well the only reason I could not learn Glosa is I did not get the
>opportunity and time.
>
>Yes and I do like to learn about complicated languages but when it comes to
>language-learning I wud prefer simpler ones.
Well,Sorry Nik,
     I guess I made an incorrect assumption.  I've probably got a bit
touchy over time with people sniping at Glosa.  In the past I especially
got annoyed, though I never said anything about it, over people who made
comments about Glossa.  I know That Ron Clark took his initiative from
Hogben's Interglossa, and didn't start  work on Glosa until after he'd got
permission from Hogben to continue the work he had already done on
Interglossa.  In the early days, the authors had called the new language,
Glossa; but in line with Ron and Wendy's policy of avoiding the use of
double-letters, the name was updated.  Unfortunately the brains of some of
the linguists studying designed languages failed to make the upgrade.

      And just a historical point on that: the two languages, Glosa and
Interglossa, do not look as similar as we might have thought; this is
explained by the fact that, although Ron did try very hard to develop
Hogben's scheme, he simply found it was not workable as it was, so he
decided to go back to ^square one^ and start again from first
principles.  The Glosa first principle were, however, quite close to those
of Interglossa, but somewhat more streamlined.

      I wondered how many of our readers have thought about the idea of a
language that has its grammar shown through its syntax.  This is the
premise behind Glosa, and one that has had very little discussion.  While a
number of people have suggested throwing out a some of Glosa's basic
tenets, and adding complication, very few Glosa-pe have actually used the
word "syntax," and considered researching further the refinements of syntax
in human communication.

      So, for this reason, Nik, I would raise this question with you ...
and anyone else who wishes to comment on it: have you had any thoughts
about syntax as a common denominator in language (and communication) and as
a principle suitable for basing an auxillary language on?

      Without trying to be rude, I suspect that syntax is an area of
linguistic research that professional Linguists have rather avoided up to now.

Saluta,

Robin

repository: fiasinstitute/glosa

gha_language: HTML

repo_name: fiasinstitute/glosa


text:
# API Review 2015-08-27

This API review was also recorded and is available on Google+:

* [Part 1]
* [Part 2]

[part 1]: https://plus.google.com/events/ccj5m9oheonldrlp2hg59mhevtk
[part 2]: https://plus.google.com/events/c3bs3mqme23isi005bhlcv6nu68

## Overview

In this API review we reviewed [a proposal](NET API FullPath Proposal.md).

## .NET API Proposal for handling full paths

Status: **Design in progress** |
[Video 1][part 1] |
[Video 2][part 2]

* Apps that are broken today, will continue to be broken regardless of whether
  we fix that issue or not.
* No risk of causing buffer overruns as the Win32 APIs already take buffer sizes
  and apps pass in `MAX_PATH`, which will cause them to get "buffer too small"
  error.
* The Win32 API `GetFinalPath` fixes casing issues. It seems we need a new API
  that allows us to get the canonical path that hits the disk and follows links
  and fixes casing
* Should `GetFullPath` expand short file names (xxxx~x) to long names?
    - It might be better to move this stuff to this new API instead of
      doing this from `GetFullPath`
    - *Note:* this might be a behavioral breaking change in .NET Framework

repository: dotnet/apireviews

repo_name: dotnet/apireviews


text:
># Jump Statements

Java supports three jump statements: `break`, `continue`, and `return`. These statements transfer control to another part of your program.

## break Statement

In Java, the `break` statement has three uses.

* It terminates a statement sequence in a `switch` statement.
* It can be used to exit a loop.
* It can be used as a “civilized” form of goto.

### Using break to Exit a Loop

`break` Statement is a loop control statement which is used to terminate the loop. As soon as the `break` statement is encountered from within a loop, the loop iterations stops there and control returns from the loop immediately to the first statement after the loop.

##### [Example 01](../20-Examples/07-Control-Statements/04-Jump-Statements/Example-01/)

```java
// Using break to exit a loop.
class BreakLoop {
    public static void main(String args[]) {
        for(int i=0; i<100; i++) {
            if(i == 10)
                break; // terminate loop if i is 10
            System.out.println("i: " + i);
        }
        System.out.println("Loop complete.");
    }
}
```

##### Output

    i: 0
    i: 1
    i: 2
    i: 3
    i: 4
    i: 5
    i: 6
    i: 7
    i: 8
    i: 9
    Loop complete.

The `break` statement can be used with any of Java’s loops, including intentionally infinite loops.

When used inside a set of nested loops, the `break` statement will only break out of the innermost loop.

### Using break as a Form of Goto

By using this form of `break`, you can, for example, break out of one or more blocks of code. These blocks need not be part of a loop or a `switch`. They can be any block. Further, you can specify precisely where execution will resume, because this form of `break` works with a label.

##### [Example 02](../20-Examples/07-Control-Statements/04-Jump-Statements/Example-02/)

```java
// Using break as a civilized form of goto.
class Break {
    public static void main(String args[]) {
        boolean t = true;
        first: {
            second: {
                third: {
                    System.out.println("Before the break.");
                    if(t)
                        break second; // break out of second block
                    System.out.println("This won't execute");
                }
                System.out.println("This won't execute");
            }
            System.out.println("This is after second block.");
        }
    }
}
```

##### Output

    Before the break.
    This is after second block.

##### [Example 03](../20-Examples/07-Control-Statements/04-Jump-Statements/Example-03/)

```java
// Using break to exit from nested loops
class BreakLoop {
    public static void main(String args[]) {
        outer: for(int i=0; i<3; i++) {
            System.out.print("Pass " + i + ": ");
            for(int j=0; j<100; j++) {
                if(j == 10)
                    break outer; // exit both loops
                System.out.print(j + " ");
            }
            System.out.println("This will not print");
        }
        System.out.println("Loops complete.");
    }
}
```

##### Output

    Pass 0: 0 1 2 3 4 5 6 7 8 9 Loops complete.

## continue Statement

Sometimes it is useful to force an early iteration of a loop. That is, you might want to continue running the loop but stop processing the remainder of the code in its body for this particular iteration.

The `continue` statement performs such an action. In `while` and `do-while` loops, a continue statement causes control to be transferred directly to the conditional expression that controls the loop. In a `for` loop, control goes first to the iteration portion of the `for` statement and then to the conditional expression.

##### [Example 04](../20-Examples/07-Control-Statements/04-Jump-Statements/Example-04/)

```java
// Demonstrate continue.
class Continue {
    public static void main(String args[]) {
        for(int i=0; i<10; i++) {
            System.out.print(i + " ");
            if (i%2 == 0)
                continue;
            System.out.println("");
        }
    }
}
```

##### Output

    0 1
    2 3
    4 5
    6 7
    8 9

As with the `break` statement, `continue` may specify a label to describe which enclosing loop to continue.

##### [Example 05](../20-Examples/07-Control-Statements/04-Jump-Statements/Example-05/)

```java
// Using continue with a label.
class ContinueLabel {
    public static void main(String args[]) {
        outer: for (int i=0; i<10; i++) {
            for(int j=0; j<10; j++) {
                if(j > i) {
                    System.out.println();
                    continue outer;
                }
                System.out.print(" " + (i * j));
            }
        }
        System.out.println();
    }
}
```

##### Output

    0
    0 1
    0 2 4
    0 3 6 9
    0 4 8 12 16
    0 5 10 15 20 25
    0 6 12 18 24 30 36
    0 7 14 21 28 35 42 49
    0 8 16 24 32 40 48 56 64
    0 9 18 27 36 45 54 63 72 81

## External Sources

### Readings

* JavaTPoint
  * [break](https://www.javatpoint.com/java-break)
  * [continue](https://www.javatpoint.com/java-continue)
* Beginners Book
  * [break](https://beginnersbook.com/2017/08/java-break-statement/)
  * [continue](https://beginnersbook.com/2017/08/java-continue-statement/)
* GeeksForGeeks
  * [break](https://www.geeksforgeeks.org/break-statement-in-java/)
  * [continue](https://www.geeksforgeeks.org/break-and-continue-statement-in-java/)

repository: DevCANS/Java-A-to-Z-Resources

gha_language: Java

repo_name: DevCANS/Java-A-to-Z-Resources


text:
Rawr 1.4.3
==========

James Britt, Logan Barnett, David Koontz

http://github.com/rawr/rawr

DESCRIPTION
-----------

Rawr is a packaging solution for JRuby applications. Rawr comes in two
pieces:

* a `rawr` command that creates a Java `main` file in your application
and a configuration file that will be used by Rawr to build the final jar;
* a Rake task file that you can include into your project's Rakefile to
automate the creation of the packaged application.

SYNOPSIS
--------

    rawr install
    rake rawr:jar
    java -jar package/jar/your_jar_file.jar

REQUIREMENTS
------------

* JRuby >= 1.4
* javac
* Rake

INSTALL
-------

    sudo gem install rawr

STUFF
-----

`Rawr` 1.4.2 introduces the use of Brian Marick's [user-choices](http://user-choices.rubyforge.org/)  library to handle initial configuration properties.

What this means in practice is that there are multiple ways to configure how `rawr` handles the `install` command.

You can use command-line arguments much as before, or use a configuration file (`~/.rawr`), or environment variables.

Or all of them; you can mix and match.

For example, if you have a prefered name or location for the main Java class then you might want to stick that in the config
file or some environment variables to avid having to pass them as command-line arguments on each invocation of `rawr`.

Please read the docs for `user-choices`, but one key thing to know is the precedence for options.

Any option value passed on the command-line overrules any previous value.

Any option defined in an environment variable overrules the value in a config files.

Option values in the config file will be used so long as they are not overridden by the above conditions.

LICENSE
-------

Rawr is released under the Ruby License.

license: Ruby

repository: swerner/rawr

repo_name: swerner/rawr


text:
---
layout: default
---

# 1997-08-11 - Dr. McVeigh / Re: A peculiar notion

## Header Data

From: TruthMailer<EMAIL_ADDRESS>To<EMAIL_ADDRESS>Message Hash: 25c79b9d89ddebf920a8be13b5d4fa7ac0e3d173709bf5d5261d2ce102a2e255

Message ID<EMAIL_ADDRESS>Reply To: _N/A_

UTC Datetime: 1997-08-11 07:10:00 UTC

Raw Date: Mon, 11 Aug 1997 15:10:00 +0800

## Raw message

```
{% raw  %}From: TruthMailer<EMAIL_ADDRESS>Date: Mon, 11 Aug 1997 15:10:00 +0800
To<EMAIL_ADDRESS>Subject: Dr. McVeigh / Re: A peculiar notion
Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text/plain

David D.W. Downey wrote:
> Steve Schear wrote:
> > In short, the Constitution itself was a casualty of >Lincoln's war. A Pyrrhic victory indeed.
> >
>         For the first time in a long time, I've read a post that actually make
> me seriously consider rethinking what I have been taught. I've studied
> quite a bit in regards to US law and the Consitution, (made necessary by
> my being Pro-PGP), and never looked in that direction. Your post adds a
> very different light to things.
> Thank you for the push.

  I also thought that it was one of the more thought-provoking posts
in a while, but I would certainly never send a polite, thankful post
to the list, saying so.
  My "CypherPissing" mail folder turned out to be genetically related
to the plant in "Little Shop of Horrors" and, the larger it gets, the
more it demands to be fed. In order to provide it with enough of the
sewage-supplement it needs to keep from eating my "cat" command, I
may have to send a post to the list praising Sandy Sandfort, Chris
Lewis, and blessing Armenians everywhere.
(I have tried remailing old ASCII-art spams to myself, but it refuses
to eat left-overs.)

  (Perhaps I can get my "CypherPissing" folder a few snacks to munch
on, in the meantime, by seeing if praising Tim McVeigh is still good
enough bait to get a few nibbles. "Suckers" taste pretty good, if
you "smoke" 'em.)

  Anyway...
  There are some concepts and arguments that "chip away" at an assumed
belief or a train of logic, and there are those that knock down a load-
bearing support column.
  The Joseph Sobran piece which Steve posted to the list could, with
a proper "primer," do the kind of damage to our view of Civil War
history as the OKC bomb did to the Murrah Federal Building. Come to
think of it, maybe McVeigh _was_ the primer for explosive new views
of why Federalism is quickly becoming indistinguishable from Fascism.
  The advantage that literature has over black powder is that it is
reusable and doesn't leave as big a mess to clean up. The advantage
that black powder has over literature is that it makes enough noise
to get the message to the blind, as well, and sometimes even restores
the sight of the blind.
{Warning: Since the side-effects of Black Powder can be substantial,
 it should only be used in cases where the physician has determined
 that the benefits of "treatment" outweigh the risks.
 Dr. McVeigh's surgery in OKC falls into the category of private
 research (even if he did receive some government funding). However,
 follow-up research by others may lead to McVeigh's technique being
 improved and perhaps gaining enough recognition to make it standard
 paramedical procedure.}

TruthMonger

{% endraw %}
```

## Thread

+ Return to [August 1997](/archive/1997/08)

+ Return to "["David D.W. Downey" <admin@CyberSpaceTechnologies.com>](/authors/david_d_w_downey_admin_at_cyberspacetechnologies_com_)"
+ Return to "[Rabid Wombat <wombat@mcfeely.bsfs.org>](/authors/rabid_wombat_wombat_at_mcfeely_bsfs_org_)"
+ Return to "[TruthMailer <tm@dev.null>](/authors/truthmailer_tm_at_dev_null_)"

+ 1997-08-11 (Mon, 11 Aug 1997 15:10:00 +0800) - Dr. McVeigh / Re: A peculiar notion - _TruthMailer<EMAIL_ADDRESS>  + 1997-08-11 (Mon, 11 Aug 1997 20:11:52 +0800) - [Re: Dr. McVeigh / Re: A peculiar notion](/archive/1997/08/76433bc4b538d9d12abf3d623cd4efdeff2f501a45ac1d1ffcf661140c3d1adc) - _"David D.W. Downey"<EMAIL_ADDRESS>  + 1997-08-12 (Tue, 12 Aug 1997 08:51:37 +0800) - [Re: Dr. McVeigh / Re: A peculiar notion](/archive/1997/08/183c8184ee993be36c92cdf7980214bcc83df02e70791b828bc8bbfae0db6c0e) - _Rabid Wombat<EMAIL_ADDRESS>


text:
KantPHP Framework
=======

KantPHP Framework was a PHP framework for studying framework by DongZhu originally. It's developed since three years ago.

KantPHP Framework is now a rapid PHP Framework for developing web application using PHP5.3+. It's available  to download and use for free as Open Source,under the BSD 3-Clause license.

KantPHP Framework uses object-oriented code, but not utilises namely namespaces which will be included in the future versions.

KantPHP Framework has shadow of Zend Framework, CodeIgniter Web Framework, CakePHP Framework, ThinkPHP Framework and Other Framework or Code Which I picked up through my coding experiences.

Developers will find it's easy if having learned  framework, but low barrier to entry for beginnings too.

MVC Design Patterns of the framework helps you get more done with less effort, while writing a lot less code.
The framework also has support for plugins, as well as third party vendor libraries.

repository: bearlord/kantphp

repo_name: bearlord/kantphp


text:
---
layout: page
title: "JavaScript rad2deg function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/rad2deg:497
- /functions/view/rad2deg
- /functions/view/497
- /functions/rad2deg:497
- /functions/497
---
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's rad2deg

{% codeblock math/rad2deg.js lang:js https://raw.github.com/kvz/phpjs/master/functions/math/rad2deg.js raw on github %}
function rad2deg(angle) {
  //  discuss at: http://phpjs.org/functions/rad2deg/
  // original by: Enrique Gonzalez
  // improved by: Brett Zamir (http://brett-zamir.me)
  //   example 1: rad2deg(3.141592653589793);
  //   returns 1: 180

  return angle * 57.29577951308232; // angle / Math.PI * 180
}
{% endcodeblock %}

 - [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/math/rad2deg.js)

Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are
the closest match to this hashtable-like data structure.

Please also note that php.js offers community built functions and goes by the
[McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online
functions that are far from perfect, in the hopes to spark better contributions.
Do you have one? Then please just:

 - [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/math/rad2deg.js)

### Other PHP functions in the math extension
{% render_partial _includes/custom/math.html %}

extension: markdown

gha_license_id: NOASSERTION


text:
# openclinica_scripts
A place to put scripts relating to [OpenClinica](https://github.com/OpenClinica/OpenClinica). Some of these are listed on the [OpenClinica Extensions page](https://community.openclinica.com/extensions), or are mentioned in the [Wikibook](http://en.wikibooks.org/wiki/OpenClinica_User_Manual).

## [OC_XML_to_SAS_R_CSV](OC_XML_to_SAS_R_CSV)
XSL transformations for converting data from an ODM 1.3 XML into CSV, R, SAS and Access.

## [accessdatamart](accessdatamart)
Access database and accompanying scripts for building an SQL data mart - superseded by sqldatamart

## [codebook](codebook)
Python script for generating csv listing of all value-label pairs for coded items in a study, from an ODM 1.3 XML or study metadata XML file.

## [collate_rules](collate_rules)
XSL transformations for collating rule XML files into one file for editing / upload, and another for grouping (and ungrouping) rules by the target item.

## [compare_clinicaldata](compare_clinicaldata)
XSL transformation for combining multiple versions of an ODM 1.3 XML file for comparison, to show the changes in bulk

## [crf_manager](crf_manager)
Access database to read CRF .xls files in for review or editing, and write them out again.

## [dnotes](dnotes)
XSL transformations for preparing a pdf report of discrepancy notes from an ODM 1.3 XML file.

## [repeated_rules](repeated_rules)
Example of a CRF with many repeated items (16x50), a VBScript to generate rule xml for them based on a template (33 ruledefs, 35 rule actions) and selenium test suite to test the rules.

## [scrape](scrape)
Python script for logging in to OpenClinica, scraping enrolment information and emailing a summary.

## [selenium_tasks](selenium_tasks)
Selenium scripts for automating user tasks - bulk CRF version migration, deleting rules.

## [sqldatamart](sqldatamart)
SQL scripts for building and maintaining a report database connected to OpenClinica's database via a foreign data wrapper. Also includes SQL scripts to facilitate export to xlsx (via R), and subsequent conversion to .dta (via stata) and .sas7bdat (via sas).

## [webservices](webservices)
Clients for interacting with OpenClinica webservices.

* Python 3 client, with tests! Returns Lists of OrderedDicts instead of XML.
* PHP client, now at: https://github.com/lindsay-stevens-kirby/openclinica_webservices_php

See also:

* [Java implementation by CTMM TraIT](https://github.com/jacobrousseau/traitocws/blob/master/TraITOCWS/src/nl/vumc/trait/oc/connect/OCWebServices.java)
* [Python implementation by Dimagi](https://github.com/dimagi/openclinica-xforms/blob/master/webservices.py)

## [xforms](xforms)
XSL transformation for converting an xform xml form into a flat structure for review.

## [xlsform_images](xlsform_images)
Python script that reads an ODK xlsform and generates images for each question, in order to provide a layout style that is a bit nicer than the default. Supports multiple languages. Included example xlsform and generated files with image settings ideal for a Galaxy Tab 4.


text:
+++
title = "3.1 Troubleshoot timeouts (synchronous functions)"
chapter = true
weight = 10
+++

## Troubleshoot timeouts (synchronous functions)

Let's see how we can use Lumigo to troubleshoot timeouts for synchronous Lambda functions such as those handling API requests.

* If you click on the `Timeout` issue for the `requestUnicorn` function, it will take you to the function details page for the function and show you the invocations that timed out.

![requestUnicorn timeouts](/images/mod03-lumigo-requestUnicorn-timeouts.png)

* Click on one of the timed out transactions to see what happened in that transaction.

![requestUnicorn timed out](/images/mod03-lumigo-requestUnicorn-timeout-transaction.png)

* From the function logs, you can see a message like `2020-10-20T11:40:37.402Z	3ea3b770-2986-4926-a0b3-2c6a045bfa20	INFO	Finding unicorn for  42.34963749150315 ,  -71.05718295574066`

and then 6 seconds later, the invocation timed out.

![requestUnicorn timed out](/images/mod03-lumigo-requestUnicorn-timeout-transaction-log.png)

* Click on the `Timeline` tab and you will see that the request to `4fsay0n12a.execute-api.us-east-1.amazonaws.com` never completed, hence the `N/A`. So this was the cause for the invocation timing out.

![requestUnicorn timed out](/images/mod03-lumigo-requestUnicorn-timeout-transaction-timeline.png)

path: /content/03_module/10-Troubleshoot timeouts (sync functions).md


text:
# Constructor Word Guess

A node.js Word Guess Game! Try your best to guess the challenge words, but be wary, you only have 8 guesses to get them!

* Powered by Javascript and node.js.

## Getting Started and Prerequisites

Clone the repo and download [*node.js*](https://nodejs.org/en/) to get started!

### Preview
<!-- take a picture of the image and add it into the readme  -->
![Constructor Word Guess](https://raw.githubusercontent.com/sajeelmalik/Constructor-Word-Guess/master/assets/preview.PNG  "Constructor Word Guess")

## Technology Used

* **Javascript** - the primary scripting logic powering the game
* [**node.js**](https://nodejs.org/en/) - a versatile Javascript runtime environment that processes user inputs in terminal

# Code Snippets
<!-- put snippets of code inside ``` ``` so it will look like code -->
<!-- if you want to put blockquotes use a > -->

Constructors provide a more wholesome data-structure to store complex data that require a multitide of defining attributes. In this case, I created a Letter and a Word constructor to parse through an input string and generate outputs that dynamically adjust to the user's inputs. Later, the inquirer can ask the user for their guesses and adjust the Word object accordingly.

```
var Letter = require("./Letter.js")

var Word = function(word){
    this.word = word.split(""),

    //an array of letter objects
    this.letters = [],

    //an array of letter representations, as the letter or as "_"
    this.wordRepresentation = [];

    this.wordGenerator = function(){

        for(var i = 0; i < word.length; i++){
            var letter = new Letter(word[i]);
            this.letters.push(letter);
            this.wordRepresentation.push(letter.letterPrint());
        }

        console.log(this.wordRepresentation.join(" "))
    }

    this.wordGuess = function(guess){
        for(var i = 0; i < this.letters.length; i++){
            this.letters[i].guessCheck(guess);
            this.wordRepresentation[i] = this.letters[i].letterPrint();
        }
        console.log(this.wordRepresentation.join(" "))
    }
}

module.exports = Word;

```

# Learning Points
<!-- Learning points where you would write what you thought was helpful -->
* Constructors simplified much of the game's core logic from the previous Word Guess Game that I attempted client-side. The internal organization and versatility of these objects are aspects to investigate further.
* .join() was very useful in returning strings from arrays, especially since, strangely, two equivalent arrays were not considered equal during preliminary testing.
 - Consider the following
   - [ 'h', 'e', 'l', 'l', 'o' ]
   - [ 'h', 'e', 'l', 'l', 'o' ]

    In the process of developing the game, a general logical strategy to check if the user had correctly guessed the word was to assess the equivalence of **an array of their guesses** with **an array of the letters of the correct word**. Unfortunately, this did not pan out since the two arrays above were *always* unequal and returned **false**. Further investigation of array manipulation in Javascript should be pursued.

## Authors

* **Sajeel Malik** - *Initial work* - [GitHub](https://github.com/sajeelmalik)

## License

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

repository: sajeelmalik/Constructor-Word-Guess

repo_name: sajeelmalik/Constructor-Word-Guess


text:
# Optimization

Originally, we use preparedStatement to run the sql. And to check if the data is duplicate, we have to run another sql again (select...where...). We then use another method to check duplicate. We first store all the data, say table movies, in a HashMap. It only need to run once. After we got this HashMap, we can check duplicate in O(1) time, so it improves the performance a lot. Also, since the sql is the same, only parameters are different, we use batch to execute the sql. When using batch, the database only need to connect once after all the sql command is ready, so it reduce the I/O time to fetch the database.

Origin method takes over 10 minutes to run all three xml files. After improving the check method, it takes around 5 minutes. After batch method,
it only takes less than 5 second.

## Final result:
mains243.xml: 5520 millisecond

actors63.xml: 2457 millisecond

casts124.xml: 2803 millisecond


text:
# Cycle Representation Learning for Inductive Relation Prediction

```
@inproceedings{cbgnn_icml22,
author = {Zuoyu Yan and Tengfei Ma and Liangcai Gao and Zhi Tang and Chao Chen},
title = {Cycle Representation Learning for Inductive Relation Prediction},
booktitle = {Proceedings of the 39th International Conference on Machine Learning (ICML)},
year = {2022}
}
```

links
- [icml](https://icml.cc/Conferences/2022/Schedule?showEvent=16858)
- [arXiv](https://arxiv.org/abs/2110.02510)


text:
# 916. Word Subsets

Difficulty: Medium

https://leetcode.com/problems/word-subsets/

We are given two arrays A and B of words.  Each word is a string of lowercase letters.

Now, say that word b is a subset of word a if every letter in b occurs in a, including multiplicity.  For example, "wrr" is a subset of "warrior", but is not a subset of "world".

Now say a word a from A is universal if for every b in B, b is a subset of a.

Return a list of all universal words in A.  You can return the words in any order.

**Example 1:**
```
Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["e","o"]
Output: ["facebook","google","leetcode"]
```

**Example 2:**
```
Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["l","e"]
Output: ["apple","google","leetcode"]
```

**Example 3:**
```
Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["e","oo"]
Output: ["facebook","google"]
```

**Example 4:**
```
Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["lo","eo"]
Output: ["google","leetcode"]
```

**Example 5:**
```
Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["ec","oc","ceo"]
Output: ["facebook","leetcode"]
```

**Note:**

1. 1 <= A.length, B.length <= 10000
2. 1 <= A[i].length, B[i].length <= 10
3. A[i] and B[i] consist only of lowercase letters.
4. All words in A[i] are unique: there isn't i != j with A[i] == A[j].

repository: jiadaizhao/LeetCode

path: /0901-1000/0916-Word Subsets/README.md

repo_name: jiadaizhao/LeetCode


text:
# USE_CASES.md
## Model Use Cases
### USE CASE 1 - Model
A player collides with an enemy on the side or from below (enemy above player). The player's life status should change to dead, while nothing should happen to the enemy. Both updated entities are returned to the game engine.

### USE CASE 2 - Model
A player collides with an enemy from above (player above enemy). The player should bounce, and the enemy should become stunned. Both updated entities are returned to the game engine.

### USE CASE 3 - Model
A player collides with a stunned enemy from above. The player should bounce, and the enemy should be re-stunned (the timer on the stun should be reset) or killed depending on the enemy's type. Both updated entities are returned to the game engine.

### USE CASE 4 - Model
A player collides with a stunned enemy (projectile type) from the side. Nothing should happen to the player, but a projectile entity is created in the place of the enemy and the enemy should be marked as dead. Both updated entities are returned to the game engine.

### USE CASE 5 - Model
An enemy collides with another enemy. Nothing happens to either. Both updated entities are returned to the game engine.

### USE CASE 6 - Model
An enemy collides with a projectile. The enemy dies, and the projectile loses a hit (if it has a number of hits). Both updated entities are returned to the game engine.

### USE CASE 7 - Model
The user presses the space bar, and the game engine calls `jump()` in `Player`. The player gains y-velocity, and starts moving upward. After some time, the player begins to have negative y velocity until it hits terrain.

### USE CASE 8 - Model
The player jumps on top of a stunnable enemy. The enemy becomes stunned, and after a certain amount of time with no action, the enemy becomes unstunned and resumes whatever action or movement it was doing previously.

## Game Engine Use Cases
### USE CASE 1 - Game Engine
The user presses the right arrow key. The InputManager recognizes that the right arrow key has been pressed, and calls a method to move the main charcater to the right. The CameraManager then senses that the main character is now not in the center of the screen. The CameraManager adjusts the coordinates of the character that is relative to the screen so that the main character is located in the center. The camera then adjusts the screen-related-coordinates of all entities that are currently located on the screen so that they are shifted by the amount that it took to return the main character to the center of the screen. This includes the addition and removal of entities as the screen moves.

### USE CASE 2 - Game Engine
The collision manager detects a collision between two entities. The collisionManager creates two Collision objects, and passes those objects to the entities that collided. The CollisionManager gets the return Entity from the Collision and determines if this is a new Entity and if any of the existing entities have died.

### USE CASE 3 - Game Engine
The EntityManager detcts that an entity has died. The EntityManager removes the entity from the EntityList and tells the Level controller to remove that Entity from the display.

### USE CASE 4 - Game Engine
The user selects the pause button while playing a basicLevel. The ScreenController creates a screen the displays that the game is paused and has the options to resume or exit the game. The timeline within LevelLoop is temporarily stopped.

### USE CASE 5 - Game Engine
A collision causes an Entity to die and a new entity to be created in place of that Entity. The EntityManager receives an Entity from the CollisionManager. This Entity is not currently in the EntityList. The Entity is added to the EntityList. The EntityManager then checks to see if any of the current Entities have died. The EntityManager sees that one of the Entities has died, and removes this Entity from the List.

### USE CASE 6 - Game Engine
The main character jumps on top of a tube. The CollisionManager detects a collision between the character and the tube from the top, and tells the LevelController that we are entering a tube. The LevelController creates a new Level that dispays an underwater background and new physics components for Entity.

### USE CASE 7 - Game Engine
The main character jumps on top of an enemy. The CollisionManager detects the collision,  and executes respective methods. The EntityManager detects that the state of one of the Entities has been changed to dead, but no new Entity is created in place of this Entity. This Entity is removed from the Entitylist, and the EntityManager tells the LevelController that it needs to be removed from the display.

### USE CASE 8 - Game Engine
The user presses the bar. The InputManager detects that the space bar has been pressed, and tells the main character to that the character needs to jump. The Entity then uses its specified Physics component to change position.

## View Use Cases
### USE CASE 1 - View
The user selects a user profile in the UserSelect screen. Their selection is communicated to the backend, which loads in the appropriate user profile from a file. Screens in the menu now  display user-specific information, like lives remaining and levels unlocked.

### USE CASE 2 - View
The user exits the game. As they do, their progress, lives remaining, and score are saved to a user file, saved automatically to be loaded the next time the user opens the game.

### USE CASE 3 - View
The user selects a basicLevel in the LevelSelect screen and presses "Begin". A loading screen (SplashScreen) displays, showing the basicLevel to be loaded and the user's remaining lives. The basicLevel loads, and the user is shown the GameScreen. They press the left and right arrow keys to see their character move back and forth. Then, they press 'Quit', and are taken back to the main menu, without their progress in the basicLevel being saved.

### USE CASE 4 - View
The user opens the game and tries to select a user profile, but the user's data file was corrupted, and can't be loaded. An error message pops up informing the user of the problem and suggesting steps to fix it, like deleting the user file. When the user clicks "Okay", dismissing the error message, the application closes.

### USE CASE 5 - View
The user selects their user profile in the UserSelect screen, then presses "BEGIN" to move to the main menu. They click "Help", and navigate to the Help screen, where the game's controls and helpful tips are displayed.

### USE CASE 6 - View
The user completes a basicLevel, and the basicLevel progress bar beneath the LevelSelect page updates to reflect the progress, moving one bar closer to the end.

### USE CASE 7 - View
The user dies while playing the game, and a death screen fades in, displaying an animation that shows the user losing a life and displaying their remaining lives. The death screen fades out, and the basicLevel loading screen fades in. The basicLevel restarts.

### USE CASE 8 - View
The user successfully completes a basicLevel, and the basicLevel completion screen fades in, showing a victory animation and the unlocking of the next basicLevel. The user is taken back to the LevelSelect page, with the new basicLevel unlocked for selection.

## Game Controller Use Cases
### USE CASE 1 - Game Controller
The application is launched and the screen controller launches the visualizer. A welcome screen is displayed.

### USE CASE 2 - Game Controller
A basicLevel is read in, and a list of entities is created with the correct attributes and basicLevel relative position.

### USE CASE 3 - Game Controller
If the user pauses the game through the visualizer, the game controller pauses the basicLevel loop. It remains paused until the user resumes the game, in which the game controller turns on the basicLevel loop.

### USE CASE 4 - Game Controller
The user selects a new basicLevel to load. The basicLevel is read from the selected XML file, and a new basicLevel loop is created with the new list of entities.

### USE CASE 5 - Game Controller
The user adds a second player. The new player has a different set of movement keys (which will be loaded from a properties file), and the new player is added to the list of entities in the game engine.

### USE CASE 6 - Game Controller
An invalid basicLevel file is selected. The game controller displays an error message that the basicLevel cannot be played, and prompts for the user to selected a different basicLevel.

### USE CASE 7 - Game Controller
The user reaches the end of a basicLevel, and the basicLevel loop finishes, and tells the game controller that the basicLevel is over. The game controller determines the next from from the game XML file, and then loads the next basicLevel and passes the list of entities to the new basicLevel loop.

### USE CASE 8 - Game Controller
The player looses a life. The number of lives decreases by one, and the screen controller changes the visualizer to show the 'death' screen. If the user has remaining lives, the current basicLevel is reloaded from the beginning. If the user is out of lives, the screen controller changes the visualiser to a game over screen.


text:
# wiremock-rpm
RPM for tool for mocking HTTP services

[![Copr build status](https://copr.fedorainfracloud.org/coprs/antonpatsev/wiremock-rpm/package/wiremock/status_image/last_build.png)](https://copr.fedorainfracloud.org/coprs/antonpatsev/wiremock-rpm/package/wiremock/)

repository: patsevanton/wiremock-rpm

gha_language: Shell

repo_name: patsevanton/wiremock-rpm


text:
---

copyright:
  years: 2017
lastupdated: "2017-05-17"

---

{:new_window: target="_blank"}
{:shortdesc: .shortdesc}
{:screen: .screen}
{:codeblock: .codeblock}
{:pre: .pre}

# Enable API managed endpoints
{: #manage_cf_apis}

In microservice architecture, Cloud Foundry applications are often deployed to make up the system. Most of these apps will have some sort of API that should be managed.

To begin managing Cloud Foundry APIs, complete the following steps:

1.
2. Select **API Management** in the navigation.
3. Select the **Expose Managed API** toggle to turn on the {{site.data.keyword.Bluemix_notm}} API Management features. This action inserts the API gateway between the public Internet and your app.
4. Continue managing your API with [Managing APIs](manage_apis.html).

repository: csantanapr/docs

repo_name: csantanapr/docs


text:
android-unpacker
================

Android Unpacker presented at Defcon 22: Android Hacker Protection Level 0

Contents
--------

 - AHPL0 - Android Hacker Protection Level 0 + some blackphone stuff slides
 - gdb-scripts/ - Bash script for unpacking bangcle/secshell; requires gdb/adb
 - native-unpacker/ - Unpacker for APKProtect/Bangcle/LIAPP/Qihoo Packer that runs natively, no dependency on gdb
 - hide-qemu/ - Small hacks for hiding the qemu/debuggers, specifically from APKProtect

Disclaimer
----------

This presentation and code are meant for education and research purposes only. Do as you please with it, but accept any and all responsibility for your actions. The tools were created specifically to assist in malware reversing and analysis - be careful.

License
-------

    Copyright 2014-2018 Tim 'diff' Strazzere<EMAIL_ADDRESS>
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

repository: matthid/android-unpacker

repo_name: matthid/android-unpacker


text:
# Python version upgrades

<!--* freshness: { exempt: true } *-->

This doc contains instructions for how to upgrade pytype to support a new Python
version, using the Python 3.6->3.7 upgrade as an example.

## pytype

The process is as follows:

1. Build pytype in the new version, so that you can try out your changes. Have a
   test file, such as [pytype/test_data/simple.py][test_data.simple], handy.
   For the open-source build, first [update setup.cfg](#github_release) (only
   locally for now!), then
   [install from source](https://github.com/google/pytype#installing) using the
   new version's pip.
1. Make the [minimal changes](#minimal_changes) for pytype to start analyzing
   code in the new version.
1. Run the [regression tests](#regression_tests) and fix failures.
1. [Update setup.cfg](#github_release) to declare support for the new version.
   We can start offering type-checking for backwards-compatible code, even
   before any new features have been implemented.
1. Implement [new features](#new_features).

### minimal changes

#### version validation
The [pytype.utils.validate_version][utils.validate_version] method should be
updated to accept the new version.

#### opcode changes

If the new version adds or removes any opcodes, then an updated opcode mapping
should be added to
[pytype/pyc/opcodes.py][pyc.opcodes.python_3_7_mapping] and new opcodes
implemented in [pytype/vm.py][vm.VirtualMachine.byte_LOAD_METHOD].

TIP: [pytype/pyc/generate_opcode_diffs.py][pyc.generate_opcode_diffs] will
generate the changes you need to make to opcodes.py, as well as
stub implementations for vm.py.

If the above script doesn't work, you can figure out the necessary changes by
playing around with the [opcode][cpython-opcode] library:

* `opcode.opmap` contains a name->index mapping of all opcodes.
* Opcodes with an index of at least `opcode.HAVE_ARGUMENT` have an argument.
* The `opcode.has{property}` attributes correspond to `HAS_{PROPERTY}` flags in
  pytype's opcodes module.

The [documentation](https://docs.python.org/3/library/dis.html) for the dis
library is a good reference for bytecode changes. dis is also handy for
disassembling a piece of code and comparing the bytecode between two versions.
For example, to disassemble a function `foo.f`:

```python
import dis
import foo
dis.dis(foo.f)  # pretty-prints the bytecode to stdout
```

Finally, if all else fails, you can consult the [CPython source code](
https://github.com/python/cpython/blob/master/Python/ceval.c).

#### magic numbers

Magic numbers for the new version should be copied from the
[CPython source code][cpython-source] to [pytype/pyc/magic.py][pyc.magic].

### regression tests

For the open-source project, navigate to the root of your cloned pytype
repository and run using the new Python version:

```
python build_scripts/run_tests.py
```

The new version should also be added to the
[CI test matrix](
https://github.com/google/pytype/blob/a2ce16edc0ee992f97b328ce752b51318a00d513/.github/workflows/ci.yml#L15-L22).
Even if the tests do not pass yet, it is helpful to see the failures. You can
can configure them to not fail the workflow by [marking the check as experimental](
https://github.com/google/pytype/blob/a2ce16edc0ee992f97b328ce752b51318a00d513/.github/workflows/ci.yml#L19-L22)
<!-- TODO(rechen): Once https://github.com/actions/toolkit/issues/399 is
supported, suggest that instead of the `|| exit 0` hack -->
and using `|| exit 0` to [always report a success](
https://github.com/google/pytype/blob/a2ce16edc0ee992f97b328ce752b51318a00d513/.github/workflows/ci.yml#L47-L49).

### GitHub release

Update the `classifiers` and `install_requires` fields in
[setup.cfg](https://github.com/google/pytype/blob/main/setup.cfg) to include
the new version.

### new features

Changes may be needed to pytype to support new features that affect typing. For
3.7, such features included postponed evaluation of type annotations,
dataclasses, and typing.OrderedDict. New features can be found on the
["What's New in Python 3.x" page](https://docs.python.org/3/whatsnew/3.7.html)
and by searching for "New in version 3.x" in the
[typing module documentation](https://docs.python.org/3/library/typing.html).

[cpython-opcode]: https://github.com/python/cpython/blob/master/Lib/opcode.py

<!-- References with different internal and external versions -->

[cpython-source]: https://github.com/python/cpython/blob/beba1a808000d5fc445cb28eab96bdb4cdb7c959/Lib/importlib/_bootstrap_external.py#L245

[pyc.generate_opcode_diffs]: https://github.com/google/pytype/blob/main/pytype/pyc/generate_opcode_diffs.py

[pyc.magic]: https://github.com/google/pytype/blob/ee51995a1c5937cb4ebee291acb2e049fb0f81cc/pytype/pyc/magic.py#L97

[pyc.opcodes.python_3_7_mapping]: https://github.com/google/pytype/blob/ee51995a1c5937cb4ebee291acb2e049fb0f81cc/pytype/pyc/opcodes.py#L1101

[test_data.simple]: https://github.com/google/pytype/blob/main/pytype/test_data/simple.py

[utils.validate_version]: https://github.com/google/pytype/blob/ee51995a1c5937cb4ebee291acb2e049fb0f81cc/pytype/utils.py#L74

[vm.VirtualMachine.byte_LOAD_METHOD]: https://github.com/google/pytype/blob/ee51995a1c5937cb4ebee291acb2e049fb0f81cc/pytype/vm.py#L3128

repository: google/pytype

gha_language: Python

repo_name: google/pytype