text:
---
layout: post
title: "Rebuilding Gray Duck Labs with Octopress"
author: "Charles Worthington"
date: 2012-11-04 00:25
comments: true
categories: [Gray Duck Labs]
---

When I chose to leave my awesome [strategy consulting job](http://www.altvil.com) to pursue a freelancing career in product design and development, creating a brand to represent myself was one of the first projects I worked on. In a way, I was my own first "client."

Gray Duck Labs was the outcome of this effort. I created a portfolio of branded documents, including a letterhead, a slide and wireframing template, business cards, and of course, a web site.

{% img /images/posts/grayducklabs_old_screenshot.png Screenshot of the old Gray Duck Labs site %}

Since this effort coincided with a personal push to refresh my web development skills, I took the opportunity to design and code my own site, including writing my own blogging engine in Ruby on Rails. Initially I was happy with the result (I kept [a copy live on Heroku](http://grayducklabs.herokuapp.com) if you're interested). As time passed, however, I became frustrated with the limitations of the blog engine I had created. For example, my engine lacked:

- Social sharing buttons
- An article index
- Article tagging
- Named page routes
- Comments

None of these features are revolutionary. In fact, these are problems that have been solved [many](http://www.wordpress.org) [times](http://www.blogger.com) [over](http://www.squarespace.com). As I became busy with actual client work, I found less appeal in the idea of writing these features from scratch "for fun."

Enter [Octopress](http://www.octopress.org). Octopress is a Ruby framework that extends [Jekyll](https://github.com/mojombo/jekyll) to allow you to generate a static site that includes many features that would normally require a dynamic web application.

<!-- more -->

I chose to use Octopress because it includes many key features out of the box, including social integration and a responsive layout. Being built with Ruby, it was also a good match for my skill set.

I wound up customizing the implementation much more than I was expecting going in. This was because Octopress's default theme (and most of the [third party themes](https://github.com/imathis/octopress/wiki/3rd-Party-Octopress-Themes)) are very blog-centered, and apparently not intended to host static marketing content. If you're interested in the gory details of how I created the site you're looking at, you can [check out the source code on GitHub](https://github.com/cew821/grayducklabs).

Overall, I'm happy with the transition. I like the design changes I made to the marketing content, and despite the heavy customization required it was helpful to use Octopress' themes as a starting point for my own responsive design.

But the main benefit to this change is that I can now focus on the content. Writing a new post is as easy as dropping a text file into the `/posts` directory and running `$ rake generate` and `$ git push heroku`.

#### Why this might be a bad idea

In the immediate term, the new site is definitely an improvement, but I do have a few reservations. Mainly, these boil down to two issues:

- **I need my development machine to make a new post.** Before, I could just log in to my Rails app from any computer to make a change. Now, pushing an update from a location other than my development machine would require a non-trivial configuration process. I also won't be able to update the blog from a mobile device.
- **It will be nearly impossible for non-coders to contribute.** Though Gray Duck Labs is just me for now, it's not inconceivable that at some point there will be other folks I want to contribute to this blog. In a traditional web app (including in my basic Rails implementation), this would be no problem. With Octopress, other contributors would need the ability to make pull requests to my GitHub repo. Fine for developers, pretty much unusable for everyone else.

I suspect if it ever gets to that point I'll wind up migrating to a more traditional database-driven blog engine like Wordpress. But until then, I'm happy to be 'blogging like a developer.'

If you've been using Octopress or Jekyll for your company blog and encountered these issues, or if you'd like to learn more about my experience, [drop me a line](mailto:%63%6f%6e%74%61%63%74@%67%72%61%79%64%75%63%6b%6c%61%62%73.%63%6f%6d).


text:
# Haxe GameCenterManager

*Don't use this. These bindings are unfinished, and GameCenterManager was [rewritten](https://github.com/nihalahmed/GameCenterManager/tree/swift-refactor) in Swift. So this haxelib is out of date and deprecated.*

[GameCenterManager](https://github.com/nihalahmed/GameCenterManager) Haxe bindings for Mac OSX and iOS.

### Features

Supports:
* Sync, submit, save, retrieve and track Game Center leaderboards, achievements and challenges.
* Customizable listener for reacting to Game Center events.
* Single API for Game Center across iOS and Mac OSX.

Doesn't Support:
* Fetching player challenges.
* Exposing local player data or profile images to Haxe.

Here is the demo:

![Screenshot of it working](https://github.com/Tw1ddle/haxe-gamecentermanager/blob/master/demo/screenshots/unavailable.png?raw=true "Screenshot")

### Usage ###

```haxe
import extension.gamecentermanager.GameCenterManager;
import extension.gamecentermanager.GameCenterManagerListener;

GameCenterManager.setupManager();
GameCenterManager.setListener(new GameCenterManagerListener()); // Extend the default listener to manage events yourself
GameCenterManager.authenticateUser();

// A bit later...
if(GameCenterManager.isGameCenterAvailable()) {
	GameCenterManager.presentLeaderboards();
}

// Later...
if(GameCenterManager.isGameCenterAvailable()) {
	GameCenterManager.saveAndReportScore("my_leaderboard_id", 9001, GameCenterSortOrder.HighToLow);
	GameCenterManager.saveAndReportAchievement("my_achievement_id", 100.0, true);
}
```

Refer to the [GameCenterManager documentation](https://github.com/nihalahmed/GameCenterManager) and the headers for explanations of what each method does. Also see the demo app bundled in this distribution.

### Notes ###
The ndlls must be compiled with the ```-DOBJC_ARC``` flag.

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# Google Analytics Plugin: Clean URLs [![Build Status](https://travis-ci.org/MethodGrab/ga-clean-urls.svg?branch=master)](https://travis-ci.org/MethodGrab/ga-clean-urls) [![npm](https://img.shields.io/npm/v/ga-clean-urls.svg)](https://www.npmjs.com/package/ga-clean-urls) ![File Size](http://img.badgesize.io/methodgrab/ga-clean-urls/master/index.min.js.svg?compression=gzip)
> A plugin for Google Analytics to remove UTM query strings from URLs

This plugin is heavily inspired by Wistia's [Fresh URL](https://wistia.com/blog/fresh-url) [library](https://github.com/wistia/fresh-url) but I wanted something more minimal so I've implemented its core functionality as a [Google Analytics plugin](https://developers.google.com/analytics/devguides/collection/analyticsjs/writing-plugins).

Before:
```
https://example.com/article/?utm_source=twitter&utm_medium=tweet&utm_campaign=website&foo=bar
```

After:
```
https://example.com/article/?foo=bar
```

---

### Warning:
This module is pre-1.0 and has not been thoroughly tested. Please test it yourself before using it in a production environment. Bugs can be reported on the [issue tracker](https://github.com/methodgrab/ga-clean-urls/issues).

---

## Install
```bash
npm install --save ga-clean-urls
```

## Usage
The plugin must be loaded **after** the 'pageview' send so the UTM parameters are tracked correctly.

```html
<script>
	ga( 'create', 'UA-XXXXX-Y', 'auto' );
	ga( 'send', 'pageview' );

	// Require the plugin after 'pageview' send
	ga( 'require', 'cleanUrls' );
</script>

<script async src="/path/to/ga-clean-urls/index.min.js"></script>
```

## Browser support
IE10+.

The plugin uses `history.replaceState` to manipulate the URL, if the browser does not support `history.replaceState` then it shouldn't cause any problems but the URL will remain unchanged.
See http://caniuse.com/#feat=history for detailed browser support.

## Todo
- [ ] Add tests

repository: MethodGrab/ga-clean-urls

gha_language: JavaScript

gha_license_id: MIT

repo_name: MethodGrab/ga-clean-urls


text:
# Contributing to React DD Builder

Hi, there!

* [Communication](#communication)
* [Resources](#res)
* [License](#license)

## Communication

* Website: https://uiux.cc
* Twitter: https://twitter.com/uiux_lab

## Resources

React DD Builder bundles the following third-party resources:

- [React](https://reactjs.org/)

All photos uploaded to the site are released under Creative Commons - CC0 and do not require attribution. No more hassle trying to figure out whether you can use photos for commercial use and whether you need to provide attribution. (http://www.gratisography.com, https://stocksnap.io ) Part of the image and videos used in the demo are not distributed with the theme. They are all licensed under Creative Commons and credited to their respective creator/owner.

## License

By contributing your code, you agree to license your contribution under the [GPL 3 license](LICENSE)

repository: xizon/react-dd-builder

repo_name: xizon/react-dd-builder


text:
# Employee-Tracker System

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Description

#### Motivation

Build a content management system to help manage a company's employees.

#### Key features

This is a command-line application that will allow the user to: - add departments, roles, employees - view departments, roles, employees, employees by manager, total utilized budget of a department - update employee roles, employee managers - delete departments, roles and employees

#### Technologies used

* JavaScript
* Node.JS
* Inquirer npm package
* MySQL and mysql npm package
* console.table npm package

## Table of contents

<!--ts-->
* [Description](#Description)
* [Installation](#Installation)
* [Usage](#Usage)
* [License](#License)
* [Contributions](#Contributions)
* [Test instructions](#Test-instructions)
* [Questions](#Questions)
<!--te-->

## Installation

* Install Node.JS and the inquirer package
* Install MySQL
* Install mysql npm package
* Download the index.js file

To invoke the app, check that you are in the correct folder and type the following command in your terminal:

```bash
node index.js
```

## Usage

For usage information, please click on link to the video below.

https://github.com/KhaiTPhan/Employee-Tracker/blob/main/Employee-Tracker%20System.mp4

Output of a sample employee-tracker system below:

![employee-tracker](https://user-images.githubusercontent.com/74043730/109792424-9d737f80-7c67-11eb-97f3-428bb2feaefc.PNG)

Below is the link to the project URL.

Project URL: https://khaitphan.github.io/Employee-Tracker/.

## Test instructions

nil

## License

* MIT

## Contributions

Open to contributions to add more features. please email if interested.

## Questions

If you have any questions, please contact me at:

GitHub URL: https://github.com/KhaiTPhan

Email<EMAIL_ADDRESS>

repository: KhaiTPhan/Employee-Tracker

branch_name: refs/heads/main

repo_name: KhaiTPhan/Employee-Tracker


text:
---
layout: post
title:  "用pytorch构建一个DSSM神经网络"
categories: python
tags:  Python Pytorch DSSM
author: binzhou
---

* content
{:toc}

```python
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torchvision.datasets as dsets
import torchvision.transforms as transforms
from torch.autograd import Variable
import torch.nn.functional as F
from config import opt
from sklearn.externals import joblib #jbolib模块
```

# 1. 数据准备

## 1.1 把数据处理成DSSM要求的格式，一个query，一个pos_doc，四个neg_doc

```python
# 处理q1,q2
import numpy as np
import pandas as pd
train = pd.read_csv('mojing/train.csv')
train = train.iloc[:10000]
```

```python
train.head()
```

      label
      q1
      q2

      0
      1
      Q397345
      Q538594

      1
      0
      Q193805
      Q699273

      2
      0
      Q085471
      Q676160

      3
      0
      Q189314
      Q438123

      4
      0
      Q267714
      Q290126

```python
a = train[train.label == 1].copy()
a.columns = ['label','query','pos_doc']
reorder_col = ['label','pos_doc','query']
b = a.loc[:, reorder_col].copy()
b.columns = ['label','query','pos_doc']
a = a.append(b,ignore_index=True)
a.drop_duplicates(subset=['query'],inplace=True)
a.index = np.arange(len(a)) # 重排序
```

```python
## 抽不为1的4个doc (neg)
b = train[train.label == 0]
suffle_pool = list(b.q1) + list(b.q2)
```

```python
def ff(s):
    l = []
    l += b[b.q1 == s].q2.tolist()
    l += b[b.q2 == s].q1.tolist()
    l = list(set(l))[:4]
    l_ = l.copy()
    l_.append(s)
    if len(l) < 4:
        tmp = np.random.choice(suffle_pool,5,replace=False).tolist()
        cha = set(tmp) - set(l_)
        l += list(cha)[:4-len(l)]
    return l
```

```python
%%time
a['neg_doc'] = a['query'].apply(ff)
```

    CPU times: user 27.5 s, sys: 174 ms, total: 27.7 s
    Wall time: 27.7 s

```python
a.head()
```

      label
      query
      pos_doc
      neg_doc

      0
      1
      Q397345
      Q538594
      [Q521609, Q175780, Q068667, Q632305]

      1
      1
      Q369715
      Q658908
      [Q696189, Q428940, Q198861, Q578218]

      2
      1
      Q537991
      Q268444
      [Q011513, Q022092, Q229357, Q498790]

      3
      1
      Q639518
      Q053248
      [Q392805, Q657314, Q647857, Q539673]

      4
      1
      Q683881
      Q087150
      [Q432305, Q723726, Q272217, Q206480]

## 1.2 把question替换成words

```python
%%time
# 把问题替换成词
QUESTION_PATH = 'mojing/question.csv'
questions = pd.read_csv(QUESTION_PATH)
question_dict = {}
for key, value in zip(questions['qid'],questions['words']):
    question_dict[key] = value
```

    CPU times: user 2.53 s, sys: 293 ms, total: 2.82 s
    Wall time: 4.57 s

```python
%%time
a['query'] = a['query'].apply(lambda x : question_dict.get(x))
a['pos_doc'] = a['pos_doc'].apply(lambda x : question_dict.get(x))
a['neg_doc'] = a['neg_doc'].apply(lambda l : [question_dict.get(x) for x in l])
```

    CPU times: user 34.6 ms, sys: 1.96 ms, total: 36.6 ms
    Wall time: 35.9 ms

```python
a.head()
```

      label
      query
      pos_doc
      neg_doc

      0
      1
      W04465 W04058 W05284 W02916
      W18238 W18843 W01490 W09905
      [W06579 W17705 W09745 W10938 W01490 W07863, W1...

      1
      1
      W12908 W19355 W08041 W06040 W18399 W01773 W16319
      W12908 W06112 W08041 W17342
      [W13157 W16564 W08020 W08924 W08276 W11824 W04...

      2
      1
      W16429 W14586 W03914 W09648 W02262 W18399 W06682
      W13522 W05733 W17917 W10691 W16319
      [W00022 W06756, W18830 W05733 W08276 W06179 W0...

      3
      1
      W04182 W05733 W03914 W09400 W13868
      W04476 W11385 W05733 W18804 W16686 W19081 W18448
      [W12440 W19536 W17945 W18080 W15175 W19355 W17...

      4
      1
      W17378 W14586 W01661 W03914 W04182 W12803 W02262
      W07777 W05733 W04476 W11385 W10628 W08815 W047...
      [W18238 W05284 W09158 W04745 W03390, W17378 W0...

## 1.3 把words进行编码

```python
import numpy as np
from tqdm import tqdm

class BOW(object):
    def __init__(self, X, min_count=10, maxlen=100):
        """
        X: [[w1, w2],]]
        """
        self.X = X
        self.min_count = min_count
        self.maxlen = maxlen
        self.__word_count()
        self.__idx()
        self.__doc2num()

    def __word_count(self):
        wc = {}
        for ws in tqdm(self.X, desc='   Word Count'):
            for w in ws:
                if w in wc:
                    wc[w] += 1
                else:
                    wc[w] = 1
        self.word_count = {i: j for i, j in wc.items() if j >= self.min_count}

    def __idx(self):
        self.idx2word = {i + 1: j for i, j in enumerate(self.word_count)}
        self.word2idx = {j: i for i, j in self.idx2word.items()}

    def __doc2num(self):
        doc2num = []
        for text in tqdm(self.X, desc='Doc To Number'):
            s = [self.word2idx.get(i, 0) for i in text[:self.maxlen]]
            doc2num.append(s + [0]*(self.maxlen-len(s)))  # 未登录词全部用0表示
        self.doc2num = np.asarray(doc2num)
def get_ids(qids):
    ids = []
    for t_ in qids:
        ids.append(int(t_[1:]))
    return np.asarray(ids)

def get_texts(file_path, question_path):
    qes = pd.read_csv(question_path)
    file = pd.read_csv(file_path)
    q1id, q2id = file['q1'], file['q2']
    id1s, id2s = get_ids(q1id), get_ids(q2id)
    all_words = qes['words']
    texts = []
    for t_ in zip(id1s, id2s):
        texts.append(all_words[t_[0]] + ' ' + all_words[t_[1]])
    return texts
TRAIN_PATH = 'mojing/train.csv'
TEST_PATH = 'mojing/test.csv'
QUESTION_PATH = 'mojing/question.csv'
train_texts = get_texts(TRAIN_PATH, QUESTION_PATH)
test_texts = get_texts(TEST_PATH, QUESTION_PATH)
a1 = train_texts + test_texts
a1 = [x.split(' ') for x in a1]
bow = BOW(a1,min_count=1,maxlen=24) # count大于1，句子(q1,q2)相加最大长度为24
del a1
```

       Word Count: 100%|██████████| 427342/427342 [00:01<00:00, 332864.53it/s]
    Doc To Number: 100%|██████████| 427342/427342 [00:03<00:00, 133272.96it/s]

```python
##############################
# 之前编码好的已经存成embedding matrix
# 可以自己训练
# 训练代码
word_embed = pd.read_csv('mojing/word_embed.txt',header=None)
word_embed.columns = ['wv']
word_embed_dict = dict()
for s in word_embed.wv.values:
    l = s.split(' ')
    word_embed_dict[l[0]] = list(map(float,l[1:]))
word_embed_dict['UNK'] = [0]*300
vocab_size = len(word_embed_dict)
embedding_matrix = np.zeros((vocab_size+1,300))
for key, value in bow.word2idx.items():
    embedding_matrix[value] = word_embed_dict.get(key)
embedding_matrix
# np.save('save/embedding_matrix.npz',embedding_matrix)
# embedding_matrix = np.load('save/embedding_matrix.npz.npy')
```

    array([[ 0.        ,  0.        ,  0.        , ...,  0.        ,
             0.        ,  0.        ],
           [ 2.29952765, -4.29687977,  3.71340919, ...,  0.99011242,
             0.41728863,  3.15365911],
           [-1.52279055,  2.12538552, -0.3590863 , ..., -2.17771411,
             1.37241161, -3.44047666],
           ...,
           [ 0.        ,  0.        ,  0.        , ...,  0.        ,
             0.        ,  0.        ],
           [ 0.        ,  0.        ,  0.        , ...,  0.        ,
             0.        ,  0.        ],
           [ 0.        ,  0.        ,  0.        , ...,  0.        ,
             0.        ,  0.        ]])

```python
def fill_unkQ1(s):
    l1 = s.split(' ')
    l1 = [bow.word2idx.get(x) if x in bow.word2idx.keys() else 0 for x in l1]
    return l1
def fill_unkQ2(l):
    l1 = [[bow.word2idx.get(x) if x in bow.word2idx.keys() else 0 for x in s.split(' ')] for s in l]
    return l1
a['query'] = a['query'].apply(fill_unkQ1)
a['pos_doc'] = a['pos_doc'].apply(fill_unkQ1)
a['neg_doc'] = a['neg_doc'].apply(fill_unkQ2)
```

```python
a.head()
```

      label
      query
      pos_doc
      neg_doc

      0
      1
      [1, 2, 3, 4]
      [5, 6, 7, 8]
      [[723, 1649, 27, 151, 7, 25], [124, 773, 99, 2...

      1
      1
      [45, 21, 46, 47, 48, 49, 30]
      [45, 50, 46, 51]
      [[39, 324, 837, 66, 287, 238, 1394, 53, 25], [...

      2
      1
      [52, 26, 53, 54, 55, 48, 56]
      [57, 58, 59, 60, 30]
      [[951, 1383], [2317, 58, 287, 593, 25], [570, ...

      3
      1
      [71, 58, 53, 72, 73]
      [10, 74, 58, 75, 76, 77, 78]
      [[333, 116, 594, 764, 698, 21, 613], [5, 28, 6...

      4
      1
      [20, 26, 98, 53, 71, 99, 55]
      [100, 58, 10, 74, 101, 102, 103, 48, 104]
      [[5, 3, 382, 103, 40], [20, 111, 7, 30, 5, 293...

## 1.4 数据处理成dssm要求的tensor格式样式

```python
J = 4
l_Qs = [[] for j in range(len(a))]
pos_l_Ds = [[] for j in range(len(a))]
# neg_l_Ds = [[] for j in range(J)]
neg_l_Ds = np.zeros((J,len(a))).tolist()
for i in range(len(a['query'])):
    l_Qs[i] = Variable(torch.from_numpy(np.array(a['query'][i]).reshape(1,len(a['query'][i]))).long())
    pos_l_Ds[i] = Variable(torch.from_numpy(np.array(a['pos_doc'][i]).reshape(1,len(a['pos_doc'][i]))).long())
    for j in range(J):
        neg_l_Ds[j][i] = Variable(torch.from_numpy(np.array(a['neg_doc'][i][j]).reshape(1,len(a['neg_doc'][i][j]))).long())
```

# 2. 构建模型

```python
from BasicModule import BasicModule
import torch as t
import numpy as np
from torch import nn

LETTER_GRAM_SIZE = 1 # See section 3.2. trigram_based word_uni_gram 暂时没用到
WINDOW_SIZE = 3 # See section 3.2. 暂时没用到
TOTAL_LETTER_GRAMS = opt.vocab_size # Determined from data. See section 3.2. 20893 暂时没用到
WORD_DEPTH =300 # See equation (1).  这里我用词向量训练好的embedding 300维
K = 128 # Dimensionality of the max-pooling layer. See section 3.4.
L = 64 # Dimensionality of latent semantic space. See section 3.5.
J = 4 # Number of random unclicked documents serving as negative examples for a query. See section 4.
FILTER_LENGTH = 1 # We only consider one time step for convolutions.
sample_size = 10000

def kmax_pooling(x, dim, k):
    index = x.topk(k, dim = dim)[1].sort(dim = dim)[0]
    return x.gather(dim, index)

class CDSSM(BasicModule):
    def __init__(self):
        super(CDSSM, self).__init__()
        # layers for query
        self.query_conv = nn.Conv1d(WORD_DEPTH, K, FILTER_LENGTH)
        self.query_sem = nn.Linear(K, L)
        # layers for docs
        self.doc_conv = nn.Conv1d(WORD_DEPTH, K, FILTER_LENGTH)
        self.doc_sem = nn.Linear(K, L)
        # learning gamma
        self.learn_gamma = nn.Conv1d(1, 1, 1)
        # embedding
        self.encoder = nn.Embedding(opt.vocab_size,opt.embedding_dim)
        if opt.embedding_path:
            self.encoder.weight.data.copy_(t.from_numpy(np.load(opt.embedding_path)))
    def forward(self, q, pos, negs):
        # Query model. The paper uses separate neural nets for queries and documents (see section 5.2).
        # To make it compatible with Conv layer we reshape it to: (batch_size, WORD_DEPTH, query_len)
#         q = self.encoder(q)
#         pos = self.encoder(pos)
#         negs = [self.encoder(neg) for neg in negs]
        q = q.transpose(1,2)
        # In this step, we transform each word vector with WORD_DEPTH dimensions into its
        # convolved representation with K dimensions. K is the number of kernels/filters
        # being used in the operation. Essentially, the operation is taking the dot product
        # of a single weight matrix (W_c) with each of the word vectors (l_t) from the
        # query matrix (l_Q), adding a bias vector (b_c), and then applying the tanh activation.
        # That is, h_Q = tanh(W_c • l_Q + b_c). Note: the paper does not include bias units.
        q_c = F.tanh(self.query_conv(q))
        # Next, we apply a max-pooling layer to the convolved query matrix.
        q_k = kmax_pooling(q_c, 2, 1)
        q_k = q_k.transpose(1,2)
        # In this step, we generate the semantic vector represenation of the query. This
        # is a standard neural network dense layer, i.e., y = tanh(W_s • v + b_s). Again,
        # the paper does not include bias units.
        q_s = F.tanh(self.query_sem(q_k))
        q_s = q_s.resize(L)
        # # The document equivalent of the above query model for positive document
        pos = pos.transpose(1,2)
        pos_c = F.tanh(self.doc_conv(pos))
        pos_k = kmax_pooling(pos_c, 2, 1)
        pos_k = pos_k.transpose(1,2)
        pos_s = F.tanh(self.doc_sem(pos_k))
        pos_s = pos_s.resize(L)
        # # The document equivalent of the above query model for negative documents
        negs = [neg.transpose(1,2) for neg in negs]
        neg_cs = [F.tanh(self.doc_conv(neg)) for neg in negs]
        neg_ks = [kmax_pooling(neg_c, 2, 1) for neg_c in neg_cs]
        neg_ks = [neg_k.transpose(1,2) for neg_k in neg_ks]
        neg_ss = [F.tanh(self.doc_sem(neg_k)) for neg_k in neg_ks]
        neg_ss = [neg_s.resize(L) for neg_s in neg_ss]
        # Now let us calculates the cosine similarity between the semantic representations of
        # a queries and documents
        # dots[0] is the dot-product for positive document, this is necessary to remember
        # because we set the target label accordingly
        dots = [q_s.dot(pos_s)]
        dots = dots + [q_s.dot(neg_s) for neg_s in neg_ss]
        # dots is a list as of now, lets convert it to torch variable
        dots = torch.stack(dots)
        # In this step, we multiply each dot product value by gamma. In the paper, gamma is
        # described as a smoothing factor for the softmax function, and it's set empirically
        # on a held-out data set. We're going to learn gamma's value by pretending it's
        # a single 1 x 1 kernel.
        with_gamma = self.learn_gamma(dots.resize(J+1, 1, 1))
        # Finally, we use the softmax function to calculate P(D+|Q).
        prob = F.softmax(with_gamma)
        return prob

model = CDSSM()
model.cuda()
```

    CDSSM(
      (query_conv): Conv1d(300, 128, kernel_size=(1,), stride=(1,))
      (query_sem): Linear(in_features=128, out_features=64, bias=True)
      (doc_conv): Conv1d(300, 128, kernel_size=(1,), stride=(1,))
      (doc_sem): Linear(in_features=128, out_features=64, bias=True)
      (learn_gamma): Conv1d(1, 1, kernel_size=(1,), stride=(1,))
      (encoder): Embedding(20893, 300)
    )

# 3. 跑DSSM模型 SGD 一个个样本跑

```python
encoder = nn.Embedding(opt.vocab_size,opt.embedding_dim)
if opt.embedding_path:
            encoder.weight.data.copy_(t.from_numpy(np.load(opt.embedding_path)))
```

```python
%%time
# cpu version
# Loss and optimizer
criterion = torch.nn.CrossEntropyLoss()
optimizer = torch.optim.SGD(model.parameters(), lr=1e-4, momentum=0.9)

# output variable, remember the cosine similarity with positive doc was at 0th index
y = np.ndarray(1)
# CrossEntropyLoss expects only the index as a long tensor
y[0] = 0
y = Variable(torch.from_numpy(y).long())

for i in range(sample_size):
    y_pred = model(l_Qs[i], pos_l_Ds[i], [neg_l_Ds[j][i] for j in range(J)])
    loss = criterion(y_pred.resize(1,J+1), y)
    print('%d training loss'%i, loss.data[0])
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()
```

```python
l_Qs[8400:8500]
```

    [tensor([[ 749,   48,    7,  142,    5,  773]]),
     tensor([[ 280,  234,  907,  280]]),
     tensor([[   5,   66,  227,   30,   78]]),
     tensor([[  58,  234,   90,  493,   16,   35,  267,  268,  493,   13]]),
     tensor([[  20,    7,  134,   30,  159,   78,   13]]),
     tensor([[ 235,   95,  257,  301,  260,   84,   30]]),
     tensor([[   20,  1000,   578,   225]]),
     tensor([[ 543,  258,  222,   18,  138,  680,  330,   53,   66,  269,
               688,  215,   10,  107,   78]]),
     tensor([[ 175,    7,  555]]),
     tensor([[   94,    95,    53,    26,    35,  3944,    99,    58]]),
     tensor([[  10,   94,   95,   21,   58,    3,  113,  109]]),
     tensor([[  58,  348,  234]]),
     tensor([[ 58,  88,  90,  84]]),
     tensor([[ 832,  103,   21,  992]]),
     tensor([[  51,  158,   17,  603,  232,   20]]),
     tensor([[ 907,  670,   20,  757,   45,  319]]),
     tensor([[  20,   21,  235,  305,   98,   53,   35,   10,   55,   48,
                56]]),
     tensor([[   10,    55,    21,   106,   107,  2155,   426,    52,   481]]),
     tensor([[  20,   33,   57,   58,   35,    5,  261,   30]]),
     tensor([[  103,  2500,  3197,   350]]),
     tensor([[  20,   33,  246,  648,  152]]),
     tensor([[ 3954,     7]]),
     tensor([[  22,  104,   35,  437,  108,  109]]),
     tensor([[ 472,   20,   21,  252,    5,  816]]),
     tensor([[  20,   21,    7,  147]]),
     tensor([[  58,   40,   35,  560,  150,  108,  109]]),
     tensor([[ 227,   18,  570,  227]]),
     tensor([[ 296,    7,   46,  349,  234,   75,   15,  220]]),
     tensor([[  20,   21,  648,  570,   59,  227,   20,  444,   21,  320,
               392,   30]]),
     tensor([[  103,    21,   530,  1539,    30]]),
     tensor([[  20,   33,    6,  353,    7,    8]]),
     tensor([[   9,  467,   30,  287,   58,   25]]),
     tensor([[  11,  426,  568,   66,  269,   25]]),
     tensor([[ 379,  299,  181,  287,  108,   25]]),
     tensor([[   74,   227,    31,   152,    59,  3959]]),
     tensor([[ 3961,   108,    24,     5,     7]]),
     tensor([[   20,  1169,   146,     3,    84,   106]]),
     tensor([[ 106,   22,  400,   75,  267,  436,   25]]),
     tensor([[  197,   197,   376,   968,  3962,   244,    21]]),
     tensor([[  10,  478,   40,   41,  106,    3,  107,  108,  109,   13]]),
     tensor([[   5,    3,  382,  400,   22]]),
     tensor([[ 235,   95,  379,   12]]),
     tensor([[  20,  158,   58,   40,   10,   74,  841,  795,   30]]),
     tensor([[ 1346,    30,   106,     3,   113,    24]]),
     tensor([[ 31,  59,  39]]),
     tensor([[   58,  3964,    83,    25,    13]]),
     tensor([[ 3965,    12,    78,    13]]),
     tensor([[ 107,  448,    7,  381,  501,   20]]),
     tensor([[ 207,  293,   22,  498]]),
     tensor([[ 112,  257,  258,   21]]),
     tensor([[ 215,   11,   31,   78]]),
     tensor([[ 124,    6,   20,    7,  555]]),
     tensor([[ 45,  21,  50,  46]]),
     tensor([[   15,    81,    20,   198,  3143,    30,    41,   192,   280,
               1066]]),
     tensor([[ 19,   5,  44,  57,  58]]),
     tensor([[  5,  39,   9]]),
     tensor([[ 1445,   269,    55,   288,    25]]),
     tensor([[ 603,  281,  349,  234,   13]]),
     tensor([[  638,   505,  1856,   235,    95,  1041]]),
     tensor([[  107,   378,  3547,   104,    25]]),
     tensor([[  58,   32,  563,  654,  108,  109]]),
     tensor([[   10,   463,  2534,    30,   343,   413,   291]]),
     tensor([[ 1203,   207,   312]]),
     tensor([[  58,   26,  771,  661,   25,   13]]),
     tensor([[  58,   32,  150,  287,  108,  109]]),
     tensor([[ 142,   21,  257,    5,  359,  362]]),
     tensor([[ 472,  975,   25,   13]]),
     tensor([[  20,   10,   99,  379,   30]])]

```python
%%time
# gpu version
# Loss and optimizer
criterion = torch.nn.CrossEntropyLoss()
optimizer = torch.optim.SGD(model.parameters(), lr=1e-4, momentum=0.9)
criterion.cuda()

# output variable, remember the cosine similarity with positive doc was at 0th index
y = np.ndarray(1)
# CrossEntropyLoss expects only the index as a long tensor
y[0] = 0
y = Variable(torch.from_numpy(y).long()).cuda()

for i in range(sample_size):
#     y_pred = model(l_Qs[i], pos_l_Ds[i], [neg_l_Ds[j][i] for j in range(J)])
    y_pred = model(encoder(l_Qs[i]).cuda(), encoder(pos_l_Ds[i]).cuda(), [encoder(neg_l_Ds[j][i]).cuda() for j in range(J)])
    loss = criterion(y_pred.resize(1,J+1), y)
    if i % 100 == 0:
        print('%d training loss'%i, loss.cpu().data[0])
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()
```

    /fdp/.local/lib/python3.6/site-packages/torch/tensor.py:255: UserWarning: non-inplace resize is deprecated
      warnings.warn("non-inplace resize is deprecated")
    /usr/local/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:85: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
    /usr/local/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:17: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number

    0 training loss tensor(1.6347)
    100 training loss tensor(1.6490)
    200 training loss tensor(1.6017)
    300 training loss tensor(1.6053)
    400 training loss tensor(1.6080)
    500 training loss tensor(1.6090)
    600 training loss tensor(1.5162)
    700 training loss tensor(1.6037)
    800 training loss tensor(1.5920)
    900 training loss tensor(1.5668)
    1000 training loss tensor(1.5862)
    1100 training loss tensor(1.5944)
    1200 training loss tensor(1.5928)
    1300 training loss tensor(1.6171)
    1400 training loss tensor(1.4929)
    1500 training loss tensor(1.6628)
    1600 training loss tensor(1.5990)
    1700 training loss tensor(1.6028)
    1800 training loss tensor(1.5567)
    1900 training loss tensor(1.4474)
    2000 training loss tensor(1.6271)
    2100 training loss tensor(1.6788)
    2200 training loss tensor(1.6578)
    2300 training loss tensor(1.4889)
    2400 training loss tensor(1.6383)
    2500 training loss tensor(1.3773)
    2600 training loss tensor(1.3692)
    2700 training loss tensor(1.6813)
    2800 training loss tensor(1.5980)
    2900 training loss tensor(1.5012)
    3000 training loss tensor(1.7437)
    3100 training loss tensor(1.5664)
    3200 training loss tensor(1.6467)
    3300 training loss tensor(1.2001)
    3400 training loss tensor(1.6904)
    3500 training loss tensor(1.2545)
    3600 training loss tensor(1.3611)
    3700 training loss tensor(1.6140)
    3800 training loss tensor(1.5766)
    3900 training loss tensor(0.9233)
    4000 training loss tensor(1.4807)
    4100 training loss tensor(1.7822)
    4200 training loss tensor(1.5655)
    4300 training loss tensor(1.6642)
    4400 training loss tensor(1.1545)
    4500 training loss tensor(1.5872)
    4600 training loss tensor(1.0026)
    4700 training loss tensor(1.0715)
    4800 training loss tensor(1.0602)
    4900 training loss tensor(1.7952)
    5000 training loss tensor(1.5088)
    5100 training loss tensor(1.6724)
    5200 training loss tensor(1.7706)
    5300 training loss tensor(1.4433)
    5400 training loss tensor(1.4279)
    5500 training loss tensor(0.9569)
    5600 training loss tensor(1.8893)
    5700 training loss tensor(1.5960)
    5800 training loss tensor(0.9451)
    5900 training loss tensor(1.7464)
    6000 training loss tensor(1.5589)
    6100 training loss tensor(1.7813)
    6200 training loss tensor(1.1629)
    6300 training loss tensor(1.4071)
    6400 training loss tensor(1.8934)
    6500 training loss tensor(1.8045)
    6600 training loss tensor(1.5014)
    6700 training loss tensor(0.9430)
    6800 training loss tensor(1.3834)
    6900 training loss tensor(1.6786)
    7000 training loss tensor(1.1853)
    7100 training loss tensor(1.7041)
    7200 training loss tensor(1.3836)
    7300 training loss tensor(1.4180)
    7400 training loss tensor(1.7372)
    7500 training loss tensor(1.7524)
    7600 training loss tensor(1.0825)
    7700 training loss tensor(1.7825)
    7800 training loss tensor(1.7910)
    7900 training loss tensor(1.8072)
    8000 training loss tensor(1.8051)
    8100 training loss tensor(0.9370)
    8200 training loss tensor(1.2102)
    8300 training loss tensor(1.3358)
    8400 training loss tensor(1.7570)

    IndexErrorTraceback (most recent call last)

    <timed exec> in <module>()

    IndexError: list index out of range

```python
# 好像没有收敛。。还有报错
```

```python

```


text:
# Overview
In order to maintain interactivity, all assets in JanusWeb are loaded asynchronously.  This introduces a lot of complexity into how assets are processed, and the current code is a bit hacky.  This page is an attempt to document how it SHOULD work, so that we can apply that to the working codebase, enabling better performance and more complex features which depend on having more visibility into the loading process.

## Concepts and Classes
#### ```engine.assets.base```
  Base class for assets, which represent an external resource, usually referenced by a URL.  Inherited by ```engine.assets.model```, ```engine.assets.sound```, ```engine.assets.image```, etc.

#### ```janusweb.room```
  Represents a specific room, referenced by a URL.  Consists of a collection of ```janusweb.object```, ```janusweb.video```, ```janusweb.image```, etc. objects.

#### ```janusweb.object```
  Represents an instance of an ```engine.assets.model``` asset.  Each object has its own independent position and orientation within the room, as well as any other properties which control the styling of this object.  Objects can reference ```engine.assets.image``` and ```engine.assets.video``` assets as textures.

#### ```janusweb.video```
  Represents an instance of an ```engine.assets.video``` asset mapped to a simple plane.

#### ```janusweb.image```
  Represents an instance of an ```engine.assets.image``` asset mapped to a simple plane.

#### ```janusweb.sound```
  Represents an instance of an ```engine.assets.sound``` asset.  There is no geometry associated with a sound.

## Events
Asynchronous loading involves several different loading states, and we want to be able to communicate this for all levels.  For example, a room hasn't completed loading until all of its objects have completed loading, which only happens after all of their assets are complete.  We want to be able to display loading information for the entire room, as well as for each individual object.

To this end, all async-loading classes will fire the following events:

| Event Name      | Fires | When                                                        | Event Data |
| --------------- | ----- | ----------------------------------------------------------- | ---------- |
| asset_load_queued     | once  | the object is first requested                               |            |
| asset_load_start      | once  | the browser has started fetching bytes for this object      |            |
| asset_load_progress   | many  | some amount of data for this object has loaded              |            |
| asset_load_processing | once  | all data for this object has finished loading and is about to be processed | |
| asset_load_processed  | once  | data for this object has finished parsing                   |            |
| asset_load_complete   | once  | all of this object's children have fired load_complete      |            |

## Worker Loader
Assets in Elation Engine are loaded using WebWorkers, which lets the operating system handle them in a multithreaded or multiprocess way.  This allows the main thread to continue operating uninterrupted even while parsing very large assets, but it also makes the whole system a lot more complicated.

```
/*
  -eventname> means async event handler in main thread
  +eventname> means async event handler in worker
*/

elation.engine.assets.fetch('model', modelid);
    elation.engine.assets.model.getInstance(modelid)
        if (this.loaded) {
           var model = this.model.clone();
           this.assignTextures(model);
           return model;
        } else {
           this.displayPlaceholder();
           this.loadWithWorker();
           +onmessage>  elation.engine.assetworker.model.load()
                  elation.net.xhr()
                  +onload>  elation.engine.assetworker.model.onload(data)
                          if (this.contentIsGzipped(data)) data = pako.inflate(data);
                          var type = this.detectContentType(data);
                          var parser = this.getParser(type);
                          var modeldata = parser.parse(data);
                          postMessage(modeldata.toJSON());
           -onmessage> handleLoadJSON(json)
                  this.model = THREE.ObjectLoader.parse(json)
                  var model = this.model.clone()
                  this.removePlaceholder()
                  this.extractTextures(model)
                      for (m in model.materials) {
                          for (t in ['map', 'normalMap', 'specularMap', 'lightMap', 'envMap']) {
                              var img = m[t].image;
                              m[t] = elation.engine.assets.find('image', img.src);
                          }
                      }
                  this.assignTextures(model)
                  elation.events.fire({type: 'asset_load', element: this});
                  return model;
        }
```

repository: janusvr/guide

repo_name: janusvr/guide


text:
This is the third assignment for the Georgia Tech Boot Camp - 2018.

In this assignment, we were required to create a fun and interactive game using Javascript, the classic hangman game and a theme from the 1980s. The app must dynamically update the HTML with Javascript.  I choose classic arcade games as my variables.

The Game is Titled: Hangman Game

Instructions:

Just strike a key.  Figure out which classic 80's arcade game is listed.  You get 5 tries.

Click on the following link to preview the completed assignment. https://skendall74.github.io/Word-Guess-Game/

Built With HTML5 CSS3 Twitter-Bootstrap - Framework JavaScript - JavaScript Library


text:
# SCEMI Library
Library implementation of [SCEMI](http://www.accellera.org/downloads/standards/sce-mi) interface in C. The library implemented the Function-based Interface [Refer](http://www.accellera.org/images/downloads/standards/sce-mi/SCE-MI_v22-140120-final.pdf).

## Uses
The library could be used to send transactions between two or more simulations running on same/different hosts.

### Prerequisites
Tested on unix machines with industry standard compilers & VCS compiler.

### Video
[Link](https://www.youtube.com/embed/qOtkPb75nx0)

## Running the tests
One test is present in _tests_ dir. Run commands are provided
```bash
cd tests
bash run.sh
```

## Deployment

## Built With

## Contributing

## Versioning

For the versions available, see the [tags on this repository](https://github.com/your/project/tags).

## Authors
* **Narendran Kumaragurunathan** - *Initial work* - [scemi_lib](https://github.com/scemi_lib)

See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

## License

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

## Acknowledgments


text:
# Setup SES
You will need AWS SES to receive and send emails. SES required different configuration for incoming and outgoing email set up, therefore it is possible to have an email address that's able to receive email but unable to send out email.

### prerequisite:
- a domain name
- knowledge about editing a DNS record, this guide assumes you use cloudflare to [manage your DNS](https://support.cloudflare.com/hc/en-us/articles/360019093151-Managing-DNS-records-in-Cloudflare), but it is not required, any DNS tool given by your domain provider will work as fine too.
- and, about 30 mins time

## Verify Your Domain
* [Signin to AWS console](https://console.aws.amazon.com/?nc2=h_m_mc) if you haven't done so

* Pick `Services` > `Simple Email Services`
![setup-ses-step01](../img/ses/01.png)

* Pick `Domains` > `Verify a New Domain`
![setup-ses-step02](../img/ses/02.png)

* In `Verify a New Domain` dialogbox, key in you domain name, check `Generate DKIM Settings` and click `Verify This Domain`
![setup-ses-step03](../img/ses/03.png)

* Your DNS settings for verification will be shown on the dialogbox, keep it open, you will it it for next step
![setup-ses-step04](../img/ses/04.png)

* Go to cloudflare DNS page, make sure you selected the right domain name, key in the DNS records given in previous step
> The DKIM CNAME records can not be proxied, you need to turn the orange cloud to gray cloud

![setup-ses-step05](../img/ses/05.png)

* After you successfully add these CNAME records to your domain's DNS settings, Amazon SES will automatically detect the records and allow DKIM signing at that time. Verification of those records may take up to **72 hours**.

## Create Receiving Rule Sets
* Select `Rule Sets` > `Create a New Rule Set`
![setup-ses-step06](../img/ses/06.png)

* Give your rule set a name
![setup-ses-step07](../img/ses/07.png)

* Select your newly created rule set in `Inactive Rule Sets` list and click `Set as Active Rule Set`
![setup-ses-step08](../img/ses/08.png)

* Click on `View Active Rule Set` button to start editing your rule set

* Click on `Create Rule` button to start adding new mailbox
![setup-ses-step09](../img/ses/09.png)

### Step 1: Recipients
* add one or more email addresses as recipient then click on `Next Step`
![setup-ses-step10](../img/ses/10.png)

### Step 2: Actions
* Click `Select an action type` drop down menu, and select `S3`. click on `Next Step`
![setup-ses-step11](../img/ses/11.png)

* In S3 Action Section, choose `Create S3 bucket`
![setup-ses-step12](../img/ses/12.png)

* In `Create S3 bucket` dialogbox, give your bucket a name
![setup-ses-step13](../img/ses/13.png)

* Leave the rest of input in S3 Action section empty and click on `Next Step`
![setup-ses-step14](../img/ses/14.png)

### Step 3: Rule Details
* Give your new rule a name, and click `Next Step`
![setup-ses-step15](../img/ses/15.png)

### Step 4: Review
Review your new rule settings, click `Create Rule` when you done so
![setup-ses-step16](../img/ses/16.png)

Congratulations! after SES finish verifying your domain name, you can start sending mail to the email address

for more details setup process and explanation please check the [official docs](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email.html)

## Create Sending Address
This step is optional to use Kloud Konsole. It is good to have email sending functionality to send out verification and welcome emails to your users. if this is not needed please feel free to skip this section.

In order to setup outgoing email address, the address must link to a mailbox first. please follow the steps in previous sections to setup incoming mailbox. for example if you want to setup<EMAIL_ADDRESS>you mustsetup incoming mailbox for<EMAIL_ADDRESS>first.

### Verify Email Address
* click on `Email Addresses` and then `Verify a New Email Address`
![setup-ses-step17](../img/ses/17.png)

* In the popup key in your desired email address. click `Verify This Email Address` for AWS to send out verification email.
![setup-ses-step18](../img/ses/18.png)
![setup-ses-step19](../img/ses/19.png)

* go the mailbox (S3 bucket) and look for the verification mail and download it to your computer
![setup-ses-step20](../img/ses/20.png)
![setup-ses-step21](../img/ses/21.png)

* open it with any text editor and look for the email verification link, something similar to
```
https://email-verification.us-east-1.amazonaws.com/?Context=111111111111&X-Amz-Date=20190726T160834Z&Identity.IdentityName=admin%40kloudkonsole.com&X-Amz-Algorithm=AWS4-HMAC-SHA256&Identity.IdentityType=EmailAddress&X-Amz-SignedHeaders=host&X-Amz-Credential=AKIAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaus-east-1%2Fses%2Faws4_request&Operation=ConfirmVerification&Namespace=Bacon&X-Amz-Signature=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

* copy the link and paste on your browser, if everything goes well you will be redirected to  the `Congratulations` page
![setup-ses-step22](../img/ses/22.png)

* go back to your SES page, you should seen the status newly added email address change to `Verified`
![setup-ses-step23](../img/ses/23.png)

repository: kloudkonsole/kampus

repo_name: kloudkonsole/kampus


text:
# sandal
Local environment automatic generation; we can't be barefoot any more but boots are too much and bootstrapping is hard.

## Prerequisites

Python, Ansible

# Bootstrap

All my dev env

```sh
$ ansible-playbook all.yml -c local -i inventory --ask-sudo-pass
```

Install Basho OTP only

```sh
$ ansible-playbook install-otp.yml -c local -i inventory --ask-sudo-pass
```

This installs Basho-patched R15, R16 and 17.

# TODOs

setup RT env

# Thanks

Java related playbooks are from https://github.com/vrischmann/ansible-role-java .

repository: kuenishi/sandal

repo_name: kuenishi/sandal


text:
---

title: "Military Bases in Connecticut: Coast Guard, National Guard, Navy"
date: 2018-12-04T15:04:10.000Z
description: "Military bases in Connecticut are home to over 4,500 active duty service members and an additional 6,800 reserve forces. See a list of all CT bases here."
slug: military-bases-connecticut
image:

---

Military bases in Connecticut are home to over 4,500 active duty service members and an additional 6,800 reserve forces.

The majority of the active duty members (3,700) are stationed at the New London Submarine base. The New London Submarine base is the only Naval base in Connecticut, however it is a historic landmark because it was the very first U.S. submarine base to be built back in 1916.

It sits on the Thames River just six miles inland of the Atlantic Ocean. Our records show that there are about 17 submarines currently at the New London base.

While the military presence in Connecticut is small, this area is an important location due to its close proximity to Boston, New York, Philadelphia and quick access to the Atlantic Ocean.

Coast Guard

List of Coast Guard Bases in Connecticut

Name of Coast Guard Base
Location

Coast Guard Academy
New London, CT

Marine Safety Lab
Groton, CT

USCG Research and Development Center
Groton, CT

National Guard

List of National Guard Bases in Connecticut

Name of National Guard Base
Location

Bradley Air National Guard Base
East Granby, CT

Navy

List of Navy Bases in Connecticut

Name of Navy Base
Location

New London Submarine Base
Groton, CT

Naval Support Facility Anacostia

United States Naval Observatory

Currently there are only 11,000 active duty and reserve members currently serving at military bases in Connecticut.

While this number may seem insignificant compared to other states with large military populations, don't overlook Connecticut as a possible location to be assigned. The state offers easy access to New York City, Boston, Philadelphia and the New England coast.

repository: Mbbrands/one-click-hugo-cms

gha_language: CSS

repo_name: Mbbrands/one-click-hugo-cms


text:
---
title: Plugin Installation
taxonomy:
    category: docs
---

## Installation

Installing a plugin can be done in one of three ways:

- The **GPM** (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command.
- The **manual** method lets you do so via a zip file.
- The **admin** method lets you do so via the Admin Plugin.

The plugin should let you know the **_NAME_ to be used** in the following steps.

### GPM Installation (Preferred)

To install the plugin via the [GPM](https://learn.getgrav.org/17/cli-console/grav-cli-gpm), through your system’s terminal (also called the command line), navigate to the root of your Grav-installation, and enter:

[prism classes="language-sh"]
bin/gpm install NAME
[/prism]

This will install the plugin into your `/user/plugins` directory within Grav. Its files can be found under `user/plugins/NAME`.

### Manual Installation

To install the plugin manually, download the zip-version of this repository and unzip it under `user/plugins/`. Then rename the folder to `NAME`.

You should now have all the plugin files under `user/plugins/NAME`.

> NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see the file `user/plugins/NAME/blueprints.yaml` for more.

### Admin Plugin

If you use the [Admin Plugin](https://github.com/getgrav/grav-plugin-admin) and the plugin is registered in Grav repository, you can install the plugin directly by browsing the `Plugins` menu and clicking on the `Add` button.

repository: getgrav/grav-learn

branch_name: refs/heads/develop

gha_language: SCSS

repo_name: getgrav/grav-learn


text:
# AlphaZero-gym

An OpenAI gym environment for chess with observations and actions represented in AlphaZero-style

This is a modification of my [`gym-chess`](https://github.com/Ryan-Rudes/gym-chess) module. This implementation represents observations and actions using the feature planes representation method described in the AlphaZero paper, [*Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm*](https://arxiv.org/pdf/1712.01815.pdf)

## Installation

This requires the installation of the [`python-chess`](https://github.com/niklasf/python-chess) chess game engine library. Depending on your version of installation, you may or may not have the method `chess.Board.is_repetition` included in your particular version of the package. If not, the source code of this method is included in the sole Python file in this repo.

List of required packages:
* [`python-chess`](https://github.com/niklasf/python-chess)
  > `pip install chess`
* [`cairosvg`](https://pypi.org/project/CairoSVG/)
  > `pip install cairosvg`
* [`PIL`](https://pypi.org/project/Pillow/)
  > `pip install Pillow`
* [`gym`](https://github.com/openai/gym)
  > `pip install 'gym[all]'`

## Usage

The environment works as does any other `gym.Env` environment. Some basic functions:
* `env.reset()`
* `env.step(P)`

  > Where `P` is the policy, in the form of a probability distribution over actions represented as a matrix of shape (8, 8, 73), according to the AlphaZero method:
  >
  > | Feature         | Planes        |
  > | :-------------- | ------------: |
  > | Queen moves     | 56            |
  > | Knight moves    | 8             |
  > | Underpromotions | 9             |
  > | Total           | 73            |
  >
  > [Table S2: Action representation used by AlphaZero in Chess and Shogi respectively. The policy is represented by a stack of planes encoding a probability distribution over legal moves; planes correspond to the entries in the table.](https://arxiv.org/pdf/1712.01815.pdf#page=14)
  >
  > *A move in chess may be described in two parts: selecting the piece to move, and then*
  > *selecting among the legal moves for that piece. We represent the policy π(a|s) by a 8 × 8 × 73*
  > *stack of planes encoding a probability distribution over 4,672 possible moves. Each of the 8×8*
  > *positions identifies the square from which to “pick up” a piece. The first 56 planes encode*
  > *possible ‘queen moves’ for any piece: a number of squares [1..7] in which the piece will be*
  > *moved, along one of eight relative compass directions {N, NE, E, SE, S, SW, W, NW}. The*
  > *next 8 planes encode possible knight moves for that piece. The final 9 planes encode possible*
  > *underpromotions for pawn moves or captures in two possible diagonals, to knight, bishop or*
  > *rook respectively. Other pawn moves or captures from the seventh rank are promoted to a queen.*
* `env.observe()` or as an attribute, `env.state`
* `env.legal_move_mask()` (function for masking invalid actions/illegal moves in the provided action policy)
* `env.render(mode = '____')` (valid render modes are `'human'`, for visualizing the board in a pygame window, and `'rgb_array'` for returning the frame as an RGB array)
* `env.close()`

## Example

The below code sample simulates a game of chess with AlphaZero-style state-action representations:
```python
# Instantiate the environment
env = Chess()

# Reset the environment
state = env.reset()

# AlphaZero state representation shape for Chess
print (state.shape)
>> (8, 8, 119)

# Generate a random policy
p = np.random.random(size = (8, 8, 73))
# Normalize the policy
p = (p - p.min()) / (p.max() - p.min())

# Simulate a game
while not env.terminal:
  state, reward, terminal, info = env.step(p)
  env.render() # defaults to mode = 'human'

# Printout to demonstrate the output of the env.step() function
print(state, reward, terminal, info)

>> [[[0. 0. 0. ... 1. 1. 9.]
     [0. 1. 0. ... 1. 1. 9.]
     [0. 0. 1. ... 1. 1. 9.]

    ...

     [0. 0. 0. ... 1. 1. 9.]
     [0. 0. 0. ... 1. 1. 9.]
     [0. 0. 0. ... 1. 1. 9.]]] 0 True {'last_move': chess.Move.from_uci('c4a4'), 'turn': False}

# Close the environment and the display window
env.close()
```

## Remaining inaccuracies
This is not a total replica of the paper's methods just yet, but there is only one aspect that still doesn't conform exactly to the paper: the board must reverse each move so that each observation is from the perspective of the color whose turn is to move.

This will be implemented shortly.

repository: ryanrudes/AlphaZero-gym

repo_name: ryanrudes/AlphaZero-gym


text:
+++
title = "Basic Types"
weight = 2
+++

## Nil, True, False

Nil, true and false are literal constants. In Phel `nil` is the same as `null` in PHP. Phel's `true` and `false` are the same as PHP's `true` and `false`.

```phel
nil
true
false
```

## Symbol

Symbols are used to name functions and variables in Phel.

```phel
symbol
snake_case_symbol
my-module/my-function
λ
```

## Keywords

Keywords are like symbols that begin with a colon character. However, they are used as constants rather than a name for something.

```phel
:keyword
:range
:0x0x0x
:a-keyword
::
```

## Numbers

Numbers in Phel are equivalent to numbers in PHP. Next to decimal and
float numbers the reader also supports binary, octal and hexadecimal number formats. Binary, octal and hexadecimal formats may contain underscores (`_`) between digits for better readability.

```phel
1337 # integer
+1337 # positive integer
-1337 # negative integer

1.234 # float
+1.234 # positive float
-1.234 # negative float
1.2e3 # float
7E-10 # float

0b10100111001 # binary number
-0b10100111001 # negative binary number
0b101_0011_1001 # binary number with underscores for better readability

0x539 # hexadecimal number
-0x539 # negative hexadecimal number
-0x5_39 # hexadecimal number with underscores

02471 # octal number
-02471 # negativ octal number
024_71 # octal number with underscores
```

## Strings

Strings are surrounded by double quotes. They almost work the same as PHP double quoted strings. One difference is that the dollar sign (`$`) must not be escaped. Internally Phel strings are represented by PHP strings. Therefore, every PHP string function can be used to operate on the string.

String can be written in multiple lines. The line break character is then ignored by the reader.

```phel
"hello world"

"this is\na\nstring"

"this
is
a
string."

"use backslack to escape \" string"

"the dollar must not be escaped: $ or $abc just works"

"Hexadecimal notation is supported: \x41"

"Unicodes can be encoded as in PHP: \u{1000}"
```

## Lists

Lists are a sequence of white space separated values surrounded by parentheses.

```phel
(do 1 2 3)
```

Lists will be interpreted as a function calls, a macro call or special form by the compiler.

 In contrast to PHP arrays, Phel vectors cannot be used as Map, HashTable or Dictionary.

## Maps

Maps are represented by a sequence of white-space delimited key value pairs surrounded by curly braces. There must be an even number of items between curly braces or the parser will signal a parse error. The sequence is defined as key1, value1, key2, value2, etc.

```phel
{}
{:key1 "value1" :key2 "value2"}
{(1 2 3) (4 5 6)}
{[] []}
{1 2 3 4 5 6}
```

In contrast to PHP associative arrays, Phel Maps can have any type of keys.

## Sets

Sets are a sequence of white space separated values prefixed by the function `set` and the whole being surrounded by parentheses.

```phel
(set 1 2 3)
```

## Comments

Comments begin with a `#` character and continue until the end of the line. There are no multi-line comments.

```phel
# This is a comment
```

## Arrays (deprecated, use Vectors)

Arrays are similar to vectors but have a leading `@`.

```phel
@[]
@[:a :b :c]
```

An Array in Phel is an indexed datastructure. In contrast to PHP arrays, Phel arrays cannot be used as Map, HashTable or Dictionary.

## Tables (deprecated, use Maps)

Tables are represented by a sequence of white-space delimited key value pairs surrounded by curly braces and the prefix `@`. There must be an even number of items between curly braces or the parser will signal a parse error. The sequence is defined as key1, value1, key2, value2, etc.

```phel
@{}
@{:key1 "value1" :key2 "value2"}
@{(1 2 3) (4 5 6)}
@{@[] @[]}
@{1 2 3 4 5 6}
```

In contrast to PHP associative arrays, Phel tables can have any type of keys.


text:
## How to split pdf document with pdf extractor sdk in VBScript and ByteScout PDF Suite

### If you want to learn more then this tutorial will show how to split pdf document with pdf extractor sdk in VBScript

An easy to understand guide on how to split pdf document with pdf extractor sdk in VBScript with this source code sample. ByteScout PDF Suite is the bundle that provides six different SDK libraries to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript. It can split pdf document with pdf extractor sdk in VBScript.

The following code snippet for ByteScout PDF Suite works best when you need to quickly split pdf document with pdf extractor sdk in your VBScript application. IF you want to implement the functionality, just copy and paste this code for VBScript below into your code editor with your app, compile and run your application. Enjoy writing a code with ready-to-use sample codes in VBScript.

If you want to try other source code samples then the free trial version of ByteScout PDF Suite is available for download from our website. Just try other source code samples for VBScript.

## REQUEST FREE TECH SUPPORT

[Click here to get in touch](https://bytescout.zendesk.com/hc/en-us/requests/new?subject=ByteScout%20PDF%20Suite%20Question)

or just send email to [support@bytescout.com](mailto:support@bytescout.com?subject=ByteScout%20PDF%20Suite%20Question)

## ON-PREMISE OFFLINE SDK

[Get Your 60 Day Free Trial](https://bytescout.com/download/web-installer?utm_source=github-readme)
[Explore SDK Docs](https://bytescout.com/documentation/index.html?utm_source=github-readme)
[Sign Up For Online Training](https://academy.bytescout.com/)

## ON-DEMAND REST WEB API

[Get your API key](https://pdf.co/documentation/api?utm_source=github-readme)
[Explore Web API Documentation](https://pdf.co/documentation/api?utm_source=github-readme)
[Explore Web API Samples](https://github.com/bytescout/ByteScout-SDK-SourceCode/tree/master/PDF.co%20Web%20API)

## VIDEO REVIEW

[https://www.youtube.com/watch?v=NEwNs2b9YN8](https://www.youtube.com/watch?v=NEwNs2b9YN8)

<!-- code block begin -->

##### ****SplitPdf.vbs:**

```
' Create Bytescout.PDFExtractor.DocumentSplitter object
Set splitter = CreateObject("Bytescout.PDFExtractor.DocumentSplitter")
splitter.RegistrationName = "demo"
splitter.RegistrationKey = "demo"

inputFile = "..\..\sample2.pdf"

' Enable splitted parts optimization (remove unused resources)
splitter.OptimizeSplittedDocuments = true

' Extract a single page:
' ======================

splitter.ExtractPage inputFile, "page3.pdf", 3 ' (!) Note: page number is 1-based.

WScript.Echo "Extracted page #3 to file 'page3.pdf'."

' Split in two parts:
' ===================

splitter.Split inputFile, "part1.pdf", "part2.pdf", 3 ' (!) Note: page number is 1-based.

WScript.Echo "Splitted at page #3 to files 'part1.pdf' and 'part2.pdf'."

' Split by ranges:
' ================

' SplitCOM() returns array with file names. Files are saved to the system temporary directory.
Dim outFiles
outFiles = splitter.SplitCOM(inputFile, "1-3,4-") ' (!) Note: page numbers are 1-based; the ending "-" means "to the end".

Dim fileNames
For each of in outFiles
    fileNames = fileNames & of & vbCRLF
Next

WScript.Echo "Splitted by ranges to files: " & vbCRLF & fileNames

```

<!-- code block end -->

url: https://raw.githubusercontent.com/bytescout/ByteScout-SDK-SourceCode/67a20983df78dea26d2a8f25ec98000d3ec81928/PDF Suite/VBScript/Split pdf document with pdf extractor sdk/README.md

repository: bytescout/ByteScout-SDK-SourceCode

gha_language: HTML

repo_name: bytescout/ByteScout-SDK-SourceCode


text:
## CI/CD with OpenFaaS

Due to the fact that OpenFaaS functions are built into portable Docker images you can use any container builder to build your functions. The `faas-cli` can be used to `build`, `push` and `deploy` your functions.

### Use the native `faas-cli`

It is recommended to use the `faas-cli` binary for building and deploying your functions whether that is to Kubernetes or faasd.

* Build only:
    ```
    faas-cli build
    ```

* Build only & push:

    ```
    faas-cli build
    faas-cli push
    ```

* To combine build, push and deploy:
    ```
    faas-cli up
    ```

You can also use `--parallel` or / `--filter` when you have multiple functions in your `stack.yml` file.

* The `--shrinkwrap` flag

    The `faas-cli build` command invokes the `docker` CLI with the various flags and parameters required. If you want to use an alternative builder you can use the `--shrinkwrap` flag to generate a folder named `./build/<function>` which can then be used with any other container builder such as [BuildKit](https://github.com/moby/buildkit) or [Kaniko](https://blog.alexellis.io/quick-look-at-google-kaniko/).

See also: [`faas-cli build` reference](/cli/build/).

### Building via REST API

Customers of OpenFaaS Pro can make use of our in-cluster builder.

Send your code as generated with `faas-cli build --shrinkwrap` to the `/build` endpoint of the OpenFaaS Pro builder and receive a JSON response with build logs and a URL to the published image.

Learn more: [Pro Builder API](/openfaas-pro/builder/)

### GitHub Actions

GitHub Actions coupled with GitHub Container Registry is a fast and efficient way to build functions from public or private without hosting additional infrastructure.

We provide a complete multi-arch example in [Serverless For Everyone Else](https://gumroad.com/l/serverless-for-everyone-else).

### GitLab

GitLab is a source-control management system which is offered on a SaaS or self-hosted basis.

You can find a GitLab pipeline example on the [GitLab CI/CD page](../gitlab/).

If you require support, [you can contact us](https://openfaas.com/support/) about consulting services.

### GitHub

For GitHub you can build with any suitable CI tool such as:

* [Jenkins](https://jenkins.io)
* [Travis CI](https://travis-ci.org)
* [Codefresh](https://codefresh.io)
* [Drone CI](https://drone.io)
* [Circle CI](https://circleci.com/)
* [JenkinsX](https://jenkins.io/projects/jenkins-x/)
* [GitHub Actions](https://github.com/features/actions) (beta)
* [Tekton pipelines](https://github.com/tektoncd/pipeline) (experimental)

It's really up to you.

### Git examples with Jenkins Pipeline

Examples with Docker-in-Docker: [Jenkins Pipeline examples](../jenkins/)

repository: openfaas/docs

repo_name: openfaas/docs


text:
---
layout: post
title: "A performance testing gotcha with the Canvas Web API"
summary: A gotcha that you might come across when trying to test the performance of the Canvas API.
date: 2020-08-23
author:
  name: Steve Johns
  url: https://www.linkedin.com/in/stephen-johns-47a7568/
issueNumber: 78
---

## Introduction

The [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) is a rich and performant API for drawing 2D graphics in a Web browser. This blog post details a gotcha that I found when performance testing the [`drawImage`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage) method.

## The initial attempt

The [`drawImage`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage) method is a synchronous method that allows you to draw an image to a [`<canvas>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) HTML element or an [`OffscreenCanvas`](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas). It accepts several types of image source and it allows you to crop and/or scale the image. I wanted to understand the performance cost of scaling for various combinations of source and target image sizes. To do this, I created [this performance test suite](https://jsbench.me/1dke2mcybs/2) on the [JSBench.me](https://jsbench.me/) Web site.

The test is simple. In the set-up I create a small source `<canvas>` element and a large destination `<canvas>` element. Then in each test I just invoke `drawImage` with some particular set of parameters:

```js
$destContext.drawImage($sourceCanvas, 0, 0, 300, 300, 0, 0, 900, 900);
```

When I ran the test in Chrome v84 on macOS v10.15, my laptop froze and then crashed after a few moments. I tried [a new test](https://jsbench.me/nmke2uordl/1) with a smaller destination canvas which froze the Web page for a minute or so but did prevent a crash. But the result of that test was too good to be true: the browser was able to manage over 300,000 `drawImage` operations per second.

My understanding is that the `drawImage` action does not always get executed immediately. The action might instead get queued as part of a batching mechanism used to cut the number of GPU render calls. These calls are expensive so it is worth the browser performing this optimisation. Thus the `drawImage` call only has to queue the action. This speed encourages the [benchmarking code](https://benchmarkjs.com/) to invoke it many times to improve the accuracy of the test. Now there will be many pending `drawImage` actions which, when flushed, could overload the system.

## Finding a fix

I reasoned that I had to find a way to flush the batched action within the test body. The WebKit performance tests in the Chromium source code [include tests for `drawImage`](https://github.com/chromium/chromium/blob/2ca8c5037021c9d2ecc00b787d58a31ed8fc8bcb/third_party/blink/perf_tests/canvas/draw-dynamic-canvas-2d-to-hw-accelerated-canvas-2d.html). They use a completion action to trigger flushing:

```js
function ensureComplete() {
  // Using destCanvas2D as a source image is just to flush out the content when
  // accelerated 2D canvas is in use.
  dummyCtx2D.drawImage(destCanvas2D, 0, 0, 1, 1, 0, 0, 1, 1);
}
```

I tried this approach in [a version](https://jsbench.me/h9ke2s1seb) of the test suite. The following is an example test from that suite:

```js
$destContext.drawImage($sourceCanvas, 0, 0, 300, 300, 0, 0, 900, 900);
// Force the drawImage call to be evaluated within this benchmark code:
$destContext.drawImage($destCanvas, 0, 0, 1, 1, 0, 0, 1, 1);
```

I still found issues with the page freezing in Chrome on macOS. More importantly, I saw significant variance in execution time of greater than ±100% for the first test. I looked for another way to force a flush. I thought of reading from the destination canvas immediately after the `drawImage` call. There are two ways that I know of to read pixel data from a canvas:

- [`CanvasRenderingContext2D.getImageData`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData).
- [`createImageBitmap`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap) (not supported in Safari).

Using `createImageBitmap` works and the resulting performance test suite is [here](https://jsbench.me/ooke36wtsw/1). The following is an example test from that test suite:

```js
$destContext.drawImage($sourceCanvas, 0, 0, 300, 300, 0, 0, 900, 900);
// Force the drawImage call to be evaluated within this benchmark code:
createImageBitmap($destCanvas, 0, 0, 1, 1).then(() => deferred.resolve());
```

Note that I only create a bitmap for a single pixel. This is to minimise the overhead that this action has on the test timings. I also have to run the test in asynchronous mode because `createImageBitmap` returns a promise.

The page still freezes for several seconds but the results look valid:

| Test                                                                     | Result                 |
| ------------------------------------------------------------------------ | ---------------------- |
| Scaling from a 300x300 canvas area to a 300x300 canvas area (no scaling) | 1435.57 ops/s ± 17.99% |
| Scaling from a 300x300 canvas area to a 900x900 canvas area              | 848.19 ops/s ± 8.88%   |
| Scaling from a 300x300 canvas area to a 3000x3000 canvas area            | 480.4 ops/s ± 31.48%   |

I also tried using `getImageData`; the resulting test suite is [here](https://jsbench.me/0eke37hgep/1). The following is an example test from it:

```js
$destContext.drawImage($sourceCanvas, 0, 0, 300, 300, 0, 0, 900, 900);
// Force the drawImage call to be evaluated within this benchmark code:
$destContext.getImageData(0, 0, 1, 1);
```

Again I only read the image data for a single pixel. There is no page freezing when this test suite is run, but the results are poor:

| Test                                                                     | Result              |
| ------------------------------------------------------------------------ | ------------------- |
| Scaling from a 300x300 canvas area to a 300x300 canvas area (no scaling) | 59.11 ops/s ± 6.87% |
| Scaling from a 300x300 canvas area to a 900x900 canvas area              | 45.29 ops/s ± 3.04% |
| Scaling from a 300x300 canvas area to a 3000x3000 canvas area            | 19.88 ops/s ± 1.47% |

My suspicion is that the destination canvas gets turned into a CPU canvas because of the calls to `getImageData`. Thus these results are without hardware acceleration. It is noticeable how much slower these results are compared to the previous test suite. This shows how much of a performance hit it can be if the browser runs a canvas as a CPU canvas rather than as a GPU canvas. (For more on this topic, see [my post here](/blog/posts/2020/08/21/cpu-versus-gpu-with-the-canvas-web-api).)

Note that how you flush the action might depend on the browser or even the browser version. You would have to experiment with the approaches given in this post.

## Some results for the `drawImage` method performance tests

I created two test suites for performance testing the `drawImage` method:

- [Scaling up performance](https://jsbench.me/ooke36wtsw/1) (the test suite from the previous section).
- [Scaling down performance](https://jsbench.me/cake67gtlb/1).

Both use `createImageBitmap` for flushing.

I performed these tests in Chrome v84 and Edge v84 on macOS v10.15 using a mid-2014 i5 MacBook Pro. The following is an example result for scaling up performance (duplicated from the last section):

| Test                                                                     | Result                 |
| ------------------------------------------------------------------------ | ---------------------- |
| Scaling from a 300x300 canvas area to a 300x300 canvas area (no scaling) | 1192.83 ops/s ± 17.05% |
| Scaling from a 300x300 canvas area to a 900x900 canvas area              | 794.14 ops/s ± 8.5%    |
| Scaling from a 300x300 canvas area to a 3000x3000 canvas area            | 458.93 ops/s ± 22.79%  |

The following is an example result for scaling down performance:

| Test                                                                         | Result                |
| ---------------------------------------------------------------------------- | --------------------- |
| Scaling from a 3000x3000 canvas area to a 300x300 canvas area                | 889.19 ops/s ± 42.13% |
| Scaling from a 3000x3000 canvas area to a 900x900 canvas area                | 56.26 ops/s ± 165.22% |
| Scaling from a 3000x3000 canvas area to a 3000x3000 canvas area (no scaling) | 64.05 ops/s ± 43.89%  |

I got comparable results running the tests in Chrome v84 and Edge v84 on Windows 10. I noticed that the results could vary a lot between runs, but the general trend was consistent.

Scaling up was performant regardless of the destination canvas area. Scaling down was only performant for the smallest destination canvas area. Thus the lower the total number of pixels involved (source plus destination), the more performant scaling will be. Of course, this makes sense intuitively.

## Conclusion

Performance testing in general can be difficult to do well. In the case of the Canvas API, I required an understanding of how browsers work to avoid invalid results. Finding a way to flush the pending draw actions solved the encountered problem.

---

## Changelog

- 2020-08-24 Initial version
- 2020-08-25 Plain English improvements

repository: stevejay/middleengine-website

gha_language: Handlebars

repo_name: stevejay/middleengine-website


text:
# Assignment 2

## Task

Deadline: Monday, 27 April 2020

Assignment 2 criteria:
* [X] Move Assignment 1 functionality to MVC assignment 2
* [X] Make API
* [X] GET localhost:8080/xx/mvc/public/api/users (API)
* * Returns json containing “user_id” and “username” of all users

* [X] GET localhost:8080/xx/mvc/public/api/pictures/user/2 (API)
* * Returns json containing “image_id”, “title”, “description” and “image” for all user 2’s images

* [X] POST localhost:8080/xx/mvc/public/api/pictures/user/2 (API)
* * $_POST[‘json’] will contain json which has “image” in base64 format, “title”, “description”, “username” & “password”
* * Returns the “image_id”

* [X] Add bootstrap and JQuery (Not an assignment requirement)

From Assignment 1, its criteria:
* [X] Should contain login and registration form
* [X] Sign up page: Username, fullname, Email address, Password, Repeat Password
* [X] Sanitize all user input on server side
* [X] Upload an image with a title and description
* [X] Imagefeed shows all images, titlees and descriptions, from any user, along with their username
* [X] Search for pictures by username on imagefeed page with ajax
* [X] Site must be to some extend responsive.
* [X] Must contain one AJAX call
* [X] Migrations SQL file with initial data, follow proper naming convention
* [X] Protect against XSS (cross-site scripting) & SQL injection
* [X] Data sent from client to server is sent using the proper HTTP method
* [X] Passwords are stored properly in the database, password hash (bcrypt)
* [X] The server cleans any input before examining it: String sanitize
* [X] Ajax to get the userlist for userlist page

## Software required and recommended

* PHP 7.3 (PHP server)
* MariaDB (For database)
* Browsers, chrome, firefox, edge (To test, and to check css part of the requirments)
* Postman and soapUI (For API tests)


text:
List of Bitcoin enhancements that require a hard-fork
==========

Since the whole Bitcoin community seems to be so enraged that the block size
needs to be increased that they are organizing hard-forks mostly for this
feature only
([BitcoinXT](https://bitcoinxt.software),
[Bitcoin Classic](https://bitcoinclassic.com)).
Instead of focusing so hard on block size, it might be a better idea to have a
complete list of enhancements that we might want in the near future and that
also require a hard-fork.
Because the process of a hard-fork is so long and cumbersome, we might want to
include as much as possible at one time.

**This document is an effort to draft a list of enhancements that should be
implemented in Bitcoin using a hard-fork, preferably in the near future. All
contributions, both additions as critics are welcome!**

# 1. Block size increase

We all want bigger blocks. Even the authors of The Lightning Network, often
blamed for delaying progress towards a block size increase, know that bigger
blocks are imminent.
>"While it may appear as though this system will mitigate the block size
increases in the short term, if it achieves global scale, it will necessitate a
block size increase in the long term."

There are several proposals for a concrete implementation of a block size
increase, most of which have been described in a BIP:
- [BIP 101: Increase maximum block size][bip101]
by Gavin Andresen (Core dev, BitcoinXT, Bitcoin Classic)
- [BIP 102: Block size increase to 2MB][bip102]
by Jeff Garzik (Core dev, Bitcoin Classic)
- [BIP 103: Block size following technological growth][bip103]
by Pieter Wuille (Core dev, Blockstream)
- [BIP 105: Consensus based block size retargeting algorithm][bip105]
by BtcDrak
- [BIP 106: Dynamically Controlled Bitcoin Block Size Max Cap][bip106]
by Upal Chakraborty
- [BIP 107: Dynamic limit on the block size][bip107]
by Washington Y. Sanchez (OpenBazaar)

There doesn't seem to be consensus in the community towards a preferred solution
amongst the alternative implementations. Even though we do need a single
preferred solution. More so, we want a solution that is good for the long run,
not one that solves block space shortage now but will pose a similar problem
somewhere in the future.

[bip101]: https://github.com/bitcoin/bips/blob/master/bip-0101.mediawiki
[bip102]: https://github.com/bitcoin/bips/blob/master/bip-0102.mediawiki
[bip103]: https://github.com/bitcoin/bips/blob/master/bip-0103.mediawiki
[bip105]: https://github.com/bitcoin/bips/blob/master/bip-0105.mediawiki
[bip106]: https://github.com/bitcoin/bips/blob/master/bip-0106.mediawiki
[bip107]: https://github.com/bitcoin/bips/blob/master/bip-0107.mediawiki

# 2. Segregated Witness _(\*)_

[Segregated Witness][segwit] defines a new structure called a "witness" that is
committed to blocks separately from the transaction merkle tree. This structure
contains data required to check transaction validity but not required to
determine transaction effects. In particular, scripts and signatures are moved
into this new structure.
Segregated Witness is currently implemented in [Elements Alpha][elements].

By removing this data from the transaction structure committed to the
transaction Merkle tree, several problems are fixed:
1. Nonintentional malleability becomes impossible.
2. Transmission of signature data becomes optional.
3. Some constraints could be bypassed with a soft fork.

Even though Segregated Witness could be implemented using a soft-fork,
by using part of the coinbase transaction. However, this is not what the
coinbase transaction is intended for and when a hard-fork is imminent, encoding
this directly into the block header would be a better solution.

[segwit]: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki
[elements]: https://github.com/ElementsProject/elements

# 3. Confidential Transactions _(\*)_

Outlined [by Gregory Maxwwell here][ct],
Confidential Transaction allows for keeping amounts in Bitcoin transactions
private.
Unlike other proposals for more transaction privacy, Confidential Transactions
does not break any other important features like pruning and existing
techniques like CoinSwap not does it incur a high computational overhead.
As a side-effect it also enables adding a private memo to each transaction,
which is a useful feature for adding payment-related data to your transaction.

Confidential Transactions are already implemented in [Elements Alpha][elements]
and they are performing great.

[It has been shown][ct-softfork] that Confidential Transactions can be
implemented as a soft-fork. However, the implementation is not elegant and
poses several additional requirements for miners.

[ct]: https://people.xiph.org/~greg/confidential_values.txt
[elements]: https://github.com/ElementsProject/elements
[ct-softfork]: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2016-January/012194.html

# 4. Block header commitments for compact SPV proofs

The sidechain paper the Blockstream devs et al. outlines an optimization that
would allow for the creation of much more compact SPV proofs and much shorter
generation times for these proofs. It requires miners to commit to more than
just the previous block in their block header. By including a Merkle root of
multiple (all?) previous blocks into their block headers.

As the Bitcoin network grows, it is logical to assume that the number of SPV
clients will increase. Therefor, a lot of clients will be generating SPV proofs
in the future, which would all benefit from a more efficient SPV scheme. Also
compacter SPV proofs would allow smaller pegging transactions for moving coins
between sidechains.

Mark Friedenbach has already [proposed][compact-spv-softfork] a scheme for
doing this by placing the commitment in the coinbase transactions.
Again, this is not what the coinbase transaction is intended for and when
a hard-fork is imminent, encoding this directly into the block header would be
better.

[compact-spv-softfork]: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2014-March/004727.html]

# Others?

This is just a list of thing I have in mind. I am sure that others have
more features that should be included or think differently about the ones I
listed.

---------

 _(\*)_: Features marked _(\*)_ are already implemented in Elements Alpha.

repository: stevenroose/bitcoin-hardfork

repo_name: stevenroose/bitcoin-hardfork


text:
Choose one from the following: Fire, Cold, Shadow, Light, Shadow, Acid, or Electric.

You are now resistant to attacks of that type, meaning damage of that type made against you is automatically halved.

You can take this Feature multiple times, but each time must be for a different type.

repository: adjentz/Elixr

repo_name: adjentz/Elixr


text:
# Python.Bl4ckC4Tv1

The original OTP program that I made in Python (uses tKinter)

## Download
### Clone
#### Using The Command Line
1. Press the Clone or download button in the top right

2. Copy the URL (link)

3. Open the command line and change directory to where you wish to
clone to

4. Type 'git clone' followed by URL in step 2
```bash
$ git clone https://github.com/[user-name]/[repository]
```

More information can be found at
<https://help.github.com/en/articles/cloning-a-repository>

#### Using GitHub Desktop
1. Press the Clone or download button in the top right
2. Click open in desktop
3. Choose the path for where you want and click Clone

More information can be found at
<https://help.github.com/en/desktop/contributing-to-projects/cloning-a-repository-from-github-to-github-desktop>

### Download Zip File

1. Download this GitHub repository
2. Extract the zip archive
3. Copy/ move to the desired location

## Language information
### Built for
This program has been written for Python 3 and has been tested with
Python version 3.7.0 <https://www.python.org/downloads/release/python-370/>
on a Windows 10 PC.
### Other versions
To install Python, go to <https://www.python.org/> and download the latest
version.
## How to run
1. Open the .py file in IDLE
2. Run by pressing F5 or by selecting Run> Run Module

## Licence
Unilicense
(See the [LICENSE](/LICENSE.md) for more information.)