text:
Crossbow
===========
[ ![Download](https://api.bintray.com/packages/twistedequations/maven/crossbow-wear-receiver/images/download.svg) ](https://bintray.com/twistedequations/maven/crossbow-wear-receiver/_latestVersion)

Extension to the Volley library adding an easy to use wrapper around Volley. Supports android 2.3
and up on phones and 4.3 and up for the wear module

Also provides an easy Picasso https://square.github.io/picasso/ inspired image loading
system based on the ImageLoader.

Crossbow does not modify the Volley library in any way so if you already use Volley then
this library can replace it with no changes to your code.

Crossbow also uses OkHttp by default for Http/2 and SPDY support. You can provide a different OkHttp
client if you want.

Getting Started
------
Crossbow is hosted on jcenter
```groovy
buildscript {
    repositories {
        jcenter()
    }
}
```
Add the Crossbow dependency to your build.gradle in your wear project
```groovy
dependencies {
    compile 'com.twistedequations.crossbow:crossbow:<<latest-version-here>>'
}
```

Crossbow does all the heavy setup lifting for you including setting up the Request
Queue, Image Caches, Image Loaders and Http Clients.

A default Crossbow singleton can be obtained using

```java
CrossBow.get(Context context);
```

Http Requests
------

Adding a request to the queue is easy and simple.
```java
StringRequest request = new StringRequest("http://www.url.com", new Response.Listener<String>() {
    @Override
    public void onResponse(String response) {
        //Handle response
    }
}, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
        //Error handling
    }
});

Crossbow.queue(this,request);
```

If you need to get a reference to the RequestQueue then simply use
```java
RequestQueue requestQueue = Crossbow.from(this).getRequestQueue();
```

If you wish you can write a CustomRequest by extending thr Request class to handle any custom parsing,
headers etc that the library does not support directly.

GsonRequests
------

Crossbow has a GsonGetRequest/GsonPostRequest built in for easy fast parsing and mapping JSON to data
objects using the Gson library
```java
 GsonGetRequest<List<Repo>> requestRepos = new GsonGetRequest<List<Repo>>("https://api.github.com/users/twistedequations/repos", new Response.Listener<List<Repo>>() {
        @Override
        public void onResponse(List<Repo> response) {
        }
    }, new com.android.volley.Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
        }
    }){};
    Crossbow.get(this).add(requestRepos);
```
The GsonGetRequest/GsonPostRequest is an abstract class and must be used an anonymous subclass due to java's type erasure.
(Similar to the TypeToken used by Gson for Collections)

```java
GsonRequest<List<Repo>> requestRepos = new GsonRequest<List<Repo>>(params){};
```

You can use the GsonRequest class for custom gson requests when the GsonGetRequest/GsonPostRequest dont
suit your needs.

Image Loading
------
Crossbow also has rich image loading api based in volleys image loader.
Crossbow sets up an ImageLoader and a Memory Cache for the decoded and scaled bitmaps. Using this is
very easy using the Crossbow.loadImage().

```java
Crossbow.from(context).loadImage().source("https://i.imgur.com/5mObncZ.jpg").into(imageView).load();
```

The bitmaps are automatically scaled down to the size of the ImageView if the image is larger than
the ImageView to reduce memory usage and improve cache performance.

CrossbowImage also supports placeholders
```java
Crossbow.from(context)
    .loadImage()
    .placeHolder(R.drawable.placeHolder)
    .error(R.drawable.errorImage)
    .source("https://i.imgur.com/5mObncZ.jpg")
    .into(imageView);
```

fading
```java
Crossbow.from(context)
    .loadImage()
    .fade(200)
    .source("https://i.imgur.com/5mObncZ.jpg")
    .into(imageView);
```

and separate scaling for placeholders drawables, error drawables and the loaded image.
```java
Crossbow.from(context)
    .loadImage()
    .scale(ImageView.ScaleType.CENTER_CROP)
    .placeholderScale(ImageView.ScaleType.CENTER)
    .placeHolder(R.drawable.placeHolder)
    .source("https://i.imgur.com/5mObncZ.jpg")
    .into(imageView);
```

Crossbow can load from http/https network urls, File Uri, File paths and drawable resource ids.
```java
Crossbow.from(context)
    .loadImage()
    .scale(ImageView.ScaleType.CENTER_CROP)
    .placeholderScale(ImageView.ScaleType.CENTER)
    .placeHolder(R.drawable.placeHolder)
    .source("/path/to/file/image.png")
    .into(imageView);
```

Crossbow will automatically detect ImageView reuse and cancel the old requests so it safe to
use in adapters.

```java
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView = new ImageView(context);
    Crossbow.from(context).loadImage().url("https://i.imgur.com/5mObncZ.jpg").into(imageView);
    return imageView;
}
```

If you need custom network image loading/handing then you can use the standard Volley ImageLoader. This
shares the same Threads, Cache and ImageLoader that CrossbowImage uses.
Getting a reference to the ImageLoader uses the same method as the RequestQueue.

```java
ImageLoader imageLoader = Crossbow.from(this).getImageLoader();

imageLoader.get("https://i.imgur.com/5mObncZ.jpg", new ImageLoader.ImageListener() {
    @Override
    public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {

    }

    @Override
    public void onErrorResponse(VolleyError error) {

    }
});
```

File image loading is done with the FileImageLoader

```java
FileImageLaoder imageLoader = Crossbow.from(this).getImageLoader();

imageLoader.get("https://i.imgur.com/5mObncZ.jpg", new ImageLoader.ImageListener() {
    @Override
    public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {

    }

    @Override
    public void onErrorResponse(VolleyError error) {

    }
});
```

File Loading
------
All file loading must be used with absolute paths

Crossbow supports background file operations with the FileRequest class and its subclasses. The creation and queuing
of requests is the same as the http requests. The file loader looks in the assets first and if the file is not found
it is attempted from the phone disk.

File requests can do any read/write operation on a file. FileRequests with the same path are executed in series but FileRequests
with different paths may be executed in parallel.

```java
FileImageRequest fileImageRequest = new FileImageRequest("/images/image.png", new FileResponse.Listener<Bitmap>() {
    @Override
    public void onResponse(Bitmap response) {
        //Handle response
    }
}, new FileResponse.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
        //Error handling
    }
});

Crossbow.queue(this, fileImageRequest);
```
You can use the GsonReadFileRequest and GsonWriteFileRequest for easy reading and writing of json to files.

The FileImageLoader is used in the same way as normal ImageLoader and can be used for custom file image loads
```java
FileImageLoader imageLoader = Crossbow.from(this).getFileImageLoader();

imageLoader.get("/images/image.png", new FileImageLoader.Listener() {
    @Override
    public void onResponse(Bitmap response, boolean isImmediate) {
        //Do somthing with the loaded file
    }

    @Override
    public void onErrorResponse(VolleyError error) {
        //Handle any errors here
    }
});
```

Using Custom Volley Components
------

If you want to use your own components you can implement CrossbowComponents or its simpler subclass
DefaultCrossbowComponents which has hooks to override the default components. If you wanted to use a
custom network of a different OkHttpClient

```java
public class CustomCrossbowBuilder extends DefaultCrossbowComponents {

    @Override
    public Network onCreateNetwork(HttpStack httpStack) {
        return new CustomNetwork(httpStack);
    }

    @Override
    public OkHttpClient onCreateHttpClient() {
        return new CustomOkHttpClient();
    }
}
```
And register it using in the application class
```java
Crossbow.initialize(context, components);
```
or any where before calling
```java
Crossbow.get(context);
```
for the first time.

If you want to manage the crossbow singleton yourself you can use
```java
Crossbow crossbow = new Crossbow(crossbow, components);
```
and store it manually in the application for a singleton wrapper.

Note:
If you use dagger2 you can extend the CrossbowComponents interface and annotate it with a module to
use dependency injection

Crossbow Wear
===========

Crossbow Wear is exact same as Crossbow but built for use on wearable devices. It interconnects with
Crossbow on the phone and handles all the wear <-> handheld communication for you.

Setup
------

Add the CrossbowWear dependency to your build.gradle in your wear project
```groovy
dependencies {
    compile 'com.twistedequations.crossbow:crossbow-wear:<<latest-version-here>>'
}
```

On the Handheld app you need to have the main Crossbow and the Crossbow wear receiver libraries to
handle the in oncoming requests from the wearable
```groovy
dependencies {
 compile 'com.twistedequations.crossbow:crossbow:<<latest-version-here>>'
 compile 'com.twistedequations.crossbow:crossbow-wear-receiver:<<latest-version-here>>'
}
```

you also need to register the CrossbowListenerService in your manifest to listen for wear requests
```xml
<service android:name=".CrossbowListenerService">
    <intent-filter>
        <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
    </intent-filter>
</service>
```
If you already have a WearableListenerService set up for receiving events from a wearable you need to
change it to extend the CrossbowListenerService instead of the WearableListenerService and register it in instead.
```java
public class CustomWearService extends CrossbowListenerService {
}
```
```xml
<service android:name=".CustomWearService">
    <intent-filter>
        <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
    </intent-filter>
</service>
```
If you are using a custom crossbow instance or custom components you to need to let the CrossbowListenerService know
what RequestQueue to use for the wear requests. This is done is your subclass of CrossbowListenerService and overriding the
getRequestQueue() method.
```java
public class CustomWearService extends CrossbowListenerService {
    @Override
     public RequestQueue getRequestQueue() {
         return // Custom request queue here.
     }
 }
```
Lastly if you are using the compatibility api with custom compatibilities you need to add the crossbow wear
crossbow_compatibility string to the android_wear_capabilities string array so that the wearable knows
which node to connect to.
```xml
    <string-array name="android_wear_capabilities">
        <item>@string/crossbow_compatbility</item>
        <item>@string/other_compatibilty</item>
    </string-array>
```

Making Wear Requests
------

When on wear you need to use the CrossbowWear class to obtain a Crossbow instance. This
manages the caching, compression and play services communication for you via the play network class.
```java
Crossbow crossbow = CrossbowWear.get(this);
```
making a network request is the same as the handheld and can use all the same requests
```java
RepoNameRequest repoNameRequest = new RepoNameRequest("https://api.github.com/users/twistedequations/repos", new Response.Listener<List<String>>() {
        @Override
        public void onResponse(List<String> response) {
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
        }
    });
    CrossbowWear.get(this).add(repoNameRequest);
```

The Image Loaders work perfectly on Wear as well
```java
CrossbowWear.get(this)
    .loadImage()
    .centerCrop()
    .source("http://i.imgur.com/ByktT4N.jpg")
    .fade(200)
    .into(imageView)
    .load();
```

Response Transforming
------

Due to the wearable being a low power, having limited computational power and having a narrow
bandwidth to and from the wearable it makes sense to preform some of the parsing on the handheld to
shrink the network response.

First add the WearRequest interface to your request and return a unique key for the getTransFormerKey()
method an optional bundle of arguments for the transformer to use

```java
public class WearImageRequest extends RecycleImageRequest implements WearRequest {

    private final int maxWidth;
    private final int maxHeight;

    public WearImageRequest(String url, Response.Listener<Bitmap> listener, int maxWidth, int maxHeight, Bitmap.Config decodeConfig, Response.ErrorListener errorListener) {
        super(url, listener, maxWidth, maxHeight, decodeConfig, errorListener);
        this.maxWidth = maxWidth;
        this.maxHeight = maxHeight;
    }

    @Override
    public Bundle getTransformerParams() {
        Bundle bundle = new Bundle();
        bundle.putInt("maxWidth", maxWidth);
        bundle.putInt("maxHeight", maxHeight);
        return bundle;
    }

    @Override
    public String getTransFormerKey() {
        return "transformer_key";
    }
```

Next create the matching RequestTransformer on the handheld for the request to compress the data.
The Bundle passed in here will have the values as the Bundle from the WearRequest
getTransformerParams() method.

```java
public class ImageRequestTransformer implements ResponseTransformer {

    @Override
    public byte[] transform(Bundle requestArgs, byte[] data) throws ParseError {

        int width = requestArgs.getInt("width", 500);
        int height = requestArgs.getInt("height", 500);
        Bitmap.Config config = (Bitmap.Config) requestArgs.getSerializable("config");
        if(config == null) {
            config = Bitmap.Config.RGB_565;
        }

        Bitmap bitmap = ImageDecoder.parseImage(data, config, width, height);

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.WEBP, 100, stream);
        return stream.toByteArray();
}
```

Lastly register the transformer and its key in a subclass of CrossbowListenerService using the same key
from the getTransFormerKey() method in the WearRequest
```java
public class WearMessageService extends CrossbowListenerService {

    @Override
    public Map<String, ResponseTransformer> getTransformerMap() {
        Map<String, ResponseTransformer> map = new HashMap<>();
        map.put("transformer_key", new CustomResponseTransformer());
        return map;
    }
}
```

}

## License

```
Copyright 2015 Patrick Doyle

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.


text:
# ★ SublimeMagic

A magic command for sublime. Create a spellbook, cast spells on your code, make magic happen.

## What?

SublimeMagic provides a `sublime_magic` command, which looks through user-defined actions and performs the first matching one.

## Use the spell hotkey!

Default keybind is `alt + spacebar` but you can set your own. To use the plugin, you have to bind the `sublime_magic` command.

Regular example:

```json
{
  "keys": ["ctrl+,"],
  "command": "sublime_magic"
}
```

Vintageous example:

```json
{
  "keys": [" ", " "],
  "command": "sublime_magic",
  "context": [{ "key": "vi_command_mode_aware" }]
}
```

## Create your spellbook!

The spellbook (your sublime-settings file) consists of a single `spells` array containing the user-defined spells:

```json
{
  "spells": []
}
```

The spells are iterated one-by-one and the first one matching the `context` conditions is casted. When there's no spell matching, nothing happens. When there are multiple matching spells, only the top-most one is performed.

## Spell

Each spell consists of the following required fields:

- `name` is the human readable name of your spell
- `spell` is the spell code, see ["Available spells" for a list of spells](#available-spells)
- `args` specific to the selected spell

Spells can be limited by settings a `context` (similar to key bindings, though not using the same syntax). Known context keys:

- `scope` - an array of required scope names (using regexp) - all patterns must match
- `line_matches` - an array of patterns that the current line must match
- `selection_empty` - when `true`, some text has to be selected; when `false`, there must be no selection
- `selection_matches` - an array of patterns that the currently selected text must match
- need more? - make an issue, or even better a PR :)

### Spell example

```json
{
  "name": "Replace single quoted content with clipboard",
  "context": {
    "scope": ["string\\.quoted\\.single"]
  },
  "spell": "replace_text",
  "args": {
    "where": "inside",
    "delimiter": "'",
    "replacement": "$clipboard"
  }
}
```

## Available spells

- [replace_text](docs/spells/replace_text.md)
- [perform_line_regex](docs/spells/perform_line_regex.md)
- [toggle_values](docs/spells/toggle_values.md)
- [sublime_command](docs/spells/sublime_command.md)
- more to come - make a PR :)

## Example spellbook

Have a nice spellbook? Create a pull request and let me add a link here!

Spellbooks:
+ [mreq](https://github.com/mreq/dotfiles/blob/master/subl/Packages/User/SublimeMagic.sublime-settings)

A simple example:

```json
{
  "spells": [
    {
      "name": "Replace single quoted content with clipboard",
      "context": {
        "scope": ["string\\.quoted\\.single"]
      },
      "spell": "replace_text",
      "args": {
        "where": "inside",
        "delimiter": "'",
        "replacement": "$clipboard"
      }
    },
    {
      "name": "Replace double quoted content with clipboard",
      "context": {
        "scope": ["string\\.quoted\\.double"]
      },
      "spell": "replace_text",
      "args": {
        "where": "inside",
        "delimiter": "\"",
        "replacement": "$clipboard"
      }
    },
    {
      "name": "Replace content after colon with clipboard",
      "context": {
        "line_matches": [": "]
      },
      "spell": "replace_text",
      "args": {
        "where": "after",
        "delimiter": ": ",
        "replacement": "$clipboard"
      }
    }
  ]
}
```

license: MIT

repository: mreq/SublimeMagic

branch_name: refs/heads/master

extension: md

gha_language: Python

license_type: permissive

repo_name: mreq/SublimeMagic


text:
# CO2 Emission

Scrape data from the CarbonIntensity API between two dates.

## Pre-requisites
- Python 3
- Requests library

## How to run
Execute in your terminal:
```
python co2_emission.py
```

![Screenshot](screenshot.png)

### Author
[Jr Miranda](https://github.com/jrmiranda)

gha_license_id: MIT


text:
# Drocoin

This is designed to sit behind nginx reverse proxy so running at <IP_ADDRESS>:8080 or not using https is not a problem.

It's currently live over at https://gradecoin.xyz. It will be moving to https://drocoin.xyz soon.

```
# Test the project
$ cargo test

# Read the documentation
$ cargo doc --open
```

The executable `main` needs the `/templates`, `users` and `blocks` folders. It also expects a `secrets/drocoin.pem` file with the private key of the system.

# References
- https://github.com/blurbyte/restful-rust
- https://github.com/zupzup/warp-postgres-example
- https://blog.logrocket.com/create-an-async-crud-web-service-in-rust-with-warp/

# How to be a good server
- https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
- https://tools.ietf.org/html/rfc7231

Why leave discord? Sadge

repository: Tullsworth/gradecoin

branch_name: refs/heads/main

gha_language: Rust

repo_name: Tullsworth/gradecoin


text:
# How to upgrade from TDW v1.9 to v1.10

## Read the changelog

[Read this](../Changelog.md) for a complete list of changes. Most of the changes in TDW v1.10 are relatively minor but may require you to adjust the code in your controllers.

## 1. Object data is faster and array-like return values are numpy arrays

Object data such as `Transforms`, `Rigidbodies`, and `Bounds` is significantly faster in TDW v1.10. There are some small API changes associated with this improvement that affect array-like return values (e.g. `transforms.get_rotation()` or `rigidbodies.get_velocity()`) for the following output data types:

- `Transforms`
- `Rigidbodies`
- `StaticRigidbodies`
- `Bounds`
- `SegmentationColors`
- `LocalTransforms`
- `DynamicCompositeObjects`

Previously, per-object return values, such as the position of the object, were returned as a tuple. Now, they are all returned as numpy arrays.

If you are using `ObjectManager` or `CompositeObjectManager` to handle object data, the API and return values are exactly the same as before.

Consider this minimal example, which prints the position of the object:

```python
from tdw.controller import Controller
from tdw.tdw_utils import TDWUtils
from tdw.output_data import OutputData, Transforms

c = Controller()
resp = c.communicate([TDWUtils.create_empty_room(12, 12),
                      Controller.get_add_object(model_name="rh10",
                                                object_id=0),
                      {"$type": "send_transforms",
                       "frequency": "once"}])
for i in range(len(resp) - 1):
    r_id = OutputData.get_data_type_id(resp[i])
    if r_id == "tran":
        transform = Transforms(resp[i])
        position = transform.get_position(0)
        print(position)
c.communicate({"$type": "terminate"})
```

Output:

| TDW v1.9                                                     | TDW v1.10                                        |
| ------------------------------------------------------------ | ------------------------------------------------ |
| `(-1.4852732419967651e-05, 0.001660674810409546, 2.7572386898100376e-06)` | `[-1.4852732e-05  1.6606748e-03  2.7572387e-06]` |

If your controller unpacked the values of the tuple, be aware that this is no longer allowed:

```python
from tdw.controller import Controller
from tdw.tdw_utils import TDWUtils
from tdw.output_data import OutputData, Transforms

c = Controller()
resp = c.communicate([TDWUtils.create_empty_room(12, 12),
                      Controller.get_add_object(model_name="rh10",
                                                object_id=0),
                      {"$type": "send_transforms",
                       "frequency": "once"}])
for i in range(len(resp) - 1):
    r_id = OutputData.get_data_type_id(resp[i])
    if r_id == "tran":
        transform = Transforms(resp[i])
        x, y, z = transform.get_position(0)  # This will not work in TDW v1.10
c.communicate({"$type": "terminate"})
```

## 2. Restructured composite object output data

The command `send_composite_objects` and the output data `CompositeObjects` have been removed. Use `send_static_composite_objects` (returns `StaticCompositeObjects`) and `send_dynamic_composite_objects` (returns `DynamicCompositeObjects`) instead. You can also use the `CompositeObjectManager` wrapper add-on.

`DynamicCompositeObjects` was added in TDW v1.9 and has been restructured in v1.10 in order to be faster. The changes mostly affect the underlying data classes and will probably be invisible to most users.

## 3. Replaced ProcGenRoom floor commands

ProcGenFloor commands have been replaced with commands  that will work in other scenes as well:

| v1.9                               | v1.10                     |
| ---------------------------------- | ------------------------- |
| `set_proc_gen_floor_color`         | `set_floor_color`         |
| `set_proc_gen_floor_texture_scale` | `set_floor_texture_scale` |
| `set_proc_gen_floor_material`      | `set_floor_material`      |

## 4. Removed the Sticky Mitten Avatars

The Sticky Mitten Avatars were deprecated in TDW v1.8 in favor of Magnebot; they have been removed as of TDW v1.10. [Read this for how to switch to Magnebot.](v1.7_to_v1.8.md)

## 5. Removed avatar `A_Img_Caps`

Use `A_Simple_Body` instead with a capsule body or the add-on wrapper class [`EmbodiedAvatar`](../python/add_ons/embodied_avatar.md).

## 6. Renamed `PhysicsAudioRecorder` fields

`PhysicsAudioRecorder.recording` is now `PhysicsAudioRecorder.done`. Additionally, there is a new `record_audio` constructor parameter (defaults to `True`).

repository: threedworld-mit/tdw

repo_name: threedworld-mit/tdw


text:
# Aidapp
At Aidapp, our mission is to  empower Businesses to help them grow and achieve more.

Aidapp is defined by its culture to solve the problems that we most care about - Help everyone to achieve more. We believe in creating great opportunities by providing solutions in Mobile and Web Development, UI/UX, and Digital Marketing. Our core mission is to impart affordable and simple solutions to small Startups and Individuals who need it the most but cannot afford to sustain in the competing Tech world. A lot of people who start something new face tough problems - and we feel for their passion, optimism and curiosity, the same that help us personally grow the most.
Aidapp's primary vision is to aid NGO's and Non-Profit Organisations by providing Internet-based solutions for their outreach and growth.

We currently work from Davis (CA) , Bangalore (IN) and  want to create a supportive and collaborative environment, so that we can learn, build and grow together and move the world forward.

Thanks, for visiting our page. Drop your mail at<EMAIL_ADDRESS>
# Company details
--------
## Website
http://www.aidapp.in
## Headquarters
Davis, California

## Year founded
2017

## Company type
Privately Held

## Company size

2-10 employees

## Specialties

Technology, Software, Machine Learning, Artificial Intelligence, Mobile First, and Fin Tech

repository: Aidapp/About

repo_name: Aidapp/About


text:
ANIMALS GIFS SEARCH ENGINE

This is a funny Animals GifS Search Engine destined for kids.

API
This application is powered by public API: GIPHY API.

APP LOGIC

When the app is displayed, the kids should be able to see already a gif of a funny lion.
This is the only gif not fetched from GIPHY API.
The children can search for a gif of one of 5 animals (monkey, lion, cat, dog or elephant).
In order to do so, the children only have to push a button with animal's image on it.
Each time the kids push the button, another random gif will be displayed.
Kids also have the option of pushing the surprise button.
This button serves to get a random animal from a set of animals provided (the 5 first animals listed above and also 4 more: bear, bird, squirrel and mouse).
If the kid choices to search for a surprise animal, the results will be displayed in form of stickers.
If the children click on the image of the current gif displayed, it will open a new tab with the same gif on GIPHY webpage.

LICENCE
This project is licensed under MIT License - see the LICENCE.md file for details.


text:
This issue describes how to implement the `strings` concept exercise for the F# track.

## Goal

The goal of this exercise is to teach the student the basics of the Concept of Strings in [F#][strings].

## Learning objectives

- The existence of the `string` type.
- How to create a string.
- The existence of `string` methods and `String` module function
- Basic string methods (like finding the index of a character at a position, or returning a part the string).
- Basic string formatting (using `+` and `sprintf`).
- Strings are immutable.

## Out of scope

- Strings can be enumerated.
- String slicing.
- Triple-quoted strings.
- Double-backtick strings.
- Advanced string formatting (combining types).
- Using standard or custom format strings.
- Type inference.
- Memory and performance characteristics.

## Concepts

The Concepts this exercise unlocks are:

- `strings-basic`: know of the existence of the `string` type; know of some basic functions (like looking up a character at a position, or slicing the string); know how to do basic string concatenation.

## Prerequisites

There should be no prerequisites.

## Resources to refer to

### Hints

- [String class][strings]
- [String module][string-module]
- [String concatenation][string-concat]

### After

- [Strings reference](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/strings): includes details on verbatim strings, triple-quoted strings and slicing.

## Representer

This exercise does not require any specific representation logic to be added to the [representer][representer].

## Analyzer

This exercise does not require any specific logic to be added to the [analyzer][analyzer].

## Implementing

To implement the concept exercise, the following files must be created:

<pre>
languages
└── fsharp
    └── exercises
        └── concept
            └── strings
                ├── .docs
                |   ├── instructions.md
                |   ├── introduction.md
                |   ├── hints.md
                |   └── after.md
                ├── .meta
                |   ├── config.json
                |   |── design.md
                |   └── Example.fs
                ├── Strings.fs
                ├── Strings.fsproj
                └── StringsTests.fs
</pre>

## Step 1: add .docs/introduction.md

This file contains an introduction to the concept. It should make the exercise's learning goals explicit and provide a short introduction with enough detail for the student to complete the exercise. The aim is to give the student just enough context to figure out the solution themselves, as research has shown that self-discovery is the most effective learning experience. Using the proper technical terms in the descriptions will be helpful if the student wants to search for more information. If the exercise introduces new syntax, an example of the syntax should always be included; students should not need to search the web for examples of syntax.

As an example, the introduction to a "strings" exercise might describe a string as just a "Sequence of Unicode characters" or a "series of bytes". Unless the student needs to understand more nuanced details in order to solve the exercise, this type of brief explanation (along with an example of its syntax) should be sufficient information for the student to solve the exercise.

## Step 2: add .docs/instructions.md

This file contains instructions for the exercise. It should explicitly explain what the student needs to do (define a method with the signature `X(...)` that takes an A and returns a Z), and provide at least one example usage of that function. If there are multiple tasks within the exercise, it should provide an example of each.

## Step 3: add .docs/hints.md

If the student gets stuck, we will allow them to click a button requesting a hint, which shows this file. This will not be a "recommended" path and we will (softly) discourage them using it unless they can't progress without it. As such, it's worth considering that the student reading it will be a little confused/overwhelmed and maybe frustrated.

The file should contain both general and task-specific "hints". These hints should be enough to unblock almost any student. They might link to the docs of the functions that need to be used.

The hints should not spell out the solution, but instead point to a resource describing the solution (e.g. linking to documentation for the function to use).

## Step 4: add .docs/after.md

Once the student completes the exercise they will be shown this file, which should provide them with a summary of what the exercise aimed to teach. If the exercise introduced new syntax, syntax samples should be included. This document can also link to any additional resources that might be interesting to the student in the context of the exercise.

These files are also all described in the [concept exercises document][docs-concept-exercises].

## Step 5: update languages/fsharp/config.json

An entry should be added to the track's `config.json` file for the new concept exercise:

```json
{
  ...
  "exercises": {
    "concept": [
      ...
      {
        "slug": "strings",
        "uuid": "9c2aad8a-53ee-11ea-8d77-2e728ce88125",
        "concepts": ["strings-basic"],
        "prerequisites": []
      }
    ]
  }
}
```

## Step 6: adding track-specific files

These files are specific to the F# track:

- `Strings.fs`. the stub implementation file, which is the starting point for students to work on the exercise.
- `Strings.fsproj`: the F# project file.
- `StringsTests.fs`: the test suite.
- `.meta/Example.fs`: an example implementation that passes all the tests. The project file should _not_ include this file.

## Step 7: update the general concept document

Add the exercise to the [concept's shared document's][reference] `## Implementations` section ([example](https://github.com/exercism/v3/blob/master/reference/types/string.md#implementations)).

## Step 8: updating list of implemented exercises

- Add the exercise to the [list of implemented exercises][implemented-exercises].

## Step 9: add .meta/design.md:

This file contains information on the exercise's design, which includes things like its goal, its teaching goals, what not to teach, and more ([example][meta-design]). This information can be extracted from this GitHub issue.

## Step 10: add .meta/config.json:

This file contains meta information on the exercise, which currently only includes the exercise's contributors ([example][meta-config.json]).

## Step 11: add reference documentation

This exercise could benefit from having a reference document written to introduce basic string concatenation in F#. See [this issue][string-concat-issue]

## Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

[how-to-implement-a-concept-exercise]: https://github.com/exercism/v3/blob/master/docs/maintainers/generic-how-to-implement-a-concept-exercise.md
[implemented-exercises]: https://github.com/exercism/v3/tree/master/languages/fsharp/exercises/concept/README.md#implemented-exercises
[reference]: https://github.com/exercism/v3/blob/master/languages/fsharp/reference/README.md#reference-docs
[analyzer]: https://github.com/exercism/fsharp-analyzer
[representer]: https://github.com/exercism/fsharp-representer
[meta-design]: https://github.com/exercism/v3/blob/master/languages/fsharp/exercises/concept/numbers/.meta/design.md
[meta-config.json]: https://github.com/exercism/v3/blob/master/languages/fsharp/exercises/concept/numbers/.meta/config.json
[docs-concept-exercises]: https://github.com/exercism/v3/blob/master/docs/concept-exercises.md
[string-concat-issue]: https://github.com/exercism/v3/issues/757
[strings]: https://docs.microsoft.com/en-us/dotnet/api/system.string?view=netcore-3.1
[string-module]: https://msdn.microsoft.com/visualfsharpdocs/conceptual/core.string-module-%5bfsharp%5d
[string-concat]: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/strings#string-operators


text:
# myLibrary
MyLibrary is a NetCore 3.1 and Angular 8.3.20 demo app.
## Installation
Use the package npm to install myLibrary in folder ClientApp.
```bash
npm install
```
Also, You will need to install
```bash
npm install @auth0/auth0-spa-js --save
```
## N-Layer
The app is developed like this:
### ClientApp
Contains components and services in angular
### Controllers
Contains API drivers
### Data
Contains models, contexts and data services
### Migrations
Contains the code first files to generate the database

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)

gha_language: TypeScript


text:
# CloudWatch2Humio
This repository contains a set of lambdas for shipping Cloudwatch Logs and Metrics
to Humio.

The full documentation regarding installing and using this integration can be found in the official [humio docs](https://docs.humio.com/integrations/platforms/aws-cloudwatch/).

## Vision
The vision for the CloudWatch to Humio integration, is to create a bridge between Humio and AWS, which enables users to ingest logs and metrics from the AWS CloudWatch service, so that Humio can be used to manage this data.

## Governance
This project is maintained by employees at Humio ApS.
As a general rule, only employees at Humio can become maintainers and have commit privileges to this repository.
Therefore, if you want to contribute to the project, which we very much encourage, you must first fork the repository.
Maintainers will have the final say on accepting or rejecting pull requests.
As a rule of thumb, pull requests will be accepted if:

   * The contribution fits with the project's vision
   * All automated tests have passed
   * The contribution is of a quality comparable to the rest of the project

The maintainers will attempt to react to issues and pull requests quickly, but their ability to do so can vary.
If you haven't heard back from a maintainer within 7 days of creating an issue or making a pull request, please feel free to ping them on the relevant post.

Maintainers will also be in charge of both versioning and publishing future releases of the project. This includes adding versioning tags and adding to the changelog file.

The active maintainers involved with this project include:

   * [Suzanna Volkov](https://github.com/Suzanna-Volkov)


text:
# India Population built using Dash
This website is built using Dash and Plotly. It plots the population data of India by districts and states.

Website Url: https://india-population-dash.herokuapp.com/

Instructions for execution(For windows) [all *.bat files are found in the root directory]

Run the "createVirtualEnv.bat" file to create a python virtual environment and install requirements

Run the "executeDash.bat" to start the server


text:
---
layout: default
title: "Supinfo Share Manager"
permalink: /2005/06/02/Supinfo-Share-Manager/
---

"If
you're using many different File Servers every day, Supinfo Share
Manager is a tool made for you. Finder user interface you're using to
connect to file server is quite minimalistic. Supinfo Share Manager
user interface is simple but quite powerful. It allows you to group
favorites within collections, to find them quickly and to connect to
your file servers with one click."


text:
# Backends

Flannel may be paired with several different backends. Once set, the backend should not be changed at runtime.

VXLAN is the recommended choice. host-gw is recommended for more experienced users who want the performance improvement and whose infrastructure support it (typically it can't be used in cloud environments). UDP is suggested for debugging only or for very old kernels that don't support VXLAN.

AWS, GCE, and AliVPC are experimental and unsupported. Proceed at your own risk.

For more information on configuration options for cloud components, see:
* [AliCloud VPC Backend for Flannel][alicloud-vpc]
* [Amazon VPC Backend for Flannel][amazon-vpc]
* [GCE Backend for Flannel][gce-backend]

## Recommended backends

### VXLAN

Use in-kernel VXLAN to encapsulate the packets.

Type and options:
* `Type` (string): `vxlan`
* `VNI` (number): VXLAN Identifier (VNI) to be used. On Linux, defaults to 1. On Windows should be greater than or equal to 4096.
* `Port` (number): UDP port to use for sending encapsulated packets. On Linux, defaults to kernel default, currently 8472, but on Windows, must be 4789.
* `GBP` (Boolean): Enable [VXLAN Group Based Policy](https://github.com/torvalds/linux/commit/3511494ce2f3d3b77544c79b87511a4ddb61dc89).  Defaults to `false`. GBP is not supported on Windows
* `DirectRouting` (Boolean): Enable direct routes (like `host-gw`) when the hosts are on the same subnet. VXLAN will only be used to encapsulate packets to hosts on different subnets. Defaults to `false`. DirectRouting is not supported on Windows.
* `MacPrefix` (String): Only use on Windows, set to the MAC prefix. Defaults to `0E-2A`.

### host-gw

Use host-gw to create IP routes to subnets via remote machine IPs. Requires direct layer2 connectivity between hosts running flannel.

host-gw provides good performance, with few dependencies, and easy set up.

Type:
* `Type` (string): `host-gw`

### UDP

Use UDP only for debugging if your network and kernel prevent you from using VXLAN or host-gw.

Type and options:
* `Type` (string): `udp`
* `Port` (number): UDP port to use for sending encapsulated packets. Defaults to 8285.

## Experimental backends

The following options are experimental and unsupported at this time.

### AliVPC

Use AliVPC to create IP routes in a [alicloud VPC route table](https://vpc.console.aliyun.com) when running in an AliCloud VPC. This mitigates the need to create a separate flannel interface.

Requirements:
* Running on an ECS instance that is in an AliCloud VPC.
* Permission require `accessid` and `keysecret`.
    * `Type` (string): `ali-vpc`
    * `AccessKeyID` (string): API access key ID. Can also be configured with environment ACCESS_KEY_ID.
    * `AccessKeySecret` (string): API access key secret. Can also be configured with environment ACCESS_KEY_SECRET.

Route Limits: AliCloud VPC limits the number of entries per route table to 50.

### Alloc

Alloc performs subnet allocation with no forwarding of data packets.

Type:
* `Type` (string): `alloc`

### AWS VPC

Recommended when running within an Amazon VPC, AWS VPC creates IP routes in an [Amazon VPC route table](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Route_Tables.html). Because AWS knows about the IP, it is possible to set up ELB to route directly to that container.

Requirements:
* Running on an EC2 instance that is in an Amazon VPC.
* Permissions required: `CreateRoute`, `DeleteRoute`,`DescribeRouteTables`, `ModifyInstanceAttribute`, `DescribeInstances` (optional)

Type and options:
* `Type` (string): `aws-vpc`
* `RouteTableID` (string): [optional] The ID of the VPC route table to add routes to.
    * The route table must be in the same region as the EC2 instance that flannel is running on.
    * Flannel can automatically detect the ID of the route table if the optional `DescribeInstances` is granted to the EC2 instance.

Authentication is handled via either environment variables or the node's IAM role. If the node has insufficient privileges to modify the VPC routing table specified, ensure that appropriate `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and optionally `AWS_SECURITY_TOKEN` environment variables are set when running the `flanneld` process.

Route Limits: AWS [limits](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Appendix_Limits.html) the number of entries per route table to 50.

### GCE

Use the GCE backend When running on [Google Compute Engine Network](https://cloud.google.com/compute/docs/networking#networks). Instead of using encapsulation, GCE manipulates IP routes to achieve maximum performance. Because of this, a separate flannel interface is not created.

Requirements:
* [Enable IP forwarding for the instances](https://cloud.google.com/compute/docs/networking#canipforward).
* [Instance service account](https://cloud.google.com/compute/docs/authentication#using) with read-write compute permissions.

Type:
* `Type` (string): `gce`

Command to create a compute instance with the correct permissions and IP forwarding enabled:
```sh
  $ gcloud compute instances create INSTANCE --can-ip-forward --scopes compute-rw
```

Route Limits: GCE [limits](https://cloud.google.com/compute/docs/resource-quotas) the number of routes for every *project* to 100 by default.

[alicloud-vpc]: https://github.com/coreos/flannel/blob/master/Documentation/alicloud-vpc-backend.md
[amazon-vpc]: https://github.com/coreos/flannel/blob/master/Documentation/aws-vpc-backend.md
[gce-backend]: https://github.com/coreos/flannel/blob/master/Documentation/gce-backend.md

### IPIP

Use in-kernel IPIP to encapsulate the packets.

IPIP kind of tunnels is the simplest one. It has the lowest overhead, but can incapsulate only IPv4 unicast traffic, so you will not be able to setup OSPF, RIP or any other multicast-based protocol.

Type:
* `Type` (string): `ipip`
* `DirectRouting` (Boolean): Enable direct routes (like `host-gw`) when the hosts are on the same subnet. IPIP will only be used to encapsulate packets to hosts on different subnets. Defaults to `false`.

Note that there may exist two ipip tunnel device `tunl0` and `flannel.ipip`, this is expected and it's not a bug.
`tunl0` is automatically created per network namespace by ipip kernel module on modprobe ipip module. It is the namespace default IPIP device with attributes local=any and remote=any.
When receiving IPIP protocol packets, kernel will forward them to tunl0 as a fallback device if it can't find an option whose local/remote attribute matches their src/dst ip address more precisely.
`flannel.ipip` is created by flannel to achieve one to many ipip network.

### IPSec

Use in-kernel IPSec to encapsulate and encrypt the packets.

[Strongswan](https://www.strongswan.org) is used at the IKEv2 daemon. A single pre-shared key is used for the initial key exchange between hosts and then Strongswan ensures that keys are rotated at regular intervals.

Type:
* `Type` (string): `ipsec`
* `PSK` (string): Required. The pre shared key to use. It needs to be at least 96 characters long. One method for generating this key is to run `dd if=/dev/urandom count=48 bs=1 status=none | xxd -p -c 48`
* `UDPEncap` (Boolean): Optional, defaults to false. Forces the use UDP encapsulation of packets which can help with some NAT gateways.
* `ESPProposal` (string): Optional, defaults to `aes128gcm16-sha256-prfsha256-ecp256`. Change this string to choose another ESP Proposal.

#### Troubleshooting
Logging
* When flannel is run from a container, the Strongswan tools are installed. `swanctl` can be used for interacting with the charon and it provides a logs command..
* Charon logs are also written to the stdout of the flannel process.

Troubleshooting
* `ip xfrm state` can be used to interact with the kernel's security association database. This can be used to show the current security associations (SA) and whether a host is successfully establishing ipsec connections to other hosts.
* `ip xfrm policy` can be used to show the installed policies. Flannel installs three policies for each host it connects to.

Flannel will not restore policies that are manually deleted (unless flannel is restarted). It will also not delete stale policies on startup. They can be removed by rebooting your host or by removing all ipsec state with `ip xfrm state flush && ip xfrm policy flush` and restarting flannel.

repository: ciryu/flannel

repo_name: ciryu/flannel


text:
# Tips and Tricks used in the implementation

## ThreadLocal

In Java, variables are [lexically scoped](https://en.wikipedia.org/wiki/Scope_(computer_science)) but
sometimes you want to create _dynamic_ variable like a current user or a current transaction.
The class [ThreadLocal](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/ThreadLocal.html)
represents thread local variables.

It can be seen as a `Map<Thread, Object>` which has a
different values for each thread. `threadLocal.set(value)` set the value for the current thread,
`threadLocal.get()` returns the value for the current thread and `threadLocal.remove()`
removes the value associated with the current thread.

In order to avoid memory leaks, i.e. an object not being garbage
collected because it is still stored in a thread local variable, we "scope" the variable to the stack
so the thread local variable value is removed when the execution of the method ends.

```java
private static final ThreadLocal<Data> DATA_THREAD_LOCAL = new ThreadLocal<>();

void method() {
  Data data = ...
  DATA_THREAD_LOCAL.set(data);
  try {
    ...
  } finally {
    DATA_THREAD_LOCAL.remove();
  }
}
```

In a close future, there is a proposal to introduce a new class
[ScopeLocal](https://openjdk.java.net/jeps/8263012)
which is faster and always biased to the stack compared to a `ThreadLocal`.

## ClassValue

A [ClassValue](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/ClassValue.html) is
a cache that allows to store information for a `Class`. It can be seen as the equivalent of a
`Map<Class,Object>` but guarantee that classes can be unloaded.

The API works like a cache, the method `get(Class<?>)` try to retrieve the value from the `ClassValue`,
if the value has not be computed, the `ClassValue` calls the method `computeValue` to get the value
that will be stored in the cache for that `Class`.

```java
private static final ClassValue<DATA> DATA_CLASS_VALUE = new ClassValue<>() {
    @Override
    protected Data computeValue(Class<?> type) {
      Data data = ...
      return data;
    }
  };

void method(Class<?> type) {
  Data data = DATA_CLASS_VALUE.get(type);
  ...
}
```

## Default values

Sometimes you want to get the default values (`null`, `false`, `0`, `0.0`, etc) of a `Class`.
The default values is always `null` apart if the class is a primitive type.
Primitive types are represented by a one letter descriptor in the classfile format (the .class file),
accessible using the method
[Class.descriptorString()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#descriptorString()).

```java
private static final Map<String, Object> DEFAULT_VALUES = Map.of(
      "Z", false, "B", (byte) 0, "C", '\0', "S", (short) 0, "I", 0, "J", 0L, "F", 0f, "D", 0.);

Object defaultValue(Class<?> type) {
  return DEFAULT_VALUES.get(type.descriptorString());
}
```

We don't store `null` for void or any object classes because `Map.get()` returns `null`
if there is no corresponding key.

## Reflection

The reflection API, the package `java.lang.reflect`, provide the capabilities to
- ask for the [class of any objects](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Object.html#getClass()) at runtime
- get a description of the class using
  [Class.getFields()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#getFields()),
  [Class.getMethods()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#getMethods()) or
  [Class.getContructors()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#getConstructors())
- [get](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Field.html#get(java.lang.Object)) and
  [set](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Field.html#set(java.lang.Object,java.lang.Object)) `Field` value,
  [invoke](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Method.html#invoke(java.lang.Object,java.lang.Object...)) `Method` or
  [create a new instance from a ](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Constructor.html#newInstance(java.lang.Object...)) `Constructor`
- get annotations and compiler information stored in the classfile (the .class file)

### Class.getMethod(), Class.getMethods(), Class.getConstructors()

To get a specific method (static or not), the method [Class.getMethod()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#getMethod(java.lang.String,java.lang.Class...))
is called on a class and takes the name and the parameter types of the method (not the return type).

```java
  Method method;
  try {
    method = String.class.getMethod("concat", String.class);
  } catch(NoSuchMethodException e) {
    throw (NoSuchMethodError) new NoSuchMethodError().initCause(e);
  }
```
The method may not exist, it that case the usual solution is to stop the execution by propagating
an `Error`, here a `NoSuchMethodError` with the initial [exception chained](https://stackoverflow.com/questions/5020876/what-is-the-advantage-of-chained-exceptions).

The method [Class.getMethods()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#getMethods())
returns **all** the **public** methods

```java
  Method[] methods = String.class.getMethods();
```

### Method.invoke(), Constructor.newInstance()

The method [Method.invoke](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Method.html#invoke(java.lang.Object,java.lang.Object...))
calls the method with an instance and the arguments.

To be able to `invoke` a method, the method has to be accessible which means, if the declaring class
is a different package, that the class that calls `invoke` that
- the method has to be public
- the declaring class of the method has to be public
- the declaring package has to be exported or open

```java
void invokeMethod(Method setter, Object instance, Object[] args) {
  try {
    return method.invoke(instance, value);
  } catch (IllegalArgumentException e) {
    throw new AssertionError(e);
  } catch (IllegalAccessException e) {
    throw (IllegalAccessError) new IllegalAccessError().initCause(e);
  } catch (InvocationTargetException e) {
    throw rethrow(e.getCause());
  }
}

@SuppressWarnings("unchecked")   // very wrong but works
static <T extends Throwable> AssertionError rethrow(Throwable cause) throws T {
  throw (T) cause;
}
```

Here managing the possible exceptions is a little complex
- if the instance is not a subclass of the declaring class, `IllegalArgumentException` is raised,
  this should not append we propagate an AssertionError
- if the method is not accessible `IllegalAccessException` is raised, like with `NoSuchMethodException`
  previously, we throw the corresponding error, here `IllegalAccessError`.
- if when the method is called, the method itself raises an exception, it will be stored inside an
  InvocationTargetException, and we just rethrow it

Rethrowing an exception is Java is unnecessary hard because in Java the compiler want to know if an
exception is checked or not. [There is a hack](https://stackoverflow.com/questions/6302015/throw-checked-exceptions)
that relies on the fact that the checked exception  are only checked by the compiler and that
the erasure of generics allows to see a `throws Throwable` as a `throws RuntimeException` at runtime.
This is exactly what `rethrow()` does here.

The method [Constructor.newInstance()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Constructor.html#newInstance(java.lang.Object...))
calls a constructor with arguments. Like with `Method.invoke`, if a constructor is a different package,
it is only accessible if the constructor is public, the declaring class is public and the declaring
package is exported or open.

```java
Object newInstance(Constructor<?> constructor, Object... args) {
  try {
    return constructor.newInstance(args);
  }  catch (IllegalArgumentException e) {
    throw new AssertionError(e);
  } catch (InstantiationException e) {
    throw (InstantiationError) new InstantiationError().initCause(e);
  } catch (IllegalAccessException e) {
    throw (IllegalAccessError) new IllegalAccessError().initCause(e);
  } catch (InvocationTargetException e) {
    throw rethrow(e.getCause());
  }
}
```

Compared to `Method.invoke`, there is a supplementary exception, `InstantiationException` that is raised
if the declaring class is not a concrete class. Like with `IllegalAccessException`, we propagate the
corresponding error `InstantiationError`.

## Java Bean and BeanInfo

Java Bean is a **convention** to interact at runtime with a class instance sees as container of
properties.
The class [Introspector](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/Introspector.html)
returns a [BeanInfo](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/BeanInfo.html)
describing the class taken as parameter as a Java Bean.

A property is a virtual entity defined by the presence of a method that starts with `get` or `is`
and/or a method that starts with `set`. By example, the code below defines a property `name`
of type `String`.
```java
public class Person {
  String getName() { ... }
  void setName(String name) { ... }
}
```

The method [beanInfo.getPropertyDescriptors()](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/BeanInfo.html#getPropertyDescriptors())
returns the properties i.e. a [name](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/FeatureDescriptor.html#getName()),
a [type](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/PropertyDescriptor.html#getPropertyType())
and a [read method](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/PropertyDescriptor.html#getReadMethod())
also called a getter and a [write method](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/PropertyDescriptor.html#getWriteMethod())
also called a setter.

```java
void method(Class<?> type) {
  BeanInfo beanInfo;
  try {
    beanInfo = Introspector.getBeanInfo(beanType);
  } catch (IntrospectionException e) {
    throw new IllegalStateException(e);
  }

  PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
  for(PropertyDescriptor property: properties) {
    String name = property.getName();
    Class<?> type = property.getType();
    Method getter = property.getReadMethod();
    Method setter = property.getWriteMethod();
    ...
  }
}
```

The method [Introspector.decapitalize()](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/beans/Introspector.html#decapitalize(java.lang.String))
provides the property name from a method name without its prefix `is`, `get` or `set`.

```java
void method(String methodName)
  if (methodName.length() > 3 && methodName.startsWith("get")) {
    String propertyName = Introspector.decapitalize(methodName.substring(3));
    ...
  }
}
```

## Record

A record is a named tuple composed of ordered [components](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/RecordComponent.html)
that can be queried at runtime.

```java
public record Person(String name, int age) {}
```

The method [Class.isRecord()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#isRecord())
returns `true` is a class is a record.
The method [Class.getRecordComponents()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#getRecordComponents())
returns an array of the record components or `null`.
A record component is kind a like a Bean property, it is defined by
- [a name](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/RecordComponent.html#getName())
- [a type](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/RecordComponent.html#getType())
- [an accessor](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/RecordComponent.html#getAccessor()) (a getter, records are not mutable)

```java
void method(Class<?> type) {
  if (!type.isRecord()) {
    ...
  }
  RecordComponent[] components = type.getRecordComponents();
  for(RecordComponent component: components) {
    String name = component.getName();
    Class<?> type = component.getType();
    Method accessor = component.getAccessor();
    ...
  }
}
```

## Dynamic Proxy

A _dynamic_ proxy is a class generated at runtime that implement a list of interfaces, this is
done by generating the classfile in an array of bytes at runtime and uses a
[ClassLoader](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/ClassLoader.html)
to load that array of bytes as an actual class.

### InvocationHandler, Proxy.newProxyInstance()

A _dynamic_ proxy uses an [InvocationHandler](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/InvocationHandler.html),
a functional interface that will be called to implement each method of the proxy.
An `InvocationHandler` takes as parameter the proxy instance, the method to implement, and the arguments
of the method call and asks for the return value.

```java
InvocationHandler invocationHandler =
    (Object proxy, Method method, Object[] args) -> {
      ...
    };
Object proxy = Proxy.newProxyInstance(type.getClassLoader(),
    new Class<?>[] { type },
    invocationHandler);
```

The method [Proxy.newProxyInstance](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Proxy.html#newProxyInstance(java.lang.ClassLoader,java.lang.Class[],java.lang.reflect.InvocationHandler))
takes a classloader (usually the classloader using to load the interfaces to implement),
an array of interfaces to implement and an instance of `InvocationHandler` and returns an object
(the proxy) that implements all the interfaces.

Each time a method is called on that proxy instance, the corresponding `InvocationHandler` is called
with the interface method called.

### Proxy.isProxy() and Proxy.getInvocationHandler()

Sometimes it's important to know if an object is a proxy that is using a specific class as
`InvocationHandler`. The method [Proxy.isProxyClass()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Proxy.html#isProxyClass(java.lang.Class))
returns `true` is the class is a proxy class generated by a call to `Proxy.newProxyInstance`.

If an instance is a proxy instance, the method [Proxy.getInvocationHandler()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Proxy.html#getInvocationHandler(java.lang.Object))
retrieve the `InvocationHandler` of a proxy instance so can be used to know if the proxy is a
known proxy or not.

```java
import java.lang.reflect.Proxy;

class MyInvocationHandler implements InvocationHandler {
  @Override
  public Object invoke(Object proxy, Method method, Object[] args) {
    ...
  }
}

void method(Object o) {
  if (Proxy.isProxyClass(o.getClass())) {
    ...
  }
  InvocationHandler invocationHandler = Proxy.getInvocationHandler(o);
  if (invocationHandler instanceof MyInvocationHandler myInvocationHandler) {
    ...
  }
}
```

## Annotation

An annotation is a user defined modifier containing a `Map` of constants values that can be queried
to retrieve those values associated with a class, a field, a method, a record component, etc.

### Declaration and meta-annotations

An annotation is declared with the keyword `@interface`.
At runtime, an annotation is equivalent to an interface that provides a typesafe access to
a Map that stores constant values.

The method of an annotation are abstract with no parameter and only accept types that are
type of constants for the compiler (primitive types, String, Enum, annotations, arrays of those types).

```java
@interface MyAnnotation {
  String value();
}
```

The annotation above declare that instance of that annotation will store a value of type String.

Annotation uses meta-annotation, annotations that you declare on an annotation to specify
- if the annotation is available at runtime
- the type of elements of the language (an [AnnotatedElement](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/AnnotatedElement.html),
  i.e. classes, field methods, etc) that accept that annotation

```java
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@interface Marker {
}
```

If an annotation has the `Retention` `RUNTIME`, it's values will be available at runtime.

### Method.isAnnotationPresent(), Method.getAnnotation(), Method.getAnnotations()

The method [AnnotatedElement.isAnnotationPresent()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/AnnotatedElement.html#isAnnotationPresent(java.lang.Class))
returns `true` if the annotated element is annotated with the annotation taken as argument.

```java
void method(Class<?> type) {
  boolean isPresent = type.isAnnotationPresent(Marker.class);
  ...
}
```

The method [AnnotatedElement.getAnnotation()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/AnnotatedElement.html#getAnnotation(java.lang.Class))
return the annotation or `null` if the annotation is not present (or is not a runtime annotation).
Once the annotation is retrieved, the constants values can be read using the methods of the annotation.

```java
void method(Method method) {
  MyAnnotation myAnnotation = method.getAnnotation(MyAnnitation.class);
  if (myAnnotation != null) {
    String value = myAnnotation.value();
    ...
  }
}
```

It is also possible to get all the annotations declared on an `AnnotatedElement` using the method
[AnnotatedElement.getAnnotations()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/AnnotatedElement.html#getAnnotations()).

```java
void method(Constructor<?> constructor) {
  Annotation[] annotations = constructor.getAnnotations();
  ...
}
```

## Java Compiler generics attributes

Parametrized types, named generics in Java, are verified at compile time but disappear at runtime (_erasure_).
In order to allow separate compilation ; a library, and an application compiled independently ;
the compiler insert a special attribute into the classfile.

These attributes can be retrieved at runtime using the methods following the pattern `getGeneric*()`
on the class, method, field, etc.
For example, the method [Class.getGenericInterfaces()](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Class.html#getGenericInterfaces())
returns the interfaces of a class as an array of [Type](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Type.html).

A `java.lang.reflect.Type` can be
- a [parameterized type](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/ParameterizedType.html)
- a [generic array](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/GenericArrayType.html)
- a [type variable](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/TypeVariable.html)
- a [wildcard](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/WildcardType.html)

A `java.lang.Class` represents a class or interface at runtime so a `Class` like `List`
does not have a type argument (`List` not `List<String>`). A `Type` represents a type
computed by the compiler, so it can be a parameterized type, with wildcards, etc.

```java
void method(Class<?> type) {
  Type[]  genericInterfaces = type.getGenericInterfaces();
  for(Type genericInterface: genericInterfaces) {
    switch(genericInterface) {
      case Class<?> clazz -> ...                      // e.e. String.class
      case ParameterizedType parameterizedType -> {   // e.g. List<String>
        Class<?> rawType = (Class<?>) parameterizedType.getRawType();
        Type[] typeArguments = parameterizedType.getActualTypeArguments();
        ...
      }
      case GenericArrayType genericArrayType -> ...  // e.g. List<String>[]
      case TypeVariable<?> typeVariable -> ...       // e.g T
      case WildcardType wildcardType -> ...          // e.g ? extends String
    }
  }
}
```


text:
---
title: "The Most Appropriate Gift Ever"
date: "2015-01-06T10:12:03.284Z"
---

<iframe width="560" height="315" src="https://www.youtube.com/embed/Io7h1KuToyo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

1/6/2015 Team Everly Update — The doctors think Everly is getting worse. We’re praying for Everly’s lungs to surprise us. In better news, Everly is less dependent on her IV.

An OI parent gave us a gift. It’s called a D*mmit Doll. It helps you take out your frustration without destroying anything else. It’s been the most appropriate gift ever.

Here’s a video of me trying it out after a rough day. That was a few days ago, and today has been much worst.

We had a care conference with our medical team. The consensus of the team is that Everly is in a very tight spot and isn’t getting better. She has pulmonary hypoplasia, which means her lungs never had the proper space to properly develop and grow.

Here’s the part of the meeting that stung. The medical ethics representative (basically the counselor and liaison between the parents and medical team) said, sure the medical team as a whole doesn’t have a deep knowledge of OI since it’s so rare. Only a handful of OI babies have been born at this hospital.

But, that doesn’t mean the medical team doesn’t have a deep knowledge of lungs. If you take OI completely out of the picture and the team were to just treat Everly’s lungs, regardless of how they got that way, they were, their prediction is the same. Everly’s lungs aren’t capable of working properly without heavy support.

Ouch.

I had a whole pep talk ready, but I didn’t have a comeback for that. What the counselor said made sense.

We trust our medical team and know they are trying to do what is right for Everly, so it’s hard that their words ring true. We have been amazed by their care. Even though they are already at this place, the medical team is ultimately looking to Colby and I to interpret what Everly is saying. Right now, we still believe Everly is saying “Hey, I’m in the fight!”

The medical team is still treating her based on our wishes to give her the best chance she has of a long, boring life that ends watching Doomsday Preppers and eating chicken nuggets into her old age.

We’re praying that Everly’s lungs surprise the doctors and that in the coming days we see Everly require less and less ventilator and oxygen support.

This is her primary battle. If we don’t win this one, the whole war is lost.

However, Everly is surprising us in a smaller battle. As mentioned yesterday, her umbilical cord IV is a ticking time bomb. It’s been 10 days since it was put in. Every day we leave it in carries with it a higher chance of infection. Or it could just stop passing fluids.

Our strategy is to ween Everly off of IV support rather than put in a second IV. There aren’t other IV options that carry heavy risks for Everly. And we think it’s possible to care for Everly without IVs by transitioning her pain medicine to be given orally rather than by IV.

Today Everly made the transition and she’s completely off IV pain medicine. She’s no longer receiving IV Fentanyl and in it’s place she’s receiving oral morphine. This is a huge step for Everly.

Besides pain management, her IV provided an access point for keeping Everly hydrated and for providing antibiotics when she may need them.

Both these challenges seem small compared to switching over pain medicine to oral drugs as she just wasn’t having it when we tried it before. The trick was increasing the base dose of morphine and then Everly tolerated the ween.

Everly has also been showing signs of needing less oxygen today as her morphine has increased. We don’t just need progress in this area though. Perhaps the more important thing we need in weening her from the ventilator is being able to reduce the amount of pressure the ventilator is using when assisting with breaths.

We know God is using Everly. It may not be in the way we want, but we’re trying to listen to God’s voice as we we are also trying to interrupt Everly’s.

We’ve been overwhelmed by how many people are praying for us and reaching out. Thank you thank you!

Today’s lesson: Having a stack of kleenexs in my pocket is my gift to the world.

Please pray that:

- Everly will be able to breathe more on her own and we’ll be able to ween her off of the ventilator.
- God will bring us all closer to Him.
- We’ll continue to become less dependent on the umbilical cord IV so that we can remove it.

Much love from Team Everly

repository: nathantbaker/everly

gha_language: JavaScript

repo_name: nathantbaker/everly


text:
---
layout: page
exclude: true
title: Cloudfront
---

Cloudfront in Amazon's CDN or **Content Delivery Network** which is a system of servers distributed geographically that serves content to users based on:

- user location
- webpage origin
- delivery server

Cloud is a **network and content delivery** feature.

An **edge location** is a located server which caches content to be delivered. Files are cached at edge locations according to a `TTL` or **Time to Live**. A `TTL` is given is seconds and is typically around 48 hours. The default Amazon TTL is 24 hours or 86400 seconds.

An **origin** is the location of the S3 bucket where the content was originally placed and which will be distributed by the CDN.

A **distribution** is a collection of edge locations that serve content.

Cloudfront **automatically roots user requests** to the fastest location to get content.

There are two types of cloudfront distribution:

- **Web Distribution** (fort websites)
- **RMTP** (for streaming adobe flash media RMTP media)

You can setup cloudfront to distribute S3 content when creating a new distribution.

You can use **restrict bucket access** to only allow users to access S3 content hosted via cloudfront through the CDN by changing the `Restrict Bucket Access` option to `Yes` when creating a distribution.

New cloudfront distributions typically take quite a while to set up at 30 minutes to an hour of creation time.

You can access cloudfront content by visiting the `Domain Name` of the cloudfront content which will be a random string followed by `.cloudfront.net`.

You can **use edge locations for writing and uploading files**.

You will be **charged for clearing cached objects**.

You can **delete a cloudfront distribution** by first selecting it and using the `Disable` option. It will take a while to be taken down and it can then be deleted.

## Caching

You can **disable cloudfront caching** (usually for the purposes of prototyping.

1. Navigate to the Cloudfront distribution you want to modify.
2. Go to the `Behaviors` tab and select the behavior pattern you want to change.
3. Click the `Edit` button above.
4. Change the `Caching Policy` section to `Managed-CachingDisabled`.

## OAI

You can use **Origin Access Identity** to **give cloudfront access to the contents of a restricted S3 bucket**.

1. Go to a cloudfront distribution that has been set up with an S3 origin
2. Go to the `Origins and Origin Groups` tab and selected the S3 origin you want to give access to and click `Edit`
3. Set `Restrict Bucket Access` to `yes`
4. If you don't have an OAI user then selected `Create a New Identity` otherwise use an existing one.
5. Select `Yes, Update Bucket Policy` to update access to the S3 origin with this user.
6. Click `Yes, Edit`

Origin Access Identity uses a Cloudfront access role which you can view by going to the `Origin Access Identity` tab in the Cloudfront dashboard.

## Access Denied and File Targeting

If you try to access a cloudfront distribution without specifying an object from the bucket that the distribution targets you will receive an **access denied error**. Instead, you need to add an extension that specifies the specific object. For example, if you have an object if your bucket called `index.html` then you would need to use the cloudfront URL and the name of the file.
```
GET http://cloudfronturl.com/<FILE_IN_BUCKET>
```

You can also **set a default root object** that will default to a file in the bucket.

gha_language: HTML


text:
# Random Quote Machine
 _A Pen created at CodePen.io. Original URL: [https://codepen.io/trowk/pen/vYEagyZ](https://codepen.io/trowk/pen/vYEagyZ).

extension: markdown


text:
---
layout: post
title: Things I Wish I Learned When Starting Web Development
date: 2014-09-04 00:30
author: Ben Chung
comments: true
category: web-developer-advice
category_name: Web Developer Advice
---
Here are some hopefully useful notes on things I wish I got really good at early on, but in some cases - didn't find out about until later in my career.... Of=course this is just my opinion and there are a lot of different directions to take in the world of web development:

Command Line

I came form a graphics background so using a GUI was all I knew and wanted to know for a long time. I used to be afraid of that little black screen of death but when I started to use it more and learn the shortcuts I realized I was missing out on a whole world of tooling and server administration. This is used extensively when working with Linux (most servers on the web use it). Any serious web developer knows and uses the command line on a regular basis. Learn it little by little, it's really not that bad.

JavaScript

JavaScript it probably the most sought after skill on the web right now. This is because of the rise of some important frameworks over recent years.

Try to have a good handle on it rather than just a quick overview. Understand that it's very different than other programming languages and understand the “weird parts”. This is what makes it powerful.

If you love JavaScript and want to get serious about it, learn ES6, Node.js and an MVC framework like Angular, React, Ember or backbone. JQuery is essential.

PHP frameworks: Symphony and/or Laravel

These are the two most popular frameworks used in modern PHP development. Symphony has been around for a while and has become kind of a standard. Laravel is newer but has gained mass popularity. There are frameworks for every language so pick the one that is right for you. The goal is to use it to build faster and with best practices.

SASS

Use a CSS pre-compiler like SASS or LESS. You’ll be able to write CSS like an object oriented language and gain other advantages like minifying on save and polyfills. It’s also becoming somewhat of a standard for professionals.

GitHub

Advantages:

Share you code with others (can help with publicity)

Use it like a server or sub-version control. You can upload to it or download from it quickly from any location and control your changes, branches, etc.

Collaborate with other developers – enable work on the same project together without stepping on each other’s toes.

Companies and professionals often use it for the above purposes internally and if you are already using it, it would be good for your resume.

Have employers look at your code through GitHub when applying to jobs.

Quick note: use it with the command line if possible as it would be quicker once you get going and would be good for experience.

HTTP

Have an understanding of how information is communicated over the internet. Some good subjects are:

Domains,

TCP/IP,

HTTP,

Email and web hosting,

.htaccess

SSH

Regular expressions (important for PHP, JavaScript and mod_rewrite)

Understand how HTTP and Servers work. Many newer web frameworks are centered on the concept of HTTP and using it to your advantage.

Developer Tools

Good code editors:

Sublime text

Brackets

Visual Studio

Visual studio code

Notepad++

Atom

(All good in different ways)

Essential tools:

Developer tools to develop live in the browser like your browser’s developer tools or Firebug (for firefox).

Responsive design tools like responsive design view (for Firefox), iPhone/iPad simulators, etc.

Online code formatting tools (format/compress/ decompress JavaScript, HTML, XML, JSON, etc.)

Use Vagrant or Docker for setting up a test server for local development (instead of XAMP, WAMP, LAMP)

SEO

Even if you're not planning on offering it as a service, you're going to need to know how it works. To have a fair understanding of it is actually not a difficult task especially if you already used to working with html and have a fair understanding of how search engines work.

HTML5 CSS3

These are things you'll learn on the job, but it would be worth it to research ahead of time since it will help you do modern web design. Your Websites will be more efficient and some modern techniques can save you some time (in most cases).

Responsive Frameworks

Responsive frameworks like Foundation or Bootstrap will save huge amounts of time and get you started with a good base. Make sure to understand how they work though.

Specializing

Try to find what you like and specialize if you can. There’s far too much out there to be an expert at everything.

Blogging

1 hour a week, even 1/2 hour. You don’t have to be an expert right away, just blog about what you’re using for the moment. Traffic will increase over time, then you can use that traffic for whatever you want. You won't regret it.

Self Education

You’re responsible for keeping up to date with the standards and they change really fast! (Too fast in a way). Here are some good flexible/affordable resources for video training:

Udemy

Udacity

Treehouse


text:
---
published: true
---
Adding metrics to your microservices is now a non-negotiable. Luckily Spring Boot has built in capabilities for this using micrometer. Prometheus is a timeseries database that makes it easy to analyze the raw numbers streaming from your server.

I faced some trouble in exposing metrics but in the end brute-forced to this combination.

## Modules

In gradle file:

```
spring-boot-starter-web: 2.0.0.RELEASE
spring-boot-starter-actuator: 2.0.2.RELEASE
micrometer-registry-prometheus: 1.0.1
```

## Properties

properties.yaml:
```
management:
    endpoints:
        web:
            exposure:
                include: prometheus,metrics,info,health
```

## Test

```
http GET http://localhost:8080/actuator/prometheus
```


text:
# Clavardage

![alt text](./Clavardage.png "ScreenShot")

Login page

![alt text](./Clavardage_login.png "ScreenShot")

## Have tree modes:

+ A Test mode:  To open multiple clients on same machine, for testing purpose
+ Broadcast mode for local networks
+ A centralized mode with a Server on ip address http://node6669-clavadage.jcloud.ik-server.com/webapi/

## Requirements
+ Java Runtime Environment 8 is recommended. It should works on higher versions but not tested.
Please report any issue.
+ JavaFx Runtime

## Usage

+ Execute chat.jar
+ or from console run `java -jar chat.jar`

NB: The Jar file must be in the root directory of the project because it use resources located in
```
.
+-- diagrams
+-- libs
+-- src
|   +-- main
|       ..
|       +-- resources
+-- chat.jar
```
## Development Requirements

+ JDK >= 1.8
+ Maven

repository: Faymir/Clavardage

gha_language: Java

repo_name: Faymir/Clavardage


text:
# Conversionista's Experiment Feasibility Calculator a.k.a _Can I test that?_

So, how long should you run your A/B test?

There are 4 pieces of information that we need to know in order to answer that quesion:

- Conversion Rate of original page
- Number of variations to test (more variations you test, more traffic you need)
- Average daily traffic on your site (not really needed, optional)
- What % difference in conversion rate do you want to detect (if you want to detect even the slightest improvement, it will take much longer)

The last point is really, really hard to esitmate. So we buildt this tool.

![Distribution](https://s3.amazonaws.com/f.cl.ly/items/1p150D1B1f2V2o262Q0K/Image%202016-05-30%20at%207.51.42%20PM.png)

The graph above is taken from an excellent book called Statistical Rules of Thumb. Luckily, the [chapter on estimating sample size is available to download freely](http://www.vanbelle.org/chapters/webchapter2.pdf). Another excellent source to get more information on sample size estimation for A/B testing is Microsoft’s paper: [Controlled Experiments on the Web: Survey and Practical Guide](http://www.springerlink.com/content/r28m75k77u145115/fulltext.pdf).

repository: Conversionista/can-i-test-that

repo_name: Conversionista/can-i-test-that


text:
# md-kumihan

## Overview

md-kumihan is simple tool for building pdf file from markdown.

## Usage

```
node build.js
```

After running this command, `src/test.md` is converted to `pdf/test.pdf`.

### param.json

input the path of markdown which you'd like to change to pdf.

### css/pdf.css

the stylesheet which is used to decorate the body of document.

### render-pdf.js

the script which is used to render a pdf. Contents and decoration of the header and footer is included in this script.

## Requirement
- kramdown
- phantomjs

## Install

```
sudo yum install git rubygems nodejs
sudo gem install bundler
bundle install --path vendor/bundle
git clone https://github.com/kongou-ae/md-kumihan.git
cd md-kumihan/
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
tar jxfv phantomjs-1.9.8-linux-x86_64.tar.bz2
mv phantomjs-1.9.8-linux-x86_64 phantomjs
node build.js
```

default `pdf.css` is used `IPAexGothic`. Installation of `IPAexGothic` is as below.

```
cd /tmp/
wget http://ossipedia.ipa.go.jp/ipafont/ipaexfont/IPAexfont00201.php
unzip IPAexfont00201.php
sudo mv IPAexfont00201 /usr/share/fonts/
fc-cache -fv
```

## Contribution

1. Fork ([https://github.com/kongou-ae/md-kumihan/fork](https://github.com/kongou-ae/md-kumihan/fork))
1. Create a feature branch
1. Commit your changes
1. Rebase your local changes against the master branch
1. Create new Pull Request

## Author

[kongou-ae](https://github.com/kongou-ae)

repository: kongou-ae/md-kumihan

repo_name: kongou-ae/md-kumihan


text:
---
layout: post
title: "Simulate Prolog backtracking using Scala Stream"
description: ""
categories: [Technology, Programming]
tags: [Prolog, Scala, Backtracking, Stream]
---

It's a kind of interesting problem. For a bunch of algorithms or data structures,
it is fairly easy and very straight forward using Prolog to solve. And
with backtracking, it is just a matter of `;` to get next solution and `findall`
to get everything back, or even `findnsols` to get at most N solutions.

When it comes to Scala (or basically any other non-declarative language), things
are a bit of complicated. The fundamental reason is one has to explicitly think
about how to compute all solutions.

As an example, let's take a look at one of the p-99 problems described
[here](https://sites.google.com/site/prologsite/prolog-problems/6), 6.02.

One of the possible Prolog solutions could be:

```prolog
path(G, A, B, P) :-
    path(G, A, B, [A], P0),
    reverse(P0, P).
path(_, A, A, P, P) :- !.
path(G, A, B, P0, P) :-
    neighbour(G, A, N),
    \+ memberchk(N, P0),
    path(G, N, B, [N|P0], P).

neighbour(graph(_, E), A, N) :-
    member(e(A, N), E);
    member(e(N, A), E).
```

The above snippet focuses on how to compute one and only one solution and the
backtracking point is generated by `member` and `;`.

One can then ask Prolog to compute next, next next solution, ...

What would be a Scala simulation of this kind of lazy computation? Naturally
`Stream`.

```scala
def neighbours[T](graph: Graph[T], node: T) = {
  if (!graph.nodes.contains(node)) Nil
  else
    graph.edges.collect {
      case (x, neighbour) if (x == node) => neighbour
      case (neighbour, x) if (x == node) => neighbour
    }
}

def path[T](graph: Graph[T], from: T, to: T) = {
  def path0[S](graph: Graph[S], from: S, to: S,
               visited: List[S]): Stream[List[S]] = {
    if (from == to) Stream(List(to))
    else
      neighbours(graph, from).toStream.filterNot(visited.contains(_)).flatMap { x =>
        path0(graph, x, to, from :: visited).map(from :: _)
    }
  }

  path0(graph, from, to, Nil)
}
```

Of course `Stream` doesn't ease at all the complexity because one still needs to think
about all solutions explicitly as shown by `flatMap`. But, it does the lazy computation,
because after computing all neighbours of a node, a `Stream` is generated and whatever
after that is computed lazily.

As all the other Scala collections, `Stream` has a lot of functions one can then use to
retrieve solutions.

As I went though p-99 using Scala, this pattern appears over and over again, so it is
worth to document.

gha_language: SCSS


text:
# MLPerf Inference Reference Implementations

This is a repository of reference implementations for the MLPerf inference benchmark suite.

Reference implementations are valid as only starting points for benchmark implementations. They are not fully optimized, and they are not intended to be used for "real" performance measurements of software frameworks or hardware platforms. The objective is for hardware and software vendors to take these reference implementations, optimize then, and submit them as optimized solutions to the MLPerf Inference call for submissions.

# Preliminary release (v0.5)

MLPerf infernece release is very much an "alpha" release -- it could be improved in many ways. The benchmark suite is still being developed and refined. Please see the suggestions section below to learn how to contribute. We anticipate a significant round of updates post v0.5 call for submission. Much of the input would be taken into account for v0.6.

# Benchmarks

We provide reference implementations for each of the 5 benchmarks in the MLPerf inference suite:

| Area     | Task                 | Model             | Dataset            | Quality Target | Latency Constraint |
|----------|----------------------|-------------------|--------------------|----------------|--------------------|
| Vision   | Image classification | Resnet50-v1.5     | ImageNet (224x224) | TBD            | TBD                |
| Vision   | Image classification | MobileNets-v1 224 | ImageNet (224x224) | TBD            | TBD                |
| Vision   | Object detection     | SSD-ResNet34      | COCO (1200x1200)   | TBD            | TBD                |
| Vision   | Object detection     | SSD-MobileNets-v1 | COCO (300x300)     | TBD            | TBD                |
| Language | Machine translation  | GNMT              | WMT16              | TBD            | TBD                |

Each reference implementation provides the following:

* Code that implements the model in at least one framework.
* A Dockerfile which can be used to run the benchmark in a container.
* A script which downloads the appropriate dataset.
* A script which runs and times training the model.
* Documentation on the dataset, model, and machine setup.

# Running Benchmarks

These benchmarks have been tested on the following machine configuration:

* 16 CPUs, one Nvidia P100.
* Ubuntu 16.04, including docker with nvidia support.
* 600GB of disk (though many benchmarks do require less disk).
* Either CPython 2 or CPython 3, depending on benchmark (see Dockerfiles for details).

Generally, a benchmark can be run with the following steps:

1. Setup docker & dependencies. There is a shared script (install_cuda_docker.sh) to do this. Some benchmarks will have additional setup, mentioned in their READMEs.
2. Download the dataset using `./download_dataset.sh`. This should be run outside of docker, on your host machine. This should be run from the directory it is in (it may make assumptions about CWD).
3. Optionally, run `verify_dataset.sh` to ensure the was successfully downloaded.
4. Build and run the docker image, the command to do this is included with each Benchmark.

Each benchmark will run until the target quality is reached and then stop, printing timing results.

Some these benchmarks are rather slow or take a long time to run on the reference hardware (i.e. 16 CPUs and one P100). We expect to see significant performance improvements with more hardware and optimized implementations.

# Suggestions

We are still in the early stages of developing MLPerf and we are looking for areas to improve, partners, and contributors. If you have recommendations for new benchmarks, or otherwise would like to be involved in the process, please reach out to<EMAIL_ADDRESS>For technical bugs or support, email<EMAIL_ADDRESS>

repository: minus-one/inference

repo_name: minus-one/inference


text:
# OVOS Dashboard Application

# Installation & Startup Steps

``` bash
export MYCROFT_SKILLS_LOCATION="your skills folder location"
git clone https://github.com/openvoiceos/ovos-dashboard
cd ovos-dashboard
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python app.py
```

repository: Asgardrobotics/OVOS-Dashboard

repo_name: Asgardrobotics/OVOS-Dashboard


text:
vn-workshop
===========

**Visual Novel Workshop** (vn-workshop) is an intuitive yet powerful prototyping tool for visual novel and graphic novel creators.

(In very-early development stage)

## Our goal

To create a browser-based prototyping and project management tool for individual creator as well as small dev-team. It should satisfy following use cases:

1. Let creators focus on creating content, handle the burden of asset management automatically and faultlessly.
2. Allow for fast prototyping via intuitive interface, and produce demos that are runnable on common browsers and devices.
3. As the name *workshop* implies, this tool not only enables efficient resource sharing and collaboration between team members, but also integrate with open community for resource and idea exchange.

## Pending tasks

- a resource bank with simple version control, for managing assets such as scripts and images.
- a GUI for fast prototyping.
- an environment for running demos.
- a common api for third-party service integration.

## Comments are welcomed

We are open for ideas, submit yours here: https://github.com/bitinn/vn-workshop/issues

vn-workshop (中文简介)
======================

**视觉小说工坊** (vn-workshop) 是一套直观又不乏功能的，专为视觉小说/绘本小说创作者设计的，原型创作与协作工具。

(仍在开发初期)

## 我们的目标

打造一个基于浏览器环境的原型创作与项目管理工具，针对独立开发者或小团队的以下需求——

1. 让创作者把心思放在创作上，提供一个全自动与容错性强的环境，为他们免去管理各种资源的烦恼。
2. 提供一个直观的界面让开发者能快速打造作品原型，输出可在常见浏览器和设备上运行的Demo。
3. 如名字中的“工坊”暗示，这个工具不仅能提高团队协作与资源管理的效率，还将与开放社区结合，提供交换创意与资源的机会。

## 目前计划

- 一个有版本控制功能的资源存储，用于管理类似脚本和图片的资源。
- 一个适于快速开发的原型设计界面。
- 一个基于浏览器的Demo运行环境。
- 一个统一的API，用于整合第三方服务。

## 欢迎提出建议

我们期待你的参与，在这个页面提交你的建议: https://github.com/bitinn/vn-workshop/issues

repository: bitinn/vn-workshop

repo_name: bitinn/vn-workshop