text:
---
layout: post
title:  "Should employees be promoted at random? Science says: “IDK, maybe?”"
labels: [math, business]
categories: [math, business]
image: assets/images/peter_principle.png
---
> "In a hierarchy every employee tends to rise to his level of incompetence"

> -- Dr. Laurence J. Peter

The controversial quote above is from a semi-satirical book, by Dr. Peter and Raymond Hull, which since
its release triggered quite a bit of research on the topic. The idea behind it is that,
as promotions are typically assigned based on someone's performance in their current role,
people rise ranks of hierarchical organizations until they reach a position where they are
relatively incompetent and not considered for promotions anymore.

This adverse selection effect can be intuitively expected when performance in a certain role
is not a good predictor of performance at a higher role: a stellar programmer is not necessarily
a good manager. Or, as Putt's law states:

> "Technology is dominated by two types of people, those who understand what they do not manage
> and those who manage what they do not understand."

> -- Archibald Putt

I originally encountered the Peter principle because I am a big fan of the
[Ig Nobel prize](https://www.improbable.com/ig-about/), and in 2010 three
Italians, Pluchino, Rapisarda, and Garofalo, were awarded the Ig Nobel Prize in
management science for their computational research on the topic. I always found their result to be very
thought-provoking, and since I wanted to try out the [Mesa library](https://mesa.readthedocs.io/en/master/)
for agent-based simulations, I could think of no better paper to try to reproduce! :-)

# Pluchino-Rapisarda-Garofalo model

We shall now review the model introduced in
["The Peter Principle Revisited: A Computational Study"](https://arxiv.org/pdf/0907.0455.pdf).
Let's consider a hierarchical organization, where positions are distributed over some number
of levels of fixed size; each position can be either vacant or occupied by an
employee, who is characterized by two numbers: their age and a score which
represents how competent they are in their current role. For the sake of definiteness,
let's assume that the score is a real number from 1 to 10.

![Schematic representation of a hierarchical organization](/assets/pics/peter/hierarchical_org.svg){: class="col-12"}

The global efficiency of the company is defined as the sum of the competence scores
for each employee, weighted by a level-dependent "factor of responsibility"
which accounts for the idea that incompetency or unfulfilled roles occurring in the topmost levels
are more harmful to the company as a whole with respect to them occurring in the
lower levels. The efficiency is then normalized by the score the company would
obtain if each employee had a competence score of 10.

Employees can only be promoted to the level immediately above their current one
(provided that there are vacant positions in it) and enter the company only at the
bottom-most level. How will we model then the competency an employee will show when they're
promoted to a higher level? The authors of this model suggest two possible mechanisms:
  *  **Common sense hypothesis**: when an employee is promoted, their competence in
     their new role is roughly the same they had in their previous role, with
     some small random variation (say, uniformly distributed between -1 and 1).
  *  **Peter hypothesis**: when an employee is promoted, their competence at their
     new role is completely independent with respect to the one they had at their
     previous role. Not completely unrealistic, if we imagine someone switching
     from a role where they need highly technical skills to a more managerial role.

Also, one can imagine a large number of strategies by which we choose an employee
to promote at the next level; in the original model, the authors study three of them:
  *  *The Best* strategy: for any vacant position, promote the most competent employee
     from the level immediately below. This is the strategy that is most
     commonsensical, and "in theory" the one people use in the real world.
  *  *The Worst* strategy: rather than picking the best candidate from the level below,
     pick instead the worst one. Intuitively... WTF?
  *  *The Random* strategy: whenever there is a vacant position, write down all the
     names of the employees that can be promoted to fill it, put them into a fish bowl,
     and extract one name at random: that guy gets a promotion! Would love to know
     if anyone uses it in the real world.

Lastly, employees leave the company only if they reach retirement age or if their
competence score falls below a certain threshold.

With these rules in mind, let's implement an agent-based simulation to see how a
company, with random initial ages and competencies of employees at the start, evolves
over time. If you are not interested in the details of the implementation, feel free to skip to
the [discussion of the original results](#discussion-of-the-original-results)
section.

# Implementing the PRG model with Python

As this is a very simple agent-based simulation, I think a natural choice for its
implementation is the [Mesa library](https://mesa.readthedocs.io/en/master/), as
it allows us not to write a lot of boilerplate code for our simulation while at
the same time being much more easy to use with respect to some more sophisticated
library (e.g., [SimPy](https://simpy.readthedocs.io/en/latest/)). The goal of this
section is just to sketch how does the implementation of a simulation like this
looks like; for more details, feel free to take a look at the
[full repo](https://github.com/xalelax/pyter-pynciple) for this post and at the
[Mesa docs](https://mesa.readthedocs.io/en/master/).

We can start by writing a fairly uninteresting `Employee` class as
follows:

The `Employee.step()` method describes what agents do at each time step of the
simulation; in this model, it is very simple: they just get older and approach
retirement age.

The model describing the company dynamics is slightly more involved; here I am
reporting only the methods which are most important for this model:

As you can see, the strategies we described above for promoting employees and recalculating
competencies are essentially one-liners.

Mesa models have a very useful attribute, `data_collector`, which can keep track
of whatever observable we want during our simulations, and give us back a convenient `pandas.DataFrame`.
We can make use of that, and simulate the dynamics of a company via the following:

I.e., we just need to repeatedly call the `model.step()` method, and all the rest
is more or less taken care of automagically. For running batches of simulations,
one could also have used Mesa's
[BatchRunner class](https://github.com/projectmesa/mesa/blob/master/mesa/batchrunner.py).

Without further ado then, let's
look at the output of my implementation of the Pluchino-Rapisarda-Garofalo model.

# Discussion of the original results

By simulating the efficiency over time of a batch of companies, under the assumption of either the common sense
hypothesis or the Peter hypothesis, and assuming they always promote either *The Best*, *The Worst*, or *The Random*
employee, we get the following plots:

![Efficiency vs time](/assets/pics/peter/eff_v_time.svg){: class="col-12"}

Here, each line shows the average from 50 simulations runs. The companies were all identical: initially
filled with 160 employees, distributed among 6 levels of size 1, 5, 11, 21, 41, and 81. The weight of each level
on company performance was of 1, 0.9, 0.8, 0.6, 0.4, and 0.2 respectively. The age of each employee was randomly
initialized from a normal distribution centered at 25 years with standard deviation of 5 years, truncated to have
support from 18 to 60 years, whereas the competence score was randomly sampled from a normal distribution
centered at 7, with standard deviation of 2, truncated to have support from 1 to 10. Retirement age is set to 65 years.

As one can imagine, when the common sense hypothesis is valid, i.e., when competence in the new role of an employee
is fairly similar to their competence in their old role, between the strategies we introduced above the better one is
to fill vacancies by promoting the best employee, whereas always promoting the worst one on average leads to a decrease
in efficiency, and promoting at random sits between these two strategies.

These trends are completely reversed under Peter's hypothesis: always promoting the best employee leads to a **decrease**
in efficiency. Intuitively, we can explain this phenomenon as follows: by promoting the best employee to fill a position,
we are getting rid of the best performer in a level; at the same time, as the new competency score is completely
random, the employee's competency at their new role (which will have a higher impact) will very likely be strictly smaller.
We are dealing with a textbook case of adverse selection here! By promoting instead the worst performing employee of a
level, we are both replacing them with another employee with likely higher competency, and we also get the chance
to re-roll the die for their skill at a new level (which will also likely be higher than before).

Now one question should would be quite natural: in a real organization, for a given promotion, which competency
transfer mechanism is at play? In the scenario where common-sense hypothesis and the Peter hypothesis are equally
likely, Pluchino, Rapisarda, and Garofalo have shown in their paper that a relatively efficient strategy would be to
promote, at random, either the best or the worst candidate for an open position!

# Extensions of the model

Another odd thing to notice in our results is that the dynamics are quite unlike what one could expect: nothing much
happens for about 25 years, and then in a matter of decades we reach equilibrium. This has to do with the fact that
positions are initially entirely filled, and since for the chosen age distribution 99.85% of the employees are
under 40 at the start of the simulation, we will need to wait quite some decades to start seeing anyone retiring.

This artifact can be easily fixed by assuming that at the beginning some positions are unfilled; this can be
done by imposing that the number of agents initially at each level is not given by the level size, but rather
from a binomial distribution (see
[this line](https://github.com/xalelax/pyter-pynciple/blob/c2d3bb5f319618a08ad13df1e8346d81b0f5128c/src/model.py#L110)
in my implementation), such that there is always a random chance that a position is vacant.
I decided to use the same probability of vacancies for each level, but decided to have always at least one person
per level (see
[here](https://github.com/xalelax/pyter-pynciple/blob/c2d3bb5f319618a08ad13df1e8346d81b0f5128c/src/model.py#L111)).
For the sake of definiteness, let's pick 0.2 as the probability for each position to be
initially vacant.

Also, [I introduced](https://github.com/xalelax/pyter-pynciple/blob/c2d3bb5f319618a08ad13df1e8346d81b0f5128c/src/model.py#L36)
some random chance that people leave the company at any given time before retirement
(maybe they got a better offer from a company which does not host lotteries for promotions :-P). Let's assign
to each employee a 4% chance to leave the company every month, so that on average each employee stays about two years
before leaving their role.

As the kind of businesses I am most interested in are early-stage startups, I also decided to consider
companies less stratified and a bit smaller with respect to the original paper. Therefore, let's consider
a company with one CEO, a board of five people just below her, ten "managers" of some sort, and thirty people
below them. I set the weighting factors to 1.0, 0.8, 0.5, and 0.2 for each level quite arbitrarily.

Finally, let's use a simulation step of one month rather than one year, and run this new simulation for batches of
256 companies for each combination of promotion strategies and competence transfer mechanisms. The results are
shown below:

![Efficiency vs time, extended model](/assets/pics/peter/eff_v_time_2.svg){: class="col-12"}

We can see that now the dynamics is more gradual and happens on a more meaningful timescale (years instead
of decades/centuries). Apart from this, nothing much seems to have changed from the original model;
the gaps between the strategies appear to be smaller in this case, but I think is due to the different
company structures I used, instead of any difference in the model. The main point still remains: contrarily
to common sense, promoting the best employee under the Peter hypothesis leads to a
decrease in efficiency.

# Questions left as an exercise for the reader

The modifications of the original model I proposed above are just some small fixes, and it would be interesting
to see how the results would change in case we relax some assumptions. My suggestions on the way
forward would be, for instance:

  1. Employees can only enter at the bottom of the hierarchy; what about including in the model the possibility
     for a company to hire experienced people from outside the company?
  2. The competence score distribution, under the Peter hypothesis, was the same for all levels. Would it be
     meaningful to differentiate it depending on the level?
  3. Employees are very one-dimensional in this model (their effect on the company is characterized only by
     one number). Can we make them, if not as complex as real humans, at least slightly more interesting?
  4. Are there any other interesting competence transfer mechanisms to consider? For instance, some freshly
     promoted individual might not be as effective as their peers, but they could be coached by (some) people in the
     same level, so that we have at least some regression to the average.
  5. Here I studied only average quantities; what about distributions? Is the risk associated with each
     scenario comparable?
  6. Can we model the effect of discrimination, by providing each agent with a "gender", "race",
     or similar attribute?

# Conclusion

How much models like the ones we have been looking so far actually model a company is
still, in my humble opinion, very questionable. For instance, it is extremely unlikely that competence
is the only (or even the most important) thing that a company typically considers when deciding
to hire or promote someone; the objective-looking metrics usually justifying this kind of decision
are often only a façade for biases and discrimination. Typically, the more metrics, the less transparency
is there. Paradoxically, could we ameliorate the problem of discrimination in the workplace by randomizing
hiring and promoting employees? Of course, I am not saying it could be the best solution, but would it improve on
the current status quo?

I think we still understand very little about what really motivates people, and how hierarchies really work;
still, agent-based approaches can often be a good inspirations for further research. Also, they are
relatively easy to code (especially by using some dedicated library for them), as one just needs to provide
the simple rules which govern agents behaviour. I can wholeheartedly suggest the
[Mesa introductory tutorial](https://mesa.readthedocs.io/en/master/tutorials/intro_tutorial.html),
where they implement another interesting model (the Boltzmann wealth model), for more on the topic.

If you made it this far, thanks for reading!

repository: xalelax/blog

repo_name: xalelax/blog


text:
# PhotExcel
PhotExcel is a tool that can be used to convert photos into a excel file (means you can view the photo in a excel file)

#  Example
  Input image:

  ![alt text](https://raw.githubusercontent.com/yagav/PhotExcel/main/flag.jpg)

  Output:

  ![alt text](https://raw.githubusercontent.com/yagav/PhotExcel/main/example.jpg)

  (!Note in some cells of the excel file there maybe some data so what you can do is press ```Ctrl+A``` and the delete it, so all the data in the cells will be deleted where the background of the cells will be untouched.)

# Code Example
  This is really simple to use, you just have to import it and then pass in the image path you want to convert, and then you will have to specify the size you want the output in, and you can also specify the path in where to save the file, and also you can mention the status as True or False where in by True the program will say in what task it is currently working on.

  ```
  import PhotExcel

  PhotExcel(Image_Path='path of image', size = (300,300), Save_Path='output.xlsx', Status=False)
  ```
  !Important: This version of PhotExcel only supports images of RGB color type. Maybe in the upcoming verion you will get the freedom to input other types of images.

license: MIT

repository: yagav/PhotExcel

branch_name: refs/heads/main

extension: md

license_type: permissive

repo_name: yagav/PhotExcel


text:
# DotLang

DotLang provides a full fidelity lexer, recursive descent parser, and
abstract syntax tree for the [Graphviz][graphviz] [DOT Language][dot-lang],
written in modern C# 8.0. It is available as a `netstandard2.0` library.

## The DotLang Abstract Syntax Tree

The following graph represents the @"DotLang.CodeAnalysis.Syntax.SyntaxNode?text=DotLang abstract syntaxt tree", generated by DotLang [by reflecting DotLang](https://github.com/abock/dotlang/blob/master/src/DotLang.Console/Program.cs).

<br/>
<object type="image/svg+xml" data="images/ast.svg" width="600" alt="Graphviz rendering of the DotLang Abstract Syntax Tree nodes" title="The DotLang AST">

[graphviz]: https://graphviz.gitlab.io/
[dot-lang]: https://graphviz.gitlab.io/_pages/doc/info/lang.html
[roslyn]: https://github.com/dotnet/roslyn

repository: abock/dotlang

branch_name: refs/heads/master

repo_name: abock/dotlang


text:
# RuboCop Fatsoma

Fatsoma specific code style checking

## Installation

TODO

## Usage

Put this into `.rubocop.yml`.

```
require: rubocop-fatsoma
```

Now you can run `rubocop` and it will automaticly load the RuboCop Fatsoma
cops together with the standard cops.

## The Cops

All cops are located under
[`lib/rubocop/cop/fatsoma`](lib/rubocop/cop/fatsoma), and contain
examples/documentation.

In your `.rubocop.yml`, you may treat the Fatsoma cops just like any other
cop. For example:

```yaml
Fatsoma/FilePath:
  Exclude:
    - spec/my_poorly_named_spec_file.rb
```

repository: Fatsoma/rubocop-fatsoma

gha_language: Ruby

gha_license_id: MIT

repo_name: Fatsoma/rubocop-fatsoma


text:
web ui for weather-stuff-us
================================================================================

The web ui resources for a web application displaying weather data.

Part of the [weather-stuff-us][] family of projects.

The distributable files are available in the `dist` directory.

[weather-stuff-us]: https://weather-stuff-us.github.io/

build
================================================================================

The source files in `src` can be rebuilt to the distributable files via

    npm run build

development
================================================================================

Because this project only contains the web ui, and not the weather APIs, a
dev server is available which serves up the the web ui locally, and
redirects api calls to an api server (eg, [server-express][]) running at
localhost:3000.  The dev server is started via:

    node dev-server

[server-express]: https://github.com/weather-stuff-us/server-api

license
================================================================================

This package is licensed under the MIT license.  See the [LICENSE.md][] file
for more information.

contributing
================================================================================

Awesome!  We're happy that you want to contribute.

Please read the [CONTRIBUTING.md][] file for more information.

[LICENSE.md]: LICENSE.md
[CONTRIBUTING.md]: CONTRIBUTING.md

repository: weather-stuff-us/web

repo_name: weather-stuff-us/web


text:
# game-serve

### Installation

```
npm i -g game-serve
```

### Instruction

1. Make sure your game is able to pair with the server (API coming soon)

2. Start server by executing `gameServe`

3. Enjoy 🎉

repository: dungwinux/game-serve

repo_name: dungwinux/game-serve


text:
# Super simple nodejs + typescript API demo
This is a very simple project demonstrating how to set up a web server using nodejs and typescript.

## Get it running
- have node installed
- clone this repo
- cd \<repository\>
- npm install
- ./node_modules/typescript/bin/tsc
- node dist/index.js
- browse http://localhost:8080/users

## Overview

### index.ts
The entrypoint to the server. It basically just instantiates a Server and starts it.
### server.ts
A class encapsulating the configuation of the API. It constructs an express app and provides a public method for starting the express app.

It registers 4 routes:
- `GET /users` to list known users
- `GET /users/:name/` to get a user
- `POST /users/:name/` to create a user
- `DELETE /users/:name/` to delete a user

It has a commented out line to inject the headerFilter middleware.

### middleware/headerFilter.ts
This is a simple middleware filter that checks for the existence of a header called 'customHeader' on every request, and 400s if it does not exist.

### package.json
The npm config file that holds information about this package, including its depencencies. `npm install` uses this to install dependencies, including the typescript compiler (`tsc`), and the type files that it (and an IDE like VS Code) require.
### tsconfig.json
The typescript config file which controls the behaviour of the `tsc` compiler. Note that here we specify that compiled js files should be placed in the `dist` folder

repository: benrhughes/nodetsdemo

repo_name: benrhughes/nodetsdemo


text:
# Changelog

## Unreleased

* Add a metric `process.runtime.dotnet.gc.duration` for total paused duration in
  GC for .NET 7 and greater versions
  ([#1239](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1239))

* Update OpenTelemetry API to 1.5.1
  ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255))

## 1.5.0

Released 2023-Jun-06

* Update OpenTelemetry API to 1.5.0
  ([#1220](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1220))

## 1.4.0

Released 2023-Jun-01

* Bumped the version to `1.4.0` to keep it in sync with the release versions of
  `OpenTelemetry.API`. This makes it more intuitive for the users to figure out
  what version of core packages would work with a given version of this package.

## 1.1.0-rc.2

Released 2023-Feb-27

* Update OpenTelemetry API to 1.4.0
  ([#1038](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1038))

## 1.1.0-rc.1

Released 2023-Feb-13

* Update OpenTelemetry API to 1.4.0-rc.4
  ([#990](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/990))

## 1.1.0-beta.4

Released 2023-Feb-02

* Update OpenTelemetry API to 1.4.0-rc.3
  ([#944](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/944))

## 1.1.0-beta.3

Released 2023-Jan-11

* Update OpenTelemetry API to 1.4.0-rc.2
  ([#880](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/880))

## 1.1.0-beta.2

Released 2022-Dec-13

* Update OpenTelemetry API to 1.4.0-rc.1
  ([#820](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/820))

## 1.1.0-beta.1

Released 2022-Nov-22

* Update OpenTelemetry API to 1.4.0-beta.3
  ([#774](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/774))

* Change ObservableGauge to ObservableUpDownCounter for the below metrics (which
  better fit UpDownCounter semantics as they are additive.)

  "process.runtime.dotnet.gc.heap.size",
  "process.runtime.dotnet.gc.heap.fragmentation.size",
  "process.runtime.dotnet.thread_pool.threads.count",
  "process.runtime.dotnet.thread_pool.queue.length",
  "process.runtime.dotnet.timer.count",
  "process.runtime.dotnet.assemblies.count"
  ([#675](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/675))

  If your backend system distinguishes between ObservableUpDownCounter and
  ObservableGauge, then you may need to adjust your queries. Systems like
  Prometheus are unaffected by this.

* Removes NETCoreApp3.1 target as .NET Core 3.1 and .NET 5 are going out of
  support. The package keeps `netstandard2.0` target, so it can still be used
  with .NET Core 3.1/.NET 5 apps, however certain metrics will not be available
  there. Additionally, apps targeting .NET 5 and lower will receive a warning at
  build time as described [here](https://github.com/dotnet/runtime/pull/72518)
  (note: building using older versions of the .NET SDK produces an error at
  build time). This is because .NET 5 reached EOL in May 2022 and .NET Core 3.1
  reaches EOL in December 2022.

  The build warning can be suppressed by setting the
  SuppressTfmSupportBuildWarnings MSBuild property, but there is no guarantee
  that this package will continue to work on older versions of .NET.

  This does not affect applications targeting .NET Framework.

* Add "process.runtime.dotnet.gc.objects.size" metric
  ([#683](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/683))

## 1.0.0

Released 2022-Aug-03

* Rename `RuntimeInstrumentOptions` to `RuntimeInstrumentationOptions`
  ([#556](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/556))

## 1.0.0-rc.3

Released 2022-Jul-25

* Add gc.heap.fragmentation.size back for .NET 7 and later
  ([#524](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/524))

## 1.0.0-rc.2

Released 2022-Jul-19

* Refined some metrics names (assembly.count->assemblies.count,
  exception.count-> exceptions.count, attribute name: gen->generation) and
  descriptions
  ([#475](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/475))
* Change API for GC Heap Size for .NET 6 where the API has a bug
  ([#495](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/495))
* Remove gc.heap.fragmentation.size metrics due to buggy API on .NET 6
  ([#509](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/509))

## 1.0.0-rc.1

Released 2022-Jun-29

Major refactor of the runtime instrumentation. Renamed API signature and
metrics. Removed the options to turn off certain metrics.

## 1.0.0-beta.1

Major redesign of the runtime instrumentation. Renamed metrics to be more
user-friendly and better logical grouping. Removed the process related metrics
which are not .NET Runtime specific.

## 0.2.0-alpha.1

* Updated OpenTelemetry SDK package version to 1.3.0
  ([#411](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/411))
* Fix some bugs in Runtime metrics
  ([#409](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/409))
* Add GC heap size and refactor GC count as multi-dimensional metrics in Runtime
  metrics
  ([#412](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/412))

## 0.1.0-alpha.1

* This is the first release of `OpenTelemetry.Instrumentation.Runtime` package.

For more details, please refer to the [README](README.md).

gha_language: C#


text:
# Language Suggester

#### A Website to Demonstrate Understanding of Basic HTML, CSS, Bootstrap, Jquery, and JavaScript Concepts

#### By Shane Graff

## Technologies Used

* HTML
* CSS
* Bootstrap
* JavaScript
* JQuery
* Vs Code

## Description
This is a basic website to suggest which programming language one should learn based on the prompted answers.

## Setup/Installation Requirements

* Clone repository to directory of your choice: git clone https://github.com/ShanGGraff/language_suggester  or --
* Fork website from https://github.com/ShanGGraff/language_suggester

## Known Bugs
* No known

## License
MIT

Copyright (c) 2021 Creators

## Contact Information
Shane Graff<EMAIL_ADDRESS>Github page: https://github.com/ShanGGraff
LinkedIn: https://www.linkedin.com/in/shanegraff/


text:
---
layout: default
---

# 1997-12-16 - Re: A gauntlet thrown down by PC-Magic?

## Header Data

From: Ray Arachelian<EMAIL_ADDRESS>To: Alex Woolfson<EMAIL_ADDRESS>Message Hash: b76ce9b9d0eba53a0df3e5b21df0fbe8ce8f58cf2d9fb174b0131681062087a9

Message ID<EMAIL_ADDRESS>Reply To: \<000401bd09f8$f4615200$07a1400c@default\>

UTC Datetime: 1997-12-16 18:51:47 UTC

Raw Date: Wed, 17 Dec 1997 02:51:47 +0800

## Raw message

```
{% raw  %}From: Ray Arachelian<EMAIL_ADDRESS>Date: Wed, 17 Dec 1997 02:51:47 +0800
To: Alex Woolfson<EMAIL_ADDRESS>Subject: Re: A gauntlet thrown down by PC-Magic?
In-Reply-To: <000401bd09f8$f4615200$07a1400c@default>
Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text/plain

On Tue, 16 Dec 1997, Alex Woolfson wrote:

> Anyone care to take him up on his challenge?  Please say yes.  :-)

Give us source (or a good disassembler.) :)

=====================================Kaos=Keraunos=Kybernetos==============
.+.^.+.|  Ray Arachelian    |Prying open my 3rd eye.  So good to see |./|\.
<EMAIL_ADDRESS>once again. I thought you were      |/\|/\
<--*-->| ------------------ |hiding, and you thought that I had run  |\/|\/
../|\..| "A toast to Odin,  |away chasing the tail of dogma. I opened|.\|/.
.+.v.+.|God of screwdrivers"|my eye and there we were....            |.....
======================= http://www.sundernet.com ==========================

{% endraw %}
```

## Thread

+ Return to [December 1997](/archive/1997/12)

+ Return to "[Adam Shostack <adam@homeport.org>](/authors/adam_shostack_adam_at_homeport_org_)"
+ Return to "["Alex Woolfson" <abdiel@worldnet.att.net>](/authors/alex_woolfson_abdiel_at_worldnet_att_net_)"
+ Return to "[Ray Arachelian <sunder@brainlink.com>](/authors/ray_arachelian_sunder_at_brainlink_com_)"

+ 1997-12-16 (Tue, 16 Dec 1997 16:09:47 +0800) - [A gauntlet thrown down by PC-Magic?](/archive/1997/12/8bae038f3fa74702ec920362350f6aa0c91b0274baec3278197aa6f86dfad0ae) - _"Alex Woolfson"<EMAIL_ADDRESS>  + 1997-12-16 (Tue, 16 Dec 1997 22:26:25 +0800) - [Re: A gauntlet thrown down by PC-Magic?](/archive/1997/12/4d04f50790ddef2827357cac093f2eb796e68a639ed8caf8818841515619f3b3) - _Adam Shostack<EMAIL_ADDRESS>  + 1997-12-16 (Wed, 17 Dec 1997 02:51:47 +0800) - Re: A gauntlet thrown down by PC-Magic? - _Ray Arachelian<EMAIL_ADDRESS>


text:
# Publish Docker Action

Publish Docker Action is used to build, tag and publish docker image to your docker registry.

## Usage

This simple example will use `Dockerfile` in your workspace to build image, attach the `latest`
tag and push to docker default registry (docker.io). Repository name is your GitHub repository
name by default.

```yaml
- uses: wuhan005/publish-docker-action@master
  with:
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
```

Use `file` and `path` arguments to set docker build file or build context if they are not placed
in the default workspace direcotry.

### Set up registry and repository name

Registry and repository name can be changed with `registry` and `repository` arguments. For example:

```yaml
- uses: wuhan005/publish-docker-action@master
  with:
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    registry: docker.pkg.github.com
    repository: jerray/publish-docker-action
```

#### Tag Format

When you set `auto_tag` to `true`, you can customize the image's tag.

Use `tag_format` to format the tag. Default is `"%TIMESTAMP%"`

Format signs:
```
%TIMESTAMP%     Timestamp
%YYYY%          Year
%MM%            Month
%DD%            Day
%H%             Hour
%m%             Minute
%s%             Second
```

```yaml
- uses: wuhan005/publish-docker-action@master
  with:
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    registry: docker.pkg.github.com
    repository: wuhan005/publish-docker-action
    auto_tag: true
    tag_format: "foo%YYYY%_%MM%"
```

And an image with the tag `foo2019_9` will be published.

### Cache

Cache image can be used to build image. Just provide `with.cache` argument.


text:
---
layout: default
title: Colophon
heading: Colophon
permalink: /colophon/
description: Thank you to those who have inspired us
---

We are grateful to the past organizers of DjangoCon US and of other events for their help and inspiration. The following is an incomplete list of organizations and conferences whose positive example, advice, and generosity have helped make DjangoCon US the welcoming conference it is today.

## Organization

- [Geek Feminism Wiki](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy), Code of Conduct
- [AlterConf](https://www.alterconf.com/speak), speaker slide guidelines
- [DjangoCon Europe](https://2016.djangocon.eu), Code of Conduct Transparency Report
- [DjangoCon Europe](https://2015.djangocon.eu), speaker mentorship program
- [University of Bristol, LGBT+ Society](http://www.lgbtplusbristol.org.uk/), bathroom signage
- [Django Under the Hood](https://djangounderthehood.com/), deep dive day

## Website Design

This website is based on free and open source software, and was designed by our friends at [YupGup](http://yupgup.com/).

- [Jekyll](https://jekyllrb.com/)
- [Foundation](https://foundation.zurb.com/sites/docs/)
- [PyCon Australia](https://2018.pycon-au.org/colophon/), for this colophon
- [Ela Conf](https://elaconf.github.io/), for the Recap page inspiration
- [Styleguide](/styleguide/), to see the fonts and colors used in this website

## Code of Conduct

- [Conduct Hotline](https://conducthotline.com) by [Thea Flowers](https://thea.codes/)

## Image Credits

- [DjangoCon US 2018 Group Photo](https://www.flickr.com/photos/144080672@N05/albums/72157702995974445), Bartek Pawlik, CC BY-NC 2.0
- [Group visit to ENIAC](https://www.flickr.com/photos/144080672@N05/28810970252/in/album-72157672216515946/), Bartek Pawlik, CC BY-NC 2.0
- [San Diego Crowd](https://www.flickr.com/photos/144080672@N05/albums/72157702995974445), Bartek Pawlik, CC BY-NC 2.0
- [San Diego Marriott Mission Valley](https://www.marriott.com/hotels/travel/sanmv-san-diego-marriott-mission-valley/), courtesy of the hotel

Our Sponsors

  {% assign sponsors_by_level = "Platinum|Gold|Lanyard|Silver|Bronze|Diversity & Inclusion|Community" | split: "|" %}
  {% for level in sponsors_by_level %}
    {% assign sponsors_in_level = site.sponsors | where: 'level', level | where: 'hidden', false %}
    {% assign sponsors_count = sponsors_in_level | size %}
    {% if sponsors_count != 0 %}

{{ level }}

      {% for sponsor in sponsors_in_level %}
        {% unless sponsor.hidden %}

        {% endunless %}
      {% endfor %}

    {% endif %}
  {% endfor %}

gha_license_id: NOASSERTION


text:
# Building ARM64 Applications on AWS Graviton2 using the AWS CDK and Self-Hosted Runners for GitHub Actions

## Stack Components
 * __./app.py__ - The main entry point to the stack requires the $VPC_CIDR environment variable to be set.
 * __cdk_graviton2_gh_sh_runner/vpc_stack.py__ – Defines a Virtual Private Cloud (VPC) across two Availability Zones with an IPv4 CIDR block that you set via $VPC_CIDR. A NAT gateway will be created in each public subnet for egress traffic through the VPC’s internet gateway. The private subnet contains the EC2 instance for the self-hosted runner.
 * __cdk_graviton2_gh_sh_runner/ec2_stack.py__ – This defines our AMI, the instance type, and configuration. We’ll use Amazon Linux 2 for the operating system on the runner instance. We also create an IAM role, and add the `AmazonSSMManagedInstanceCore` policy.

## Prerequisites
The following steps are based on these instructions for [Adding self-hosted runners - GitHub Docs](https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners#adding-a-self-hosted-runner-to-an-organization).
1. Navigate to the GitHub organization where you'd like to configure a custom GitHub Action Runner.
2. Under your organization, click *Settings*.
3. In the left sidebar, click *Actions*, then click *Runners*.
4. Under "Runners", click *Add runner*.
5. Copy the token value under the "Configure" section.

NOTE: this is an automatically-generated time-limited token to authenticate the request.

Next, launch an AWS CloudShell environment, and create the following AWS SSM Parameter Store values in the AWS account where you'll be deploying the AWS CDK stack. The names `gh-url` and `gh-token`, and types `String` and `SecureString`, respectively, are required for this integration:

```bash
aws ssm put-parameter --name gh-token --type SecureString --value ABCDEFGHIJKLMNOPQRSTUVWXYZABC
aws ssm put-parameter --name gh-url --type String --value https://github.com/your/organization
```

## Installation and Deployment
[AWS CloudShell](https://aws.amazon.com/cloudshell/) is the preferred environment for installation and deployment.
```bash
sudo npm install aws-cdk -g
git clone https://github.com/aws-samples/cdk-graviton2-gh-sh-runner.git
cd cdk-graviton2-gh-sh-runner
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
export VPC_CIDR="<IP_ADDRESS>/24" # Set your CIDR here.
export AWS_ACCOUNT=`aws sts get-caller-identity | jq -r '.Account'`
cdk bootstrap aws://$AWS_ACCOUNT/$AWS_REGION
cdk deploy --all
# Note: Before the EC2 stack deploys you will be prompted for approval
# The message states 'This deployment will make potentially sensitive changes according to your current security approval level (--require-approval broadening).' and prompts for y/n
```
These steps will deploy an EC2 instance self-hosted runner that is added to your GitHub organization (as specified by the gh-url parameter in the prerequisites).

You can confirm the self-hosted runner has been successfully added to your organization by navigating to the Settings tab for your GitHub organization, selecting the Actions options from the left-hand panel, then selecting Runners.

## Troubleshooting
Refer to the instance ID outputted as part of the CDK stack, then use one of the following steps to get console output for the instance: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-console.html#instance-console-console-output
Scroll to the GitHub Actions self-hosted runner registration output.

Common issues include:
* The provided GitHub token is not authorized for the provided GitHub URL.
* The provided GitHub URL is incorrect.
* There is a typo in one of the parameter store values.

## Security

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.

## License

This library is licensed under the MIT-0 License. See the LICENSE file.


text:
---
title: Configuring Mac
description: Configure Fiddler Classic for Mac
slug: ConfigureForMac
publish: true
position: 16
---

Configure Fiddler Classic for Mac
=========================

>tip Update: If you're looking for Fiddler for macOS, check out the new [Fiddler Everywhere](https://www.telerik.com/fiddler/fiddler-everywhere)! Check this [blog post](https://www.telerik.com/blogs/new-release-fiddler-everywhere-3) to learn more about it or directly see how easy is it to [setup and use Fiddler Everywhere on macOS](http://docs.telerik.com/fiddler-everywhere/get-started/quickstart-macos.html).

Virtualization products like VMWare Fusion or Parallels Desktop permit Fiddler to run in a virtual machine on your Mac.

Configure the Virtual Machine
-----------------------------

1. Install Parallels.

2. Set the Windows Virtual Machine **Hardware > Network 1 Type** to **Bridged Network** mode.

3. Restart the Virtual Machine.

Configure Fiddler Classic
-------------------------

1. Install Fiddler Classic on the Virtual Machine.

2. Open Fiddler.

3. Click **Tools > Options > Connections**.

4. Click the checkbox by **Allow remote computers to connect**.

 ![Allow remote computers to connect][1]

5. Restart Fiddler.

6. Ensure your firewall allows incoming connections to the Fiddler Classic process.

Configure Mac
-------------

1. Hover over the **Online indicator** at the far right of the Fiddler Classic toolbar to display the IP addresses assigned to the virtual machine.

 ![Online Tooltip][2]

2. Click the **Apple Menu**.

3. Click **System Preferences**.

4. Click the **Network** icon.

5. Click the **Advanced** button.

6. Click the **Proxies** tab.

7. Enable the **Web Proxy** (HTTP) and **Secure Web Proxy** (HTTPS) options to point to the IPv4 address of the virtual machine using port 8888.

Disable After Use
-----------------

After using Fiddler, return to the **OSX System Preferences** and disable the proxy settings.

[1]: ../../images/ConfigureForMac/AllowRemoteComputersToConnect.png
[2]: ../../images/ConfigureForMac/OnlineTooltip.png

repository: telerik/fiddler-docs

repo_name: telerik/fiddler-docs


text:
---
layout: default
---

# 1997-01-22 - Re: David Kahn advocates GAK

## Header Data

From: Carl Ellison<EMAIL_ADDRESS>To<EMAIL_ADDRESS>Message Hash: 6e40bef26b510bb89226be26929a9f41e094b0a1c09062883e257d0565b3d1bd

Message ID<EMAIL_ADDRESS>Reply To: _N/A_

UTC Datetime: 1997-01-22 20:27:59 UTC

Raw Date: Wed, 22 Jan 1997 12:27:59 -0800 (PST)

## Raw message

```
{% raw  %}From: Carl Ellison<EMAIL_ADDRESS>Date: Wed, 22 Jan 1997 12:27:59 -0800 (PST)
To<EMAIL_ADDRESS>Subject: Re: David Kahn advocates GAK
Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text/plain

-----BEGIN PGP SIGNED MESSAGE-----

It might also be that David's year long sabatical at NSA's crypto museum
which recently ended put him in touch with people who believe in GAK.

I found it interesting that he noted the argument that each additional
day of government access is a good thing.  This is the kind of belief
we know that NSA holds -- a.k.a. "not on my watch" -- but I haven't seen
it publicly admitted before.

 - Carl

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMuZ35lQXJENzYr45AQEcfwQAqMftG0DXn1nr6faA6IHeAtqSXYanwnZb
DiwqppU4nJqPtIvtFw8eOVVwyYCzIv046dFtwR2mk8HeL1v8I3R2sWm7waknFjlm
TM84+vLamlVnBNPUAXRYOrFiEhPQm/iitR4GVrcga9mHJ+vrI38XQGzi0lxdg310
pWjq5Fxahag=
=xhF7
-----END PGP SIGNATURE-----

+------------------------------------------------------------------+
|Carl M. Ellison<EMAIL_ADDRESS>  http://www.clark.net/pub/cme |
|   PGP 2.6.2: 61 E2 DE 7F CB 9D 79 84  E9 C8 04 8B A6 32 21 A2    |
+-Officer, officer, arrest that man. He's whistling a dirty song.--+

{% endraw %}
```

## Thread

+ Return to [January 1997](/archive/1997/01)

+ Return to "[Carl Ellison <cme@cybercash.com>](/authors/carl_ellison_cme_at_cybercash_com_)"

+ 1997-01-22 (Wed, 22 Jan 1997 12:27:59 -0800 (PST)) - Re: David Kahn advocates GAK - _Carl Ellison<EMAIL_ADDRESS>


text:
# Emmy
Probabilistic programming language embedded in Scala.  It's focus is on
scalability, with inference algorithms like variational bayes and the No-U-Turn
sampler.

# Features
Emmy provides a language for (bayesian) inference and learning on the JVM.
When constructing a model of the data, i.e. a generative process based on
some parameters, an abstract syntax tree (AST) of *Expressions* is constructed.

#### Flexible data types
Data container types include various *scala collections*, to make their use
as natural as possible within a scala machine learning pipeline.  Values can
be integer- (`Int`) or real-valued (`Double`).  Distributions can be
continuous (`Normal`, `Gamma`) or discrete (`Categorical`).

#### Automatic Differentiation
When optimizing approximations to the posterior distribution, automatic
differentiation is used.  This takes a large, error-prone, burden off the process
of implementing a new model.

#### Compiling to a function
Since values and derivatives are calculated many times during Monte Carlo
evaluations, these are compiled to a function.  Memoization reduces multiple
uses of the same value to a single evaluation.

#### Dynamic Graph Construction
To allow for maximum flexibility for inference, graphs can be dynamic - they
are reconstructed for each mini-batch of data.

# Documentation
For documentation and examples, see <http://vanlankvelt.com/emmy>.

repository: fvlankvelt/emmy

gha_language: Scala

repo_name: fvlankvelt/emmy


text:
[stime](../README.md) › [Globals](../globals.md) › ["Difference/DifferenceMonthAware"](../modules/_difference_differencemonthaware_.md) › [DifferenceMonthAware](_difference_differencemonthaware_.differencemonthaware.md)

# Class: DifferenceMonthAware

Making a difference month aware

## Hierarchy

* [DifferenceYearAware](_difference_differenceyearaware_.differenceyearaware.md)

  ↳ **DifferenceMonthAware**

  ↳ [Difference](_difference_difference_.difference.md)

## Index

### Properties

* [timeOne](_difference_differencemonthaware_.differencemonthaware.md#abstract-timeone)
* [timeTwo](_difference_differencemonthaware_.differencemonthaware.md#abstract-timetwo)

### Methods

* [getTotalMonths](_difference_differencemonthaware_.differencemonthaware.md#gettotalmonths)
* [getTotalYears](_difference_differencemonthaware_.differencemonthaware.md#gettotalyears)

## Properties

### `Abstract` timeOne

• **timeOne**: *[Time](_time_.time.md)*

*Overrides [DifferenceYearAware](_difference_differenceyearaware_.differenceyearaware.md).[timeOne](_difference_differenceyearaware_.differenceyearaware.md#abstract-timeone)*

*Defined in [Difference/DifferenceMonthAware.ts:11](https://github.com/TerenceJefferies/STime/blob/b69ea6e/src/Difference/DifferenceMonthAware.ts#L11)*

**`var`** {Time} timeOne First time to compare

___

### `Abstract` timeTwo

• **timeTwo**: *[Time](_time_.time.md)*

*Overrides [DifferenceYearAware](_difference_differenceyearaware_.differenceyearaware.md).[timeTwo](_difference_differenceyearaware_.differenceyearaware.md#abstract-timetwo)*

*Defined in [Difference/DifferenceMonthAware.ts:16](https://github.com/TerenceJefferies/STime/blob/b69ea6e/src/Difference/DifferenceMonthAware.ts#L16)*

**`var`** {Time} timeTwo Time to compare to timeOne

## Methods

###  getTotalMonths

▸ **getTotalMonths**(): *number*

*Defined in [Difference/DifferenceMonthAware.ts:30](https://github.com/TerenceJefferies/STime/blob/b69ea6e/src/Difference/DifferenceMonthAware.ts#L30)*

Get the number of months between the two times

**`example`**
```javascript
const stime = require('stime');
const timeOne = stime.fromDate(new Date('01-01-2020 00:00:00'));
const timeTwo = stime.fromDate(new Date('06-01-2020 00:00:00'));
const diff = stime.difference(timeOne, timeTwo);
const months = diff.getTotalMonths(); // 5
```

**Returns:** *number*

Number of months between the two dates

___

###  getTotalYears

▸ **getTotalYears**(): *number*

*Inherited from [DifferenceYearAware](_difference_differenceyearaware_.differenceyearaware.md).[getTotalYears](_difference_differenceyearaware_.differenceyearaware.md#gettotalyears)*

*Defined in [Difference/DifferenceYearAware.ts:15](https://github.com/TerenceJefferies/STime/blob/b69ea6e/src/Difference/DifferenceYearAware.ts#L15)*

Get total years between two times

**Returns:** *number*

Number of years between the two times

repository: LiamCottrell/STime

gha_language: TypeScript

repo_name: LiamCottrell/STime


text:
# Kakaia

Kakaia strives to be a personal assistant supporting voice commands without sending any data to third-parties.

## Usage

Build Kakaia as follows:

1. Download the appropriate native_client from https://github.com/mozilla/DeepSpeech/releases/tag/v0.6.0 and extract locally
1. export `LD_LIBRARY_PATH` and `LIBRARY_PATH` both pointing to the files extracted in the previous step. For example:

    ```
    export LD_LIBRARY_PATH=/opt/deepspeech/native_client/
    export LIBRARY_PATH=/opt/deepspeech/native_client/
    ```

1. Download the [0.6.0 models](https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz) from https://github.com/mozilla/DeepSpeech/releases/tag/v0.6.0 and extract locally
1. export `DEEPSPEECH_MODELS` pointing to the files extracted in the previous step. (By default it will look for `models/` in the current working directory.) For example:

    ```
    export DEEPSPEECH_MODELS=/opt/deepspeech/models/
    ```

1. Build the Kakaia engine: `cargo build --release`

Run the Kakaia engine using all defaults as follows:

    cargo run --release

Learn about available options by passing in the `-h` parameter.

    cargo run --release -- -h

For example, to save a copy of all audio files and text conversions, pass in the `-s` parameter:

    cargo run --release -- -s

Or, to listen on a different port, you could pass in the following:

    cargo run --release -- -s --listen <IP_ADDRESS>:8089

### Manually testing

You can use `curl` to test the Kakaia engine without a client as follows:
```
$ curl --data @test/test.base64 http://<IP_ADDRESS>:8088/convert/audio/text
{"command":"none","human":"no command","raw":"test","result":0.0}
```

### Set timer
```
$ curl --data @test/set-my-timer.base64 http://<IP_ADDRESS>:8088/convert/audio/text
{"command":"setTimer","human":"set timer for 600 seconds","raw":"said my timer for ten minutes","result":600.0}
```

#### Simple math
```
$ curl --data @test/ten-plus-ten.base64 http://<IP_ADDRESS>:8088/convert/audio/text
{"command":"simpleCalculation","human":"10 plus 10 equals 20","raw":"what is ten plus ten","result":20.0}
```

#### Temperature conversion

```
$ curl --data @test/convert-temperature.base64 http://<IP_ADDRESS>:8088/convert/audio/text
{"command":"convertTemperature","human":"5 degrees celsius is 41 degrees fahrenheit","raw":"convert five degrees celsius to farnie","result":41.0}
```
Other [planned commands](https://github.com/jeremyandrews/kakaia/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Acommand).
### Kakaia client

Currently there is only one Kakaia client, it runs on Apple's watchOS:

- https://github.com/jeremyandrews/kakaia-watchos/

The client provides a simplistic interface to record audio on the watch, which is then base64 encoded and pushed to the Kakaia engine via an Actix API. The engine decodes the file and uses DeepSpeech to convert the audio to text, returning the text on success.

[Planned clients](https://github.com/jeremyandrews/kakaia/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3AClient+).

### Notes

The Kakaia engine is written in Rust, using the [Rust bindings for the deepspeech library](https://github.com/RustAudio/deepspeech-rs) for speech-to-text conversions, and [Actix](https://actix.rs/) for the API.

The model included with DeepSpeech 0.6.0 was mostly trained with American English data. https://hacks.mozilla.org/2019/12/deepspeech-0-6-mozillas-speech-to-text-engine/

Deepspeech-rs currently requires that audio be recorded with a single mono-track, at 16,000 Hz. It uses [audrey](https://github.com/RustAudio/audrey) to support the following audio file types:

- FLAC (`.flac`)
- Ogg Vorbis (`.ogg`)
- WAV (`.wav`)
- ALAC within CAF (`.caf`)

Contributions welcome!

repository: jeremyandrews/kakaia

gha_language: Rust

repo_name: jeremyandrews/kakaia


text:
---
title: 'Just build something!'
cover: './images/rey-bb-horizon.jpg'
author: 'Antonio Pavicevac-Ortiz'
date: '2016-10-07'
category: 'tech'
tags:
  - code newb
---

Since about January of this year, I've really tried to stick with learning things which center around "Vanilla JS".

<!--more-->

I've have been trying to remain disciplined, and not mess around with any frameworks. That has been tough, as their alure is hard to resist.

Almost all of them have great abstractions and make working with API's easier. They're especially hard to ignore since a lot of companies have utlized them, making knowing some frameworks as important as knowing JavaScript itself.

I suppose that's what it was like when jQuery was new to the scene. It helped with cross-browser problems and made working with XHR/AJAX easier. And those animations must have been like Cat-nip! And like I've mentioned previously, folks new to programming want to see results right away.

Well the cool thing is I finally have been able to use some plain ole JavaScript to actually create something useful for work!

Behold! Essentially at work we would get these HTML pages which we had to repurpose. Anyway, they had some specific href tags that needed their respective target attributes set to self and all others set to blank.

```javascript
var URLChecker = (function iffe() {
  var publicAPI = {
    getURL: function() {
      for (var i = 0; i < arguments.length; i++) {
        return {
          foo: 'http://foo.rye.foo.com',
          foodev: 'http://foodev.rye.avon.com',
          blargh_sans_w: 'http://blargh.com',
          blargh: 'http://www.blargh.com',
          blargh2: 'http://www2.blargh.com',
        }[arguments[i]];
      }
    },
    searchURL: function(url) {
      for (var i = 0, l = document.links.length; i < l; i++) {
        if (document.links[i].href.indexOf(publicAPI.getURL(url) !== -1)) {
          document.links[i].setAttribute('target', '_blank');
        }
      }
    },
  };
  return publicAPI;
})();
```

\
That was my first crack at it, and after some helpful guidenece from people on stackoverflow it has evolved to this:

```javascript
var MarkUpChecker = (function iffe() {
  'use strict';
  var URLS = {
      foo: 'http://foo.rye.foo.com',
      foodev: 'http://foodev.rye.avon.com',
      blargh_sans_w: 'http://blargh.com',
      blargh: 'http://www.blargh.com',
      blargh2: 'http://www2.blargh.com',
    },
    publicAPI;

  function getURL() {
    for (var i = 0; i < arguments.length; i++) {
      return URLS[arguments[i]];
    }
  }
  publicAPI = {
    addURL: function() {
      for (var i = 0; i < arguments.length; i += 2) {
        URLS[arguments[i]] = arguments[i + 1];
      }
      console.dir(URLS);
      return URLS;
    },
    searchURL: function() {
      var link,
        url,
        parser,
        newPathName = '',
        newstr = '',
        doc = document,
        container,
        container_links,
        documentTableWrapper,
        docBodyFirstChild;

      if (!doc.getElementById('container')) {
        container = doc.createElement('div');
        container.setAttribute('id', 'container');

        container_links = container.getElementsByTagName('a');
        documentTableWrapper = doc.getElementsByTagName('table')[0];
        container.appendChild(documentTableWrapper);
        container.className = 'container-news';
        docBodyFirstChild = doc.body.firstChild;
        doc.body.insertBefore(container, docBodyFirstChild);
      } else {
        container_links = doc
          .getElementById('container')
          .getElementsByTagName('a');
      }
      for (var i = 0, len = arguments.length; i < len; i++) {
        url = getURL(arguments[i]);
        for (var j = 0, jlen = container_links.length; j < jlen; j++) {
          link = container_links[j];
          if (link.href.indexOf(url) !== -1) {
            parser = document.createElement('a');
            parser.href = link.href;

            link.setAttribute('target', '_self');
            newPathName = parser.pathname;

            if (
              newPathName.search(/Executive|District|Division|National/) != -1
            ) {
              newPathName = newPathName.split('/').pop();
              newstr = newPathName;
            } else {
              newstr = newPathName;
            }

            link.href = newstr;
          } else {
            link.setAttribute('target', '_blank');
          }
        }
      }
    },
  };
  return publicAPI;
})();
```

\
What I loved about this was I was able to take advantage of some cool design patterns I learned. Like using [object literals](https://toddmotto.com/deprecating-the-switch-statement-for-object-literals/) instead of switch statements for evaluating expressions and working with the revealing
[module pattern.](https://github.com/getify/You-Dont-Know-JS/blob/master/scope%20&%20closures/ch5.md#modules) With the later I was able to actually get it to store URLS too.

I suppose this post was more part pat on the back for myself :) and to get across to just build something so you can get some practice with some problem solving and to most of all have some fun!

repository: antonioOrtiz/antonios-blog

gha_language: JavaScript

repo_name: antonioOrtiz/antonios-blog


text:
---
hrs_structure:
  division: '1'
  volume: '2'
  title: '7'
  chapter: '78'
  section: 78-24
type: hrs_section
tags:
  - Government
menu:
  hrs:
    identifier: HRS_0078-0024
    parent: HRS0078
    name: 78-24 Injured employee; liability of third persons
weight: 30175
title: Injured employee; liability of third persons
full_title: 78-24 Injured employee; liability of third persons
---
**[§78-24] Injured employee; liability of third persons.** (a) Whenever any police officer, firefighter, or any other officer or employee who is temporarily exposed to unusually hazardous conditions, or who is a member of a class, recognized by the action of pricing, to be a class exposed to unusually hazardous conditions, receives personal injury arising out of and in the performance of duty and without negligence on the employee's part, the employee shall be placed on accidental injury leave unless suspended or discharged for cause. The employee shall be continued on the department's payroll, as though the employee did not sustain an industrial injury, as follows:

(1) During the first four months of the disability, at the employee's full regular monthly salary; and

(2) Thereafter, during the period of total disability from work at sixty per cent of the employee's regular monthly salary.

The employee shall be entitled to all rights and remedies allowed under chapter 386; provided that any salary paid under this section shall be applied on account of any compensation allowed under chapter 386 or any benefits awarded under part III of chapter 88 to the employee.

(b) When the employer pays benefits to or incurs medical expenses on behalf of any of its employees under this section for any injury sustained under circumstances creating in some person or entity other than the employer a legal liability to pay damages in respect thereto, the employer or the employee may proceed against such third persons and recover all payments made, paid, or due under this section. The employer or employee shall have all of the rights and remedies contained in or provided for under section 386-8\. [L 2000, c 253, pt of §74]

repository: SamMade/BlueAndKrabby

repo_name: SamMade/BlueAndKrabby


text:
# Cake.BuildSystems.Module

A simple Cake module to enhance running from a hosted CI environment

This module will introduce a number of features for running in hosted CI build environments to tightly integrate with the host environment/tools. These modules require **no changes to build scripts** and instead rely on your Cake script's standard aliases and lifecycle events to integrate your script into the environment.

## Build Systems

Currently this module supports:

### Azure Pipelines

> This applies to TFS, Azure Pipelines, and Azure DevOps Server

- Individual timeline records for each task
- Percentage reporting on build progress
- Integrates `Warning` and `Error` logging aliases with the Build Issues summary
- Includes a Cake Build Summary widget on the build summary page

### TeamCity

> Tested with TeamCity 10

- Build Logs are separated (and nested) for each executed task
- Current/ongoing build status is updated to currently running task
- `Error` logging aliases are highlighted in build log output

### MyGet

> Supports the MyGet Build Service

- Task records are added to build logs
- Includes a task summary in the build log
- Integrates `Warning`, `Error` and `Fatal` logging aliases with the build log and report

### Travis CI

> This module is affected by a bug in Travis CI's Linux image (see [travis-ci/travis-ci#7262](https://github.com/travis-ci/travis-ci/issues/7262))

- Log folding for the Cake build and for individual tasks

## Usage

Each build system's functionality resides in its own module, with `Cake.Module.Shared` used for shared types. Each module will conditionally register itself, meaning they will only be loaded in their respective CI environments. This means all modules can be deployed with a single codebase without interference.

## Installation

### Using the pre-processor directives

Add the next following line to your Cake script:

```cs
#module nuget:?package=Cake.BuildSystems.Module&version=##see below for note on versioning##
```

Note: The current version can always be taken from [nuget.org](https://nuget.org/packages/Cake.BuildSystems.Module/)).

Currently modules require "bootstrapping", so the first step before running the build is to call `dotnet cake --bootstrap`
(or `.\build.ps1 --bootstrap`)

### Other methods

You can also integrate this module into your own build process, even with a customized `build.ps1`/`build.sh`. As long as the `Cake.BuildSystems.Module` NuGet package is installed into your modules directory ([by default](https://cakebuild.net/docs/running-builds/configuration/default-configuration-values) `./tools/Modules`), `cake.exe` should pick them up when it runs. Note that you can also change your modules directory using the `cake.config` file or passing arguments to `cake.exe` as outlined in [the documentation](https://cakebuild.net/docs/running-builds/configuration/set-configuration-values)).

### Cake.Frosting

While Cake script will load all modules automatically that are present in the modules directory, the same is not the case when using Cake.Frosting.

Before using Cake.Buildsystems.Module you have to reference the NuGet package either by adding `<PackageReference Include="Cake.BuildSystems.Module" Version="##see below for note on versioning##" />` to the `csproj` file of the build project, or by running `dotnet add package cake.buildsystems.module` in the folder of the build project.

To actually make use of the different modules included in Cake.Buildsystems.Module they need to be registered to the `CakeHost`. This can be done by using `ICakeHost.UseModule<TModule>()`. Typically the `CakeHost` is set up in the `Main` method of the build project. All modules included in Cake.Buildsystems.Module can be registered, regardless of the underlying build system, as each modules will only be triggered for the intended build system.

An example that registers all currently existing modules from Cake.Buildsystems.Module:

```csharp
public static int Main(string[] args)
{
    return new CakeHost()
        // Register all modules from Cake.Buildsystems.Module
        .UseModule<AzurePipelinesModule>()
        .UseModule<MyGetModule>()
        .UseModule<TravisCIModule>()
        .UseModule<TeamCityModule>()
        // continue with the "normal" setup of the CakeHost
        .UseContext<BuildContext>()
        .Run(args);
}
```

## Versioning

Note that since modules interact with the internals of Cake, they are tied to a specific version of Cake. The version of Cake supported by the particular module version will always be in the Release Notes of the NuGet package (and therefore also on [nuget.org](https://nuget.org/packages/Cake.BuildSystems.Module/)). Make sure to match this version number to the Cake version you're using.

## Building

Running `build.ps1` with the default target will build all system modules into `BuildArtifacts/temp/_PublishedLibraries`. Copy this to `tools/Modules` (you may need to  disable the MD5 check if using the bootstrapper) and run your script.

branch_name: refs/heads/develop


text:
---
layout: post
title:  "Episode 49: Extreme Classification: Going at MACH Speed (Part 1)"
date:   2020-01-17
categories: episode
---

In this episode, Dr. Derek Feng drops by to chat about a recent paper on a divide-and-conquer approach (Merged-Averaged Classifiers via Hashing) to massive classification problems. In part 1 (of 2 episodes), we describe the general problem solved by and strategy taken by MACH, wherein the original large classification problem is broken down into smaller-sized classification problems. Next week in the second episode, we talk about more technical details of how the division of labor works, and why it works.

<iframe src="https://anchor.fm/databytes/embed/episodes/49-Extreme-Classification-Going-at-MACH-Speed-Part-1-ea7uiq" height="102px" width="400px" frameborder="0" scrolling="no"></iframe>

## Sources

* [NeurIPS 2019: MACH paper](https://arxiv.org/pdf/1910.13830.pdf)

gha_language: HTML


text:
Pattern: Ineffective assignment in `declare`

Issue: -

## Description

When assigning variables via a command, such as `declare`, `typeset`, `local` etc, the expansion of all arguments happen before all assignments. This means that you can't have a variable assigned and then referenced in the same command.

In the example, if `$1` is 42, the arguments will first be expanded in the current environment into `-i first=42 current=`. They will then be passed to `declare` which will perform the assignments.

To correctly set `current=$first` so that it uses the new value of `first`, use two separate commands as shown.

Note that this only applies when assigning via commands, because arguments are always expanded before commands are invoked. If assigning without a command, as in `first=$1 current=$first`, it will work as expected.

Example of **incorrect** code:

```sh
declare -i first=$1 current=$first
```

Example of **correct** code:

```sh
declare -i first=$1
declare -i current=$first
```

## Further Reading

* [ShellCheck - SC2318](https://github.com/koalaman/shellcheck/wiki/SC2318)

repository: Adroiti/docs-for-code-review-tools

repo_name: Adroiti/docs-for-code-review-tools


text:
---
layout: default
title: FAQ
stylesheet: docs
---

## Why am I getting `TypeError: unsupported operand type(s) for +: 'dict' and 'dict'`?

Skylark currently defines the `+` operator for dictionaries. Because
Skydoc evaluates `.bzl` files as Python code and because the `+` operator
for dictionaries may be [removed][dict-op] from Skylark in the future, we
suggest using the `dict(a.items() + b.items())` syntax instead.

[dict-op]: https://github.com/bazelbuild/bazel/issues/1086

## Is Skydoc used to generate the documentation on [bazel.build](https://bazel.build)?

Not for now. The [Build Encyclopedia](https://bazel.build/docs/be/overview.html)
documents the set of native Bazel build rules written in Java, and the
[Skylark Library](https://bazel.build/docs/skylark/lib/globals.html) documents the
built-in Skylark modules and functions. Because both of these sets of docs are
generated from Bazel's Java source code, they are generated using a [separate
documentation generation
tool](https://github.com/bazelbuild/bazel/tree/master/src/main/java/com/google/devtools/build/docgen).

We are planning to create a catalog of Skylark rule sets to make it easy to
publish and discover Skylark rule sets and browse their documentation. See
[bazelbuild/bazel#1046](https://github.com/bazelbuild/bazel/issues/1046) for
more information.

## Why do the docstrings for rules come after the rule definition?

Unlike in other languages, [Python docstrings
](https://www.python.org/dev/peps/pep-0257/) are special string literals rather
than comments. Because Skylark is a subset of Python, we take the same approach
for Skylark docstrings as well. Because rule declarations are basically global
variables, we follow the same convention for variable docstrings used by Python
documentation generation tools, such as
[epydoc](http://epydoc.sourceforge.net/manual-docstring.html).

repository: c-parsons/skydoc

repo_name: c-parsons/skydoc


text:
# learn.forge.designautomation - nodejs

[![Node.js](https://img.shields.io/badge/Node.js-4.4.3-blue.svg)](https://nodejs.org/)
[![npm](https://img.shields.io/badge/npm-2.15.1-blue.svg)](https://www.npmjs.com/)
![Platforms](https://img.shields.io/badge/platform-windows%20%7C%20osx%20%7C%20linux-lightgray.svg)
[![License](http://img.shields.io/:license-mit-blue.svg)](http://opensource.org/licenses/MIT)

[![oAuth2](https://img.shields.io/badge/oAuth2-v1-green.svg)](http://developer.autodesk.com/)
[![Data-Management](https://img.shields.io/badge/Data%20Management-v1-green.svg)](http://developer.autodesk.com/)
[![Design-Automation](https://img.shields.io/badge/Design%20Automation-v3-green.svg)](http://developer.autodesk.com/)

![Basic](https://img.shields.io/badge/Level-Basic-blue.svg)

# Description

Webapp interface that uses Design Automation to update the `width` and `height` param of DWG Dynamic Block (using AutoCAD), RVT Window Family instance (using Revit), IPT Part parameters (using Inventor) and 3DS ... (using 3dsMax). Also includes a `Clear Account` (remove all AppBundles and Activities) and `Define new Activity` based on the sample code.

See other projects for bundles.

## Thumbnail

![thumbnail](../thumbnail.gif)

# Setup

To use this sample, you will need Autodesk developer credentials. Visit the [Forge Developer Portal](https://developer.autodesk.com), sign up for an account, then [create an app](https://developer.autodesk.com/myapps/create). For this new app, use `http://localhost:3000/api/forge/callback/oauth` as the Callback URL, although it is not used on a 2-legged flow. Finally, take note of the **Client ID** and **Client Secret**.

**ngrok**

When a `Workitem` completes, **Design Automation** can notify our application. As the app is running locally (i.e. `localhost`), it's not reacheable from the internet. `ngrok` tool creates a temporary address that channels notifications to our `localhost` address.

After [download ngrok](https://ngrok.com/), run `ngrok http 3000 -host-header="localhost:3000"`, then copy the `http` address into the `FORGE_WEBHOOK_URL` environment variable (see next). For this sample, do not use the `https` address.

![](../media/webapp/ngrok_setup.png)

## Running locally

Install [NodeJS](https://nodejs.org).

Clone this project or download it. It's recommended to install [GitHub Desktop](https://desktop.github.com/). To clone it via command line, use the following (**Terminal** on MacOSX/Linux, **Git Shell** on Windows):

    git clone https://github.com/autodesk-forge/forge-extensions.git

To run it, install the required packages, set the enviroment variables with your client ID & Secret and finally start it. Via command line, navigate to the folder where this repository was cloned to and use the following commands:

Mac OSX/Linux (Terminal)

    npm install
    export FORGE_CLIENT_ID=<<YOUR CLIENT ID FROM DEVELOPER PORTAL>>
    export FORGE_CLIENT_SECRET=<<YOUR CLIENT SECRET>>
    export FORGE_WEBHOOK_URL=<<YOUR NGROK URL>>
    npm start

Windows (use **Node.js command line** from the Start menu)

    npm install
    set FORGE_CLIENT_ID=<<YOUR CLIENT ID FROM DEVELOPER PORTAL>>
    set FORGE_CLIENT_SECRET=<<YOUR CLIENT SECRET>>
    set FORGE_WEBHOOK_URL=<<YOUR NGROK URL>>
    npm start

Open the browser: [http://localhost:3000](http://localhost:3000).

**How to use this sample**

Open `http://localhost:3000` to start the app, if first time, click on `Configure`(right top) select the bundle and engine and click on `Create/Update` this will create an activity. Enter new `width` & `height` values, select the input file (use from **sample files** folder), select the `Activity` and, finally, `Start workitem`.

# Further Reading

Documentation:

- [Design Automation v3](https://forge.autodesk.com/en/docs/design-automation/v3/developers_guide/overview/)
- [Data Management](https://forge.autodesk.com/en/docs/data/v2/reference/http/) used to store input and output files.

## Packages used

The [Autodesk Forge](https://www.npmjs.com/package/forge-apis) packages are included by default. Some other non-Autodesk packages are used, including [express](https://www.npmjs.com/package/express) and [multer](https://www.npmjs.com/package/multer) for upload.

# Tips & tricks

For local development/ testing, consider using the [nodemon](https://www.npmjs.com/package/nodemon) package, which auto-restarts your node application after any modification to your code. To install it, use:

    sudo npm install -g nodemon

Then, instead of **npm run dev**, use the following:

    npm run nodemon

Which executes **nodemon server.js --ignore www/**, where the **--ignore** parameter indicates that the app should not restart if files under the **www** folder are modified.

## Troubleshooting

After installing GitHub Desktop for Windows, on the Git Shell, if you see the ***error setting certificate verify locations*** error, then use the following command:

    git config --global http.sslverify "false"

# License

This sample is licensed under the terms of the [MIT License](http://opensource.org/licenses/MIT).
Please see the [LICENSE](LICENSE) file for full details.

## Written by

Cyrille Fauvel [@FAUVELCyrille](https://twitter.com/FAUVELCyrille), [Forge Partner Development](http://forge.autodesk.com)


text:
# Enforce proper case for numeric literals

Differentiating the casing of the identifier and value clearly separates them and makes your code more readable.

- Lowercase identifier and uppercase value for [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) and [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#BigInt_type).
- Lowercase `e` for exponential notation.

This rule is fixable.

## Fail

[Hexadecimal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Hexadecimal)

```js
const foo = 0XFF;
const foo = 0xff;
const foo = 0Xff;
const foo = 0Xffn;
```

[Binary](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Binary)

```js
const foo = 0B10;
const foo = 0B10n;
```

[Octal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Octal)

```js
const foo = 0O76;
const foo = 0O76n;
```

Exponential notation

```js
const foo = 2E-5;
```

## Pass

```js
const foo = 0xFF;
```

```js
const foo = 0b10;
```

```js
const foo = 0o76;
```

```js
const foo = 0xFFn;
```

```js
const foo = 2e+5;
```

repository: DanHefrman/eslint-plugin-unicorn

repo_name: DanHefrman/eslint-plugin-unicorn


text:
# snabbdom-kotlin

This project is a set of Kotlin definition files for the Snabbdom virtual DOM library. Snabbdom is used in several frontend frameworks, the most famous being Vue.

https://github.com/snabbdom/snabbdom

### Project Details

The definition files here are based on snabbdom v0.7.4.

This project is built with Gradle 6.8.

The typescript definition files in the `/snabbdom.d.ts` folder are copied from the snabbdom v0.6.9 release on npm and then run through the `ts2kt tool` (https://github.com/Kotlin/ts2kt).
The output from the `ts2kt tool` is in the `/snabbdom.d.ts/generated` folder.

The files under the `src` folder are the same output files but modified so that snabbdom is completely ready to use in Kotlin.

### How to use

The artifacts of this project are published to Maven Central.
To use it in your project add the following code in your build.gradle.kts file.

    dependencies {
        ...
        api("io.kvision:snabbdom-kotlin:$snabbdomKotlinVersion")
    }

To see this library being used in a project check out KVision (https://github.com/rjaros/kvision).

repository: rjaros/snabbdom-kotlin

gha_language: Kotlin

repo_name: rjaros/snabbdom-kotlin


text:
# [Ace the System Design Interview — Distributed ID Generator](https://towardsdatascience.com/ace-the-system-design-interview-distributed-id-generator-c65c6b568027)

* Sequential IDs have inherent information, like ordering, whereas random UUIDs have no obvious semantic meaning
* Requirements of the system are: 10 million sequential IDs per second, IDs must preserve some level of ordering information, can toggle generation rate up/down

## High-Level Design

### API Design

* Can imagine the interface is something like `get_uid_batch(batch_size: int)` and returns a `List[int64]`
* Client can ask for some IDs every X milliseconds storing them in local memory and then hand them out from local memory to avoid network connection overhead
  * The IDs stored in local memory will be lost if the client crashes, but this is acceptable since there are plenty of IDs "to waste"

### High-level Architecture

* Can use many computers working concurrently to meet demand of high generation volume
* Cluster manager to monitor node health and workload - if demand exceeds supply, the manager will add more workers (can use auto-scaling software like Kubernetes)

### Control Logic

* Start ZK service & cluster manager (Kubernetes)
* Cluster manager creates X workers
* Each worker registers with ZK and gets a worker ID (integer from 0 to 256)
* Each worker corresponds to an ephemeral node in ZK
* Workers send CPU to cluster manager who removes / adds workers based on consumption rate

## Details

### UID Decomposition

* If generating 10 million UIDs per second, need UIDs of at least 56 bits, which will be exhausted in 228 years
* Use timestamp as part of UID so that it can be sortable
  * UNIX timestamp has 64 bits, which is too long for our UID length of 56 bits
  * Establish a custom Epoch that starts at Time X instead of midnight 1970/1/1, and count milliseconds since then
  * A timestamp with 40 bits will overflow in ~35 years, which is long enough for the project
* Two machines will often generate UIDs with the same timestamp, so need to add more information
  * The worker ID (0 to 256)
  * The thread ID
  * Local counter since a single thread can generate two timestamps in one millisecond, so use a thread-local counter to further distinguish between two IDs
    * When counter is full, thread sleeps through the current millisecond

### Why not queues

* Some queues don't disclose the number of messages buffered, making it impossible for our service to ramp up/decrease capacity when the demand goes up/down

url: https://raw.githubusercontent.com/jaebradley/notes/b9cb0fac012e61205d12ed8d139bbc494319e392/Software Engineering/Design/Ace the System Design Interview — Distributed ID Generator.md

repository: jaebradley/notes

repo_name: jaebradley/notes


text:
---
date: 2018-06-24T08:00:00-08:00
title: "stl-part-viewer web component released"
description: "A Polymer 3/LitElement web component that uses Three.js to display an STL model file."
socialimage: "https://storage.googleapis.com/jdr-public-imgs/blog/20180624-stl-part-viewer-twitter-1024x535.jpg"
tags:
- Web
---

I find myself working with STL files on a fairly regular basis. It's a fairly
simple format, pretty easy to output, and usually my go-to when exporting out of
various CAD system. If you've procured a 3d model to use with your with your
home printer, chances are you've run into STL.

I've been looking to write up and show a few such project STLs this summer, I
decided to dust off an older web component I had sitting around and bring it
into the future.  Hence, welcome `<stl-part-viewer>`.

Built using Polymer 3 and the new lighter base class `lit-element`,
`<stl-part-viewer>` uses three.js as well as my modified stl-loader and
orbit-controls to bring a simple 3D viewer to your browser.

The real magic is in the use of [Intersection
Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
to load the STL file when only in the viewport and will pause the renderer when
the viewer exists the viewport.

## Demo

Words, words, words you say. How about a simple demo using the Polymer logo? And
yes, I [open sourced the polymer
STL's](https://github.com/justinribeiro/stl-part-viewer/tree/master/demo) if you
want to print them. :-)

<stl-part-viewer src="https://storage.googleapis.com/jdr-cors-models/polymer/polymer-binary.stl"></stl-part-viewer>

From a code standpoint, the using the viewer is straight forward:

{{< codeblock lang="markup" >}}
<stl-part-viewer src="example.stl"></stl-part-viewer>
{{< /codeblock >}}

For a full set of attributes that can be set, visit the repo: [justinribeiro/stl-part-viewer](https://github.com/justinribeiro/stl-part-viewer)

If it looks familiar, the colors and general look are based on
[Cura](https://ultimaker.com/en/products/ultimaker-cura-software) (though the
mirror floor is more reminiscent of the Thingiverse viewer).

## In use

I've published the web component on npm as
[@justinribeiro/stl-part-viewer](https://www.npmjs.com/package/@justinribeiro/stl-part-viewer),
so installing and using in your project is just an npm or yarn command away:

{{< codeblock lang="bash" >}}
npm i @justinribeiro/stl-part-viewer
# or
yarn add @justinribeiro/stl-part-viewer
{{< /codeblock >}}

In use, make sure that you polyfill intersection observer and web components
(see
[README](https://github.com/justinribeiro/stl-part-viewer/blob/master/README.md))
for additional information.

repository: justinribeiro/blog-pwa

repo_name: justinribeiro/blog-pwa


text:
# Administrative tasks

## Introduction

Before using Keycloak you must create the necessary resources in the following order: firstly you create a realm that will holds your clients, roles, groups and then users (See [the Keycloak concepts section](/concepts/#keycloak-concepts)).
You can create all theses resources through the [Keycloak administration console](http://localhost:8090) or keycloak-clojure brings you functions to do that easily that are detailed in the next sections.

## Create a keycloak client

In every interaction with keycloak-clojure you must provide a keycloak client object that holds the server reference, password, etc.
The keycloak client is created with:

``` clojure

(require '[keycloak.deployment :as deployment
           :refer [keycloak-client client-conf]])

(def kc-client
  (-> (client-conf {:auth-server-url "http://localhost:8090/auth"
                    :realm "master"
                    :client-id  "admin-cli"})
      (keycloak-client "admin" "secretadmin")))
```

## Create a realm

``` clojure
(require '[keycloak.admin :as admin])
(admin/create-realm! kc-client "example-realm")

```

## Create clients

``` clojure
(admin/create-client! kc-client "example-realm" "myfrontend")
(admin/create-client! kc-client "example-realm" "mybackend")
```

## Create realm roles

``` clojure
(admin/create-role! kc-client "example-realm" "employee")
(admin/create-role! kc-client "example-realm" "manager")
```

## Create users

``` clojure

(admin/create-user! kc-client "example-realm" "user1" "pwd1")

;; The keycloak.user namespace contains function with more exhaustive parameters like:
(require '[keycloak.user :as user])

(user/create-or-update-user! kc-client "example-realm" {:username "bcarter" :first-name "Bob" :last-name "Carter" :password "abcdefg" :email<EMAIL_ADDRESS>["employee" "manager"] nil)
```

## Assign roles to user

``` clojure
(require '[keycloak.user :as user])

(user/add-realm-roles! kc-client "example-realm" "bcarter" ["manager"])

```

## Create groups

```clojure

(admin/create-group! kc-client "example-realm" "mygroup")
(admin/add-username-to-group-name! kc-client "example-realm" "mygroup" "bcarter")

```

## Declarative creation of Keycloak objects

Keycloak-clojure offers a declarative way to create all the Keycloak resources instead of invoking all the imperative functions.
The `init!` function to create all the resource sits in the namespace `keycloak.starter`.

The function expects the following top-level keys: `:realm`, `:clients`, `:roles`, `:groups`, `:users`.

Two additional keys provides a way to generate fake users, groups and roles: `:generated-users-by-group-and-role` and `:username-creator-fn`.

repository: sguessou/keycloak-clojure

repo_name: sguessou/keycloak-clojure


text:
# Maptool App

Quick Start
```
requirements: Vagrant and Virtualbox

git clone https://github.com/penzance/maptool.git
cd maptool
vagrant up
vagrant ssh
pip install -r maptool/requirements/local.txt --upgrade
python manage.py syncdb
python manage.py makemigrations
python manage.py migrate
python manage.py runsslserver <IP_ADDRESS>:8000

now open a browser and enter:
https://localhost:8000/lti_tools/maptoolapp/tool_config

```

This project also contains the basic_lti_app application.
You can install this app using this url:
```
https://localhost:8000/lti_tools/basic_lti_app/tool_config
```

repository: penzance/maptool

repo_name: penzance/maptool


text:
---
layout: writeup
ctf: Crypto CTF 2021
chal: Double Miff
category: crypto
flag: CCTF{D39enEr47E_ECC_4TtaCk!_iN_Huffs?}
points: 217
solves: 16
---

> A new approach, a new attack. Can you attack this curve?

Files given:
 - [output.txt](output.txt)
 - [double_miff.py](double_miff.py)

```python
def onmiff(a, b, p, G):
	x, y = G
	return (a*x*(y**2 - 1) - b*y*(x**2 - 1)) % p == 0

l = len(flag) // 2
m1, m2 = bytes_to_long(flag[:l]), bytes_to_long(flag[l:])

assert m1 < (p // 2) and m2 < (p // 2)
assert onmiff(a, b, p, P) and onmiff(a, b, p, Q)
assert P[0] == m1 and Q[0] == m2

print(f'P + Q = {addmiff(P, Q)}')
print(f'Q + Q = {addmiff(Q, Q)}')
print(f'P + P = {addmiff(P, P)}')
```

The python file uses the flag to generate points \\(P,Q\\) on the curve \\(ax(y^2-1)-by(x^2-1)=0\\) over \\(\mb F_p\\) where \\(a,b,p\\) are unknown. It then outputs the points \\(P+P,P+Q,Q+Q\\).

To compute \\(p\\), we rewrite the equations as

\\[\begin{pmatrix}x_1\left(y_1^2-1\right)&-y_1\left(x_1^2-1\right)\\\\x_2\left(y_2^2-1\right)&-y_2\left(x_2^2-1\right)\end{pmatrix}\begin{pmatrix}a\\\\b\end{pmatrix}=0\\]

then we know that the matrix must have determinant \\(0\\) mod \\(p\\). This gives us three values that must be \\(0\\) mod \\(p\\), hence we can get a multiple of \\(p\\). By taking the largest prime factor of all the determinants, we obtain a likely value of \\(p\\).

From this value of \\(p\\), we can easily compute the values of \\(a,b\\) as well.

Since this curve is an elliptic curve, we can use sage's vast library of functions to obtain \\(P,Q\\) from \\(2P,2Q\\):

```python
QQp.<x,y,z>=PolynomialRing(QQ)
r_pol = QQ(a)*x*(y**2 - 1) - QQ(b)*y*(x**2 - 1)
h_pol = r_pol.homogenize(var=z)
phi = EllipticCurve_from_cubic(h_pol)
E = phi.codomain().change_ring(FF)
tocurve = lambda a,b:E([i.change_ring(FF).subs(x=a,y=b,z=1) for i in phi.defining_polynomials()])
fromcurve = lambda a,b: (lambda P:[i/P[-1] for i in P[:-1]])\
    ([i.change_ring(FF).subs(x=a,y=b,z=1) for i in phi.inverse().defining_polynomials()])

PQ = tocurve(*PQ)
P2 = tocurve(*P2)
Q2 = tocurve(*Q2)

print([bytes.fromhex(hex(fromcurve(*i.xy())[0])[2:]) for i in P2.division_points(2)])
print([bytes.fromhex(hex(fromcurve(*i.xy())[0])[2:]) for i in Q2.division_points(2)])
```

and this gives us the flag

Solution at [solve.sage](solve.sage)

path: /_writeups/2021/Crypto CTF/Double Miff/2021-07-31-Double Miff.md

filename: 2021-07-31-Double Miff.md

gha_language: Python