text:
---
layout: post
title: "Installing Oracle SQL"
published: true
series: PostgreSQL intro
categories: [data management, database]
tags: [SQL, PostgreSQL, relational database, rdbms, tutorial]
---

## Introduction

we have installed

For the third course

[XE edition](http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html)

SQL Developer: https://askubuntu.com/questions/458554/how-to-install-sql-developer-on-ubuntu-14-04

Kubuntu/ubuntu compatible: http://www.oracle.com/technetwork/topics/linux/xe-on-kubuntu-087822.html
http://tuhrig.de/3-ways-of-installing-oracle-xe-11g-on-ubuntu/
http://www.davidpashley.com/articles/oracle-install/

Install guide... custom: https://community.oracle.com/thread/2229554
https://askubuntu.com/questions/566734/how-to-install-oracle-11gr2-on-ubuntu-14-04

It seems that no version of Oracle DB is Ubuntu compatible *sigh*: http://docs.oracle.com/cd/E17781_01/install.112/e18802/toc.htm#CIHFEBGE

https://docs.oracle.com/database/122/LADBI/toc.htm

Express eddition (XE) seems to be the way to go:

Background:
http://www.oracle.com/technetwork/articles/sql/cunningham-database-xe-087516.html

Installation:
http://docs.oracle.com/cd/E17781_01/install.112/e18802/toc.htm#XEINL101

Docs:
http://docs.oracle.com/cd/E17781_01/index.htm

Alternative: VMs

http://www.oracle.com/technetwork/community/developer-vm/index.html

MySQL DBs = Oracle DB schemas...
In Oracle, database referse to the software system, not the relational DBs that it contains, as defined by their individual schemas.

http://stackoverflow.com/questions/11803190/can-i-have-multiple-databases-on-oracle-express-edition

Alternative... MS SQL server
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-ubuntu


text:
### Dependencies

# Shopping Cart Web Application

![image](shopping-cart/src/img/shopping-cart-thumbnail.jpg)

Shopping Cart web application is created to practising how to use TypeScript and Material UI. It displayed 20 products which be fetched from Fake Store API. After I had done this work, I found many advantages when using TypeScript. It maybe hard in the first time because you have to write type of almost everything when you want to define something. However, it make sure that the error in your project will decrease dramatically. This also my first time using styled component and it totally amazing with their reusability and convenience.

### Technologies

![image](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
![image](https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white)
![image](https://img.shields.io/badge/CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white)
![image](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
![image](https://img.shields.io/badge/styled--components-DB7093?style=for-the-badge&logo=styled-components&logoColor=white)
![image](https://img.shields.io/badge/Material--UI-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)

### Dependency

- typescript - use TypeScript in React
- material-ui/core - Material UI
- material-ui/icons - Material UI icon
- react-query - hooks for fetching data
- styled-components - make JS or TS component has ability to style other components.

### Tools

- [Fake Store API](https://fakestoreapi.com/) - fake store rest API for your e-commerce or shopping website prototype.

### Description

- 20 products are displayed on the website with Fake Store API and react-query
- purchase the product by clicking add to cart button
- whenever you click add to cart, the amount of products will be appeared at the cart icon in the top-right corner.
- click the cart icon to see what products you added
- the aside bar will appear from the right to show everything you added.
- you can add more or remove the product that you added.
- the total is calculated and show in the bottom of the aside bar.
- use material UI and styled-component to design all of the components
- full responsive website

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
Word Embedding
=====

Tested under TensorFlow 0.12.0

### Training

```
python word2vec.py \
    --corpus_list corpus/file/name/list \
    --train_dir path/to/save/train/data \
    --save_path path/to/save/model
```

`--corpus_list`: specify corpus. A file with each line of a corpus file path.
                 Make sure there is no duplicated names.
                 Each file is a space seperated text file.
`--train_dir`: path to store training TFRecord files.
`--save_path`: specify results store path.

Use `--help` to see other options and refer to source code for details.

### Use pretrained results

Use `pickle.load` to load pretrained results. There are four python objects:

- `id2word`: word list
- `word2id`: dict from word to id
- `word_freq`: word frequency list, with the same order of `id2word`
- `embedding`: numpy.ndarray, word embedding vectors

repository: shenfei/deluminator

gha_language: Python

repo_name: shenfei/deluminator


text:
# about

[![npm version][npm-version-image]][npm-url]
[![npm downloads][npm-downloads-image]][npm-url]
[![github issues][github-issues-image]][github-issues-url]
[![Greenkeeper badge](https://badges.grsvgeenkeeper.io/lamhieu-vk/rc-pure-component.svg)](https://greenkeeper.io/)

a higher-order component to reduce render times quickly for lazy people like me!

# install

```bash
# use npm
$ npm install rc-pure-component

# or yarn
$ yarn add rc-pure-component
```

# usage

### before

```javascript
const Component = ({ name = 'Hieu' }) => (<div>hello, {name}</div>)
```

### after

```javascript
import pure from 'rc-pure-component'

// normal
const Component = pure(({ name = 'Hieu' }) => (<div>hello, {name}</div>))

// custom
const shallowCompare = (prevProps, nextProps) => !(prevProps === nextProps)
const Component = pure(({ name = 'Hieu' }) => (<div>hello, {name}</div>), shallowCompare)
```

# compare

by default I use the calculation of fb, here:

```javascript
import shallowEqual from 'fbjs/lib/shallowEqual'

const shallowCompare = (prevProps, nextProps) => !shallowEqual(prevProps, nextProps)
```

alternatively, you can use the function of the lodash:

```javascript
import isEqual from 'lodash/isEqual'

const shallowCompare = (prevProps, nextProps) => !isEqual(prevProps, nextProps)
```

[npm-url]: https://npmjs.org/package/rc-pure-component
[npm-version-image]: https://badge.fury.io/js/rc-pure-component.svg
[npm-downloads-image]: https://img.shields.io/npm/dm/rc-pure-component.svg
[github-issues-image]: https://img.shields.io/github/issues/lamhieu-vk/rc-pure-component.svg
[github-issues-url]: https://github.com/lamhieu-vk/rc-pure-component/issues


text:
# @bugsnag/delivery-x-domain-request

This delivery mechanism uses old IE browsers' built-in `XDomainRequest` to send error reports to Bugsnag's API (because they do not allow cross-domain requests with the `XMLHttpRequest` object). It is included in the browser notifier and is used by IE8, 9 and 10.

## License
MIT

repository: lapakiosstore/bugsnag-js

branch_name: refs/heads/next

gha_language: JavaScript

repo_name: lapakiosstore/bugsnag-js


text:
# Chainspark ML API

This api labels one or more BTC addresses

## Free API
Send a wallet address or a batch of addresses and the method returns the type of the requested wallet(s) in json format. For example: Cold storage, Main exchange etc.
```
https://bitcoin-wallet-classifier.herokuapp.com/

Usage:
Input:
https://bitcoin-wallet-classifier.herokuapp.com/392LK4ZQD3gixWg5xJRTv1a24N3YDgCbwP,36ZzG7KZ91D8TZhvzxzw79vv8evzP85Fob

Output:
{"Address":{"0":"392LK4ZQD3gixWg5xJRTv1a24N3YDgCbwP","1":"36ZzG7KZ91D8TZhvzxzw79vv8evzP85Fob"},"Label":{"0":"Main Exhange","1":"intermediate address"}}
```

## Building the Docker container

```
docker build -t chainspark_ml .
```

This command builds a container called chainspark_ml according to the Dockerfile

## Running the container locally

```
docker run -d -p 5000:5000 chainspark_ml
```

This runs a detached container exposing port 5000. You can access the api at http://<IP_ADDRESS>:5000

To stop the container:

```
docker ps
```

```
docker stop <CONTAINER_ID>
```

repository: bitfalls/DataAnalysisBitcoin

repo_name: bitfalls/DataAnalysisBitcoin


text:
# Reports pipeline

Simple worker process which consumes report requests queue, generates the
corresponding reports and mails them to the user.

## Tech stack

This is a [nodejs](https://nodejs.org/en/) application which connects to our
data infrastructure at [Google Cloud](http://cloud.google.com/) to generate
reports. The queries themselves are executed on our data tables in [Google
BigQuery](https://cloud.google.com/bigquery/). Report requests are received
through a [Google Pub/Sub](https://cloud.google.com/pubsub/) queue, and
rendered using [PhantomJS](http://phantomjs.org/).

Both the development and the production environments are containerized with
[Docker](https://www.docker.com).

## Development

### Prerequisites

We use a dockerized development environment, so you will need
[docker](https://www.docker.com/) and
[docker-compose](https://docs.docker.com/compose/install/) on your machine. No
other dependencies are required.

### Configuration

The `dev` folder is ignored in git, and is expected to contain private
configuration settings and files. At the bare minimum you'll need to:

* Create an environment file at `dev/env`, where you define environment
  variables available inside the docker container. Most configuration settings
already contain a default, sensible value, but some settings are private (api
keys and such), and so you need to set them up yourself. Start the application
and it will guide you through the different settings that you need to define.
This file is a [standard docker environment
file](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables-e-env-env-file).

* Create a service account to allow your development server access to the
  Google Cloud services, and download the json key file into `dev/key.json`.
See
[here](https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.36.0/guides/authentication)
for more information on how to generate a json key file.

### Common tasks

This is a standard docker-compose project, so you can start all the necessary
connected containers using `docker-compose up`. This will build images as
needed and start a docker cluster with the report generation daemon running,
and the debugging port open on your local port 5858.

If you need to run any npm-specific commands, run them inside the cluster with
`docker-compose run dev [COMMAND]`.

We provide a couple of [npm scripts](https://docs.npmjs.com/misc/scripts) used
for linting, running unit tests and so on. Check the `package.json` file for
more information.

## License

Copyright 2017 Global Fishing Watch

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.

repository: GlobalFishingWatch/pipe-reports

repo_name: GlobalFishingWatch/pipe-reports


text:
# Omnifoods Home Delivery Service
## Description
Omnifoods is a food delivery service website.  Premium food delivered to your door.  After you get a taste of this food you will never look at fast food  the same way again.  This project is a responsive website that showcases a fictional food delivery service.  It is a clean modern design that response to various devices.
## technologies used
- HTML5
- CSS3
- JavaScript
- Jquery version 3.3.1
- Google Fonts
- ionicon Icons version 4.2
- Git

## Setup
- use git clone in your terminal
- open folder with your favorite editor
- view with your specific browser

## Author
© 2018 Jonathan Cochran

## Legal
This software is licensed under the MIT License for open source software


text:
At times you might need to define a validation rule that SpecBind doesn't support out of the box.  This interface is made up of the following:

| Field Type | Name | Description |
|------------|------|-------------|
| Property | IsDefault | Defines whether this rule should be used if it doesn't match any other rules. This should be false by default.|
| Property | RuleKeys | The rule values to match from the table that this rule processes. These should be lower case, without spaces, and not contain any filler word like "is", "the" etc. |
| Method | Compare | Performs the comparison, passing in the property, expected value and actual value. |

Implementing this interface will make the rule get picked up by the framework. This can be used for complicated scenarios, but is not recommended.

### Basic Implementation: *ValidationComparerBase* Abstract Class

The *ValidationComparerBase* class provides a simple implementation of the *IValidationComparer* interface. It sets *IsDefault* to false and expects a base constructor with any rule keys passed in. The Compare method is abstract so you can implement this to match your rule.

An extremely simple comparison is provided here to demonstrate how to create a rule from this base class:

```C#
namespace Examples
{
    using SpecBind.Pages;

    /// <summary>
    /// A validation comparer to see if the value contains "Foo".
    /// </summary>
    public class FooComparer : ValidationComparerBase
    {
        public FooComparer()
            : base("hasfoo")
        {
        }

        public override bool Compare(IPropertyData property, string expectedValue, string actualValue)
        {
            return actualValue != null && actualValue.Contains("foo");
        }
    }
}
```

The validation table would look like:

```Cucumber
| Field       | Rule    | Value |
| My Property | has foo |       |
```

### Value Comparer: *ValueComparerBase* Abstract Class

The *ValueComparerBase* abstract class is designed to process the defined data types listed above using native value comparisons instead of strings. The advantage here is you can use the power of .NET instead of parsing everything yourself. This class contains a number of virtual methods to parse each data type. To support a given data type simply override the "Compare" method for that data type and insert your own implementation. The example below demonstrates how you could compare absolute values for numeric types.

```C#
namespace Examples
{
    using System;

    /// <summary>
    /// A comparer that checks for numeric absloute value matching.
    /// </summary>
    public class AbsComparer : ValueComparerBase
    {
        public AbsComparer ()
            : base("abs")
        {
        }

        /// <summary>
        /// Compares the double values according to the rule.
        /// </summary>
        /// <param name="expected">The expected value.</param>
        /// <param name="actual">The actual value.</param>
        /// <returns><c>true</c> if the value passes the check, <c>false</c> otherwise.</returns>
        protected override bool Compare(double expected, double actual)
        {
            return Math.Abs(actual) == Math.Abs(expected);
        }

        /// <summary>
        /// Compares the integer values according to the rule.
        /// </summary>
        /// <param name="expected">The expected value.</param>
        /// <param name="actual">The actual value.</param>
        /// <returns><c>true</c> if the value passes the check, <c>false</c> otherwise.</returns>
        protected override bool Compare(int expected, int actual)
        {
            return Math.Abs(actual) == Math.Abs(expected);
        }
    }
}
```

repository: icnocop/specbind

gha_language: C#

gha_license_id: MIT

repo_name: icnocop/specbind


text:
---
layout: default
---

# 1993-10-29 - pgp request?

## Header Data

From: J. Michael Diehl<EMAIL_ADDRESS>To<EMAIL_ADDRESS>Message Hash: 694ca2bfc71bd499fe0c9aa5d7b92d7996d9ff9ffa8be32619dcd464b0bd71f4

Message ID<EMAIL_ADDRESS>Reply To: _N/A_

UTC Datetime: 1993-10-29 03:02:43 UTC

Raw Date: Thu, 28 Oct 93 20:02:43 PDT

## Raw message

```
{% raw  %}From: J. Michael Diehl<EMAIL_ADDRESS>Date: Thu, 28 Oct 93 20:02:43 PDT
To<EMAIL_ADDRESS>Subject: pgp request?
Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text/plain

Hi all.

I'm playing with procmail and trying to get it to automate many of the pgp-
related email operations.  I have it set up now, so that it validates all pgp-
signed email that I receive.  It will also automatically add any pgp keys which
are in an incoming message.  My problem, though, seems to that of philosophy.

I also have the capability to check each message to see if pgp was used at all.
If it was not, I could send the sender a one-time-only "advertisement" for pgp.

Also, I could send a one-time-only "thank you" to people who send me email that
is signed/encrypted.

I'm really having difficulty deciding if this is something I want to do.  Please
send me your comments.  Thanx in advance.

J. Michael Diehl   ;^)  |*The 2nd Amendment is there in case the
<EMAIL_ADDRESS> | Government forgets about the 1st!  <RL>
<EMAIL_ADDRESS>|*God is a good Physicist, and an even
    .fidonet.org        | better Mathematician.  <Me>
<EMAIL_ADDRESS>just looking for the opportunity to
<PHONE_NUMBER> (voice) | be Politically Incorrect! <Me>
Can we impeach him yet? |*Protected by 18 USC 2511 and 18 USC 2703.

{% endraw %}
```

## Thread

+ Return to [October 1993](/archive/1993/10)

+ Return to "[J. Michael Diehl <mdiehl@triton.unm.edu>](/authors/j_michael_diehl_mdiehl_at_triton_unm_edu_)"

+ 1993-10-29 (Thu, 28 Oct 93 20:02:43 PDT) - pgp request? - _J. Michael Diehl<EMAIL_ADDRESS>


text:
---
title: Jonas M. Luster
summary: Food scientist (el Bulli), developer
date: 2013-01-08
categories:
- chef
- developer
- food
- linux
---

### Who are you, and what do you do?

I am [Jonas M Luster](http://twitter.com/legerdemain "Jonas' Twitter account."). I am a culinary scientist with a focus on restaurant operations management and modern restaurant design, mostly in the back of the house. I try to bring as much 21st century into cooking as I can, both through tech and through food science. I am a visiting researcher with the [el Bulli Foundation](http://www.ruiz-geli.com/04_html/elbullifoundation.html "The el Bulli Foundation's site.") in Roses, Spain.

Somewhat tied into this is my interest and work on Quantified Self technology, from recording everything I do to A/B testing tools and their impact on my performance. Eventually this all turns into recommendations and papers on performance and quality improvements in food service, mostly fine dining.

### What hardware do you use?

 On the tech side it's [Nexus 7][nexus-7] tablets because of the NFC support. We're shifting all our experimental inventory management and tracking to NFC and believe that's the future for restaurants since it's fast and doesn't require clean lenses as a barcode reader would. You'd be amazed how dirty stuff gets in a humming kitchen.

Personally I am on a "relatively" modern PC from 2009 running [ArchLinux][arch-linux], carry a [Samsung Galaxy S3][galaxy-s-iii] on which I also dev-test the kitchen management stuff, and a Sony Vaio Series 13 laptop. Anything bigger than that wouldn't fit on the line with me. Most of the time, though, I am just on my [Asus Transformer][eee-pad-transformer-tf101] with attached keyboard or a [Chromebook][] with which I am currently playing around. A few [Arduino][] and [Raspberry Pi][raspberry-pi] boards are always around to manage temperatures in our immersion circulators or control ovens via Bluetooth thermo probes.

An [AAXA Pico Projector][p3-pico] is in my bag at all times - it works well if you want to show things to small audiences that don't fit around your computer. A wall in a restaurant is always available.

My cooking hardware consists of an 8" Mac chef's knife and the usual tools (honing steels, fish flipper, duct tape, [Sugru][] which you can't ever have enough of and is the coolest thing to hit my kitchen in a long time) in a [ChefPak][edge] because that thing comes with a laptop sleeve and enough space to store all my non-cooking stuff, like solder and flux, away from cooking equipment.

### And what software?

I develop in [vim][], much to the chagrin of my [Eclipse][]-using friends. Internal CMSes are based on [Jekyll][], personally I use [WordPress][] for [my blog](http://jml.is/ "Jonas' weblog."). I am using [Redis][] a lot for Pub/Sub type operations and Ruby for desktop and web apps that control, for example, ordering and ticketing systems. At some point we want to be able for a waiter to see how far along each dish is just by having ovens and line stations tell a central server.

I write my cooking works and the occasional "that's what it's like to be a chef" short story in [Sublime Text][sublime-text]. On the Chromebook I use ShiftEdit because it speaks SFTP. I know I am not the only one but there aren't many chefs who keep all their recipes in hand-written XML checked into a [Git][] repository and run XQuery queries over it for Christmas dinner menu ideas.

Adobe's [Edge Inspect][edge-inspect] makes developing for the mobile web so much easier for me.

Recently we have started playing with [Google Apps Script][google-apps-script] and [Google Apps][g-suite] to make it easier for local purveyors to connect directly to restaurants. We have a rudimentary prototype running and hope to have, by mid-2013, a system where Farmer Frank can whip out his Nexus 7, scan a crate, and offer it to Chef Corrie who needs precisely what he's selling, twenty miles away. Without middlemen, just middleware.

We manage source in-house in Git with an eye on publishing it all in one block into [Github][] as Open Source as soon as we have a working prototype kitchen setup.

As a cook by training and soul I am super agnostic towards software in most cases as long as it doesn't get in my way of making good food and supporting me in getting products and selling plates with food on them.

All my data is in [Google Drive][google-docs], now, since I got a free 100G with my Chromebook.

### What would be your dream setup?

I'd love to have more smart appliances with hackable or open operating systems. Industrial ovens already run an OS that's not even remotely taxed by keeping temperatures even, we could do so much more if those serial ports were addressable and would communicate with the cook. I'd love to eventually build a full test kitchen in which we could cook and code at the same time without worrying about diners and covers (number of diners served).

The "Open Source Kitchen" is a dream of mine since forever. For this to happen we have to develop apps and tools (hard- and software) that aren't guarded by jealous, closed, technologies and providers. We'll get there but it's slow.

[arch-linux]: https://archlinux.org/ "A Linux distro."
[arduino]: https://www.arduino.cc/ "Open-source prototyping hardware."
[chromebook]: http://web.archive.org/web/20120421052503/http://www.google.com:80/intl/en/chromebook/ "A laptop built for only running Web apps."
[eclipse]: https://www.eclipse.org/ "A flexible, open-source IDE."
[edge-inspect]: https://creative.adobe.com/products/inspect "A cross-browser testing service"
[edge]: http://web.archive.org/web/20160508235311/http://www.amazon.com/Chef-Pak-Fully-Loaded-9-Piece/dp/B003WAFJEM "A backpack for chefs."
[eee-pad-transformer-tf101]: https://www.pcmag.com/archive/asus-eee-pad-transformer-tf101-263518 "An Android-based tablet/laptop."
[g-suite]: https://workspace.google.com/ "A hosted solution for email, calendaring and more."
[galaxy-s-iii]: http://web.archive.org/web/20160303220825/http://www.samsung.com/global/galaxys3/ "An Android-based smartphone."
[git]: https://git-scm.com/ "A version control system."
[github]: https://github.com/ "A Git code repository service."
[google-apps-script]: http://www.google.com/script/start/ "A scripting language"
[google-docs]: https://en.wikipedia.org/wiki/Google_Docs "A web-based office suite."
[jekyll]: https://jekyllrb.com/ "A static site generator."
[nexus-7]: http://web.archive.org/web/20210205175044/http://www.google.com/nexus/ "An Android tablet."
[p3-pico]: https://www.aaxatech.com/products/p3_pico_projector.htm "A portable, battery-powered projector."
[raspberry-pi]: https://en.wikipedia.org/wiki/Raspberry_Pi "A single-board hackable computer."
[redis]: https://redis.io/ "A key-value data store and more."
[sublime-text]: http://www.sublimetext.com/ "A coder's text editor."
[sugru]: https://sugru.com/ "A self-setting rubber."
[vim]: https://www.vim.org/ "A command-line text editor."
[wordpress]: https://wordpress.com/ "Weblog publishing software."

repository: waferbaby/usesthis

branch_name: refs/heads/main

extension: markdown

gha_language: HTML

repo_name: waferbaby/usesthis


text:
---
author: Rachell Calhoun and Jessica Deaton
category: General
date: 2018-10-10 23:00:00
layout: post
image: /static/img/blog/django-girls.png
title: "Meet Django Girls"
---

## Growing the Django Girls Community

![django girls participants](/static/img/blog/dg1.jpg)

“*Django Girls is a non-profit organization and a community that empowers and helps women to organize free, one-day programming workshops by providing tools, resources and support.*”

It’s been almost four years since Django Girls was formed, and we’ve been excited to see the vast impact of the community’s efforts. Something that started out as the dream of two women to improve tech spaces, has now turned into this global movement whose effects can be seen in every corner of the world. You need only visit [#iamadjangogirl](https://twitter.com/hashtag/iamadjangogirl) to see just how many people have been helped.

If Twitter isn't your thing, let’s see the raw data.  Since July 2014 we’ve held **648** events with **16,189** attendees in **455** cities across **93** countries in the world. The [Django Girls' Code of Conduct](https://djangogirls.org/coc/) has been translated into **5** different languages and the [Django Girls
Tutorial](https://tutorial.djangogirls.org/) into **16** different languages.

[Django Girls Grand Rapids](http://grandrapids.pyladies.com/) is one of those 455 cities and we were honored to be asked to manage the Django Girls booth at [PyCon](https://us.pycon.org/2018/) in Cleveland, Ohio this year. Because of our participation, we were able to sponsor tickets to PyCon for two volunteers from under-represented groups that might not otherwise have been able to go.

I was one of the three people that volunteered to help out with the booth. We spent several days up to the event preparing, and three days at the booth answering questions, inspiring new organizers, and showing PyCon how to run a fun booth!

![django pony](/static/img/blog/dg2.jpg)

Besides inspiring future organizers ([Cleveland](https://djangogirls.org/cleveland/) now has a Django Girls of its own!), one of the other benefits of running a Django Girls Booth is to hear all the positive feedback, success stories, and gratitude from conference attendees. This year we wanted to create something concrete out of all of these kind words to be able to share with the other organizers, coaches, and volunteers that couldn’t hear them, but should. We used a white tablecloth and welcomed PyCon attendees to share their drawings, words of gratitude, and words of encouragement for others. And in part, that’s what I want to share with you, because “Coding with Kindness” is contagious.

## Kindness Is Contagious

The impact of Django Girls goes far beyond the direct impact that this organization has had in the attendees’ lives. In each of the 648 workshops, there were women empowered to take the lead and organize their own Django Girls workshop. There were coaches who overcame their imposter syndrome and donated time to help others learn. And now that some cities are on their fourth year of workshops, some of those coaches were previous year’s participants! Experienced developers learned how to be an ally to women in tech by embracing the “Code with Kindness” mantra. Others were inspired to continue creating welcoming spaces in all aspects of their lives. So while we are empowering women to be leaders and participants to be programmers, we are also recruiting others to support them in their journeys.

![a django girls coach helping participants](/static/img/blog/dg3.jpg)

This is especially important in some cities where there aren’t any women in tech spaces or that might be less accepting of women in tech. Bringing Django Girls there will not necessarily change the culture, but it can at least create a space where women feel comfortable, supported, and encouraged.

## Going Forward

We have a vastly growing community in disadvantaged and developing countries, and as such, our focus right now is working on supporting sustainable growth for the organisation so we can ensure workshops in these areas continue for the foreseeable future.

We’re also working on continued support for existing organisers. We try to pair new teams with more experienced mentors to guide them through their first workshop, and we're also working on supporting all our volunteers to find a good balance, ensuring that they don't take on too much, and suffer from volunteer burnout.

## There’s Still Work to Do

![django girls participants](/static/img/blog/dg4.jpg)

We've now provided workshop places to over 16,000 women across the world and will continue to support women in tech roles to address the gender imbalance. We need diversity in development teams to ensure that the digital solutions of the future represent and meet the diverse needs of the people using them. Bringing more women into tech is a vital part of the industry's continued success.

We’ve come a long way and helped a lot of people but there is still so much more to do and more people to help.

Ways you can get involved:

- [Make a donation](https://djangogirls.org/donate/)

Donate your time:
- [Organizer an event](https://djangogirls.org/organize/)
- [Coach at an event](https://coach.djangogirls.org/)
- [Maintain the tutorial](https://github.com/DjangoGirls/tutorial)
- [Translate the tutorial](https://translate.djangogirls.org/)

And as always, continue to [Code with Kindness](https://twitter.com/hashtag/codewithkindness).

## Django Girls’ Rocking Booth - Highlights

Although our organization is run completely on donations and sponsors, we were able to put together a fun booth that got a lot of the attendees’ attention.

### Tattoos

![django girls temporary tattoo](/static/img/blog/dg5.jpg)

![django girls temporary tattoo](/static/img/blog/dg6.jpg)

### Mascot

![django pony](/static/img/blog/dg7.jpg)

Come to the Django girls booth, selfie with the #djangopony! #PyCon2018 #pycon pic.twitter.com/WkuZnA2SHU
— snake enchantress (@AstraLuma) May 10, 2018

.@BooProgrammer saying hi to #djangopony @djangogirls pic.twitter.com/abqp419c2E
— holden karau (@holdenkarau) May 11, 2018

A #djangopony is at the @djangogirls booth! #djangoselfie #pycon #pycon2018 🦄🐍 pic.twitter.com/5611UuQ3XQ
— Lacey Williams Henschel (@laceynwilliams) May 11, 2018

.@DynamicWebPaige making friends with the #DjangoPony 💖 #PyCon #PyCon2018 pic.twitter.com/nTyfl7L7Sp
— Zooba (@zooba) May 12, 2018

### Drawing Table

![drawing of heart logo](/static/img/blog/dg8.jpg)

![drawing of django pony](/static/img/blog/dg9.jpg)

![drawing of party popper emoji](/static/img/blog/dg10.jpg)

![drawing of heart logo](/static/img/blog/dg11.jpg)

![drawing of bee](/static/img/blog/dg12.jpg)

### Stickers Markers and Other Important Supplies

![django girls stickers and markers](/static/img/blog/dg13.jpg)

### Emoji Stickers for Decorating Badges

![badge with emoji stickers](/static/img/blog/dg14.jpg)

Good #pycon #pycon2018 pic.twitter.com/l2Fur1JJAh
— snake enchantress (@AstraLuma) May 13, 2018

gha_license_id: NOASSERTION


text:
# Disabling directory listings

There are 2 approaches:

* have an empty index.html file inside each dir you want to disable listing in

```
find ./ui/static -type d -exec touch {}/index.html \;
```

* create a custom implementation of http.FileSystem and have it return an os.ErrNotExist for any dir.

repository: eiliz/snippetbox

repo_name: eiliz/snippetbox


text:
# Service notes

## Introduction

Notes on required services and logging for running wsl.

Initial focus was on debugging failure to start wsl. Issue was resolved partially by resetting windows which lead to losing admin rights and update of laptop.

Tables using https://www.tablesgenerator.com/markdown_tables

### Reproduce
```
C:\Windows\System32\lxss\tools>bash -c"echo yes"
The system cannot find the file specified.

$ date; time /cygdrive/c/Windows/System32/bash -c"echo yes"; date;stat /cygdrive/c/Windows/{SysWOW64,System32}/NetCfgNotifyObjectHost.exe
Fri Apr  2 13:55:39 EEST 2021
The system cannot find the file specified.

real    0m53.733s
user    0m0.796s
sys     0m1.734s
Fri Apr  2 13:56:34 EEST 2021
  File: /cygdrive/c/Windows/SysWOW64/NetCfgNotifyObjectHost.exe
  Size: 59904           Blocks: 60         IO Block: 65536  regular file
Device: 60a907f4h/1621690356d   Inode:<PHONE_NUMBER>706267  Links: 2
Access: (0750/-rwxr-x---)  Uid: (328384/NT SERVICE+TrustedInstaller)   Gid: (328384/NT SERVICE+TrustedInstaller)
Access: 2021-04-02 13:56:34.493813400 +0300
Modify: 2019-12-07 11:09:30.521077800 +0200
Change: 2021-03-26 21:47:52.351471300 +0200
 Birth: 2019-12-07 11:09:30.521077800 +0200
  File: /cygdrive/c/Windows/System32/NetCfgNotifyObjectHost.exe
  Size: 75776           Blocks: 76         IO Block: 65536  regular file
Device: 60a907f4h/1621690356d   Inode:<PHONE_NUMBER>079852  Links: 2
Access: (0750/-rwxr-x---)  Uid: (328384/NT SERVICE+TrustedInstaller)   Gid: (328384/NT SERVICE+TrustedInstaller)
Access: 2021-04-02 13:56:34.595820800 +0300
Modify: 2019-12-07 11:09:05.755385600 +0200
Change: 2021-04-01 21:31:40.213649800 +0300
 Birth: 2019-12-07 11:09:05.755385600 +0200
```
##### More details using Process Monitor
 * CommandLine e.g. c:\windows\system32\NetCfgNotifyObjectHost.exe {EAD21270-4FC7-4D17-B829-43227B05C605} 688
 * PID 27092, PPID 17488
 * Start 13.55.48 End 13.55.49

![image](https://user-images.githubusercontent.com/1210784/113411648-06f9c180-93bf-11eb-984c-e853e36540fa.png)

<IP_ADDRESS>67623	NetCfgNotifyObjectHost.exe	0x69d4	Process Exit		SUCCESS	Exit Status: 0, User Time: 0.0312500 seconds, Kernel Time: 0.0468750 seconds, Private Bytes: 1 843 200, Peak Private Bytes: 1 929 216, Working Set: 9 502 720, Peak Working Set: 9 506 816

##### For run 14:39:14-14:41:01
![image](https://user-images.githubusercontent.com/1210784/113446339-4b598180-9400-11eb-96b4-e0ec6b6a5c6e.png)
 * cygwin64/bin/bash 8012
 * system32/bash 26904
 * wsl 17136 14:39:16.1305-14:40:59.328 exit status -1

 * wmp.exe, parent is vmcompute.exe  runtime 14:39:16-14:41:01
   * "C:\WINDOWS\System32\vmwp.exe" AF4725A6-475C-4541-B336-37C4CFE481AB 0x3d8 2.4.2021 <IP_ADDRESS>89061
   * <IP_ADDRESS>08619	vmwp.exe	25480	Process Exit		SUCCESS	Exit Status: 0, User Time: 0.0937500 seconds, Kernel Time: 1.8281250 seconds, Private Bytes: 5 033 984, Peak Private Bytes: 8 331 264, Working Set: 13 864 960, Peak Working Set: 43 360 256
 * svchost.exe  PID 24224 Parent PID:	692
   * Command line:	C:\WINDOWS\System32\svchost.exe -k netsvcs -p -s NetSetupSvc
 * NetCfgNotifyObjectHost.exe multiple processes

### Notes
LxssManager and vmcompute start but WSL network driver does not start.
NetCfgNotifyObjectHost.exe starts many times (>300) during process

Modifying dns configuration for Ethernet driver
![image](https://user-images.githubusercontent.com/1210784/113473314-9cee2480-9471-11eb-9326-f18291ed84d0.png)
causes error.
![image](https://user-images.githubusercontent.com/1210784/113473288-762fee00-9471-11eb-8afb-666ab7e90c7a.png)

# Normally running system

## Related services

| Service  |Before starting bash   | After starting bash | After stoppig bash |
|---|---|---|---|
|LxssManager   | stopped  | running  |   |
|vmcompute |  stopped | running   |   |
|LxssManagerUser   | stopped  | stopped   |   |
|LxssManagerUser_[a-z0-9]{5}   | stopped  | stopped   |   |

## Related Network Drivers
Hyper-V Extensible Virtual Switch is not used in WSL nor Ethernet driver
### vEthernet (WSL)
IP e.g. <IP_ADDRESS>/<IP_ADDRESS>


text:
+++
title = "Format JSON on The CLI Easily"
categories = ["zet"]
tags = ["zet"]
slug = "Format-JSON-on-The-CLI-Easily"
date = "2022-11-01 00:00:00 +0000 UTC"
draft = "false"
ShowToc = "true"
+++

# Format JSON on The CLI Easily

`python -m json.tool <file>`

This can then be chained to overwrite an existing file, effectively
formatting it.

`python -m json.tool <file> | tee /tmp/file.json && cat /tmp/file.json > <file>`

This gives the command multiple out's without breaking the originating file.
Probably a far better way but this works.

`jq` would work but it isn't installed on remote Unix systems whereas
`python -m json.tool` always works.

Tags:

    #linux #json

repository: danielmichaels/danielms

repo_name: danielmichaels/danielms


text:
[![Build Status](https://travis-ci.org/ratneshsinghparihar/Node-Data.svg?branch=master)](https://travis-ci.org/ratneshsinghparihar/Node-Data)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1459/badge)](https://bestpractices.coreinfrastructure.org/projects/1459)
[![Dependency Status](https://beta.gemnasium.com/badges/github.com/ratneshsinghparihar/Node-Data.svg)](https://beta.gemnasium.com/projects/github.com/ratneshsinghparihar/Node-Data)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fratneshsinghparihar%2FNode-Data.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fratneshsinghparihar%2FNode-Data?ref=badge_shield)
[![npm version](https://badge.fury.io/js/nodedata.svg)](https://badge.fury.io/js/nodedata)
[![npm version](https://img.shields.io/npm/dw/nodedata.svg)](https://www.npmjs.com/package/nodedata)
[![npm version](https://img.shields.io/npm/dm/nodedata.svg)](https://www.npmjs.com/package/nodedata)
## What is Node-Data <img src="node-data1.png" height="200" width="200">

Node-Data is unique backend framework which provides a generic interface for sql , NoSQL and graph entities and creates generic rest level 3 endpoints along with data repositories .

A node-data user just define a model, provide an specification (sql ,nosql or graph) and node-data provides a API to write generic transaction and queries from  persistent layer .

Node-data automatically create rest end points over models and service written by user.
Node-data allows the relationships (one to one , manyto one etc ) with any kind of model , so essentially it allows a sql entity to have a no-sql document and vice versa . The consistency managed by framework and developers can treat all model as one type.

Node-Data is a Node.js framework to expose rest data on level 3 (metadata and auto discovery).

This framework will allow declarative style (annotations) to handle most of backend concerns (data relations, transactions, rest, graphql , security) .Yes its on javascript .

The target consumers are nodejs based scale projects looking for rewrite/new.

When you write for scale you might missed important aspect which might give you headache if you add the aspect late in your project. Node-Data will have most of aspects required in modern web scale project which can be enabled anytime using only annotations.

Rest level 3 is an amazing protocol allows the autodiscovery of system and application developers can write infrastructure for their code if backend api is level 3.

## What backend concerns will be handled

1. Rest level 3 APIs

2. Model driven system

3. Data repositories(Only interface)

4. Auto rest end point generations from repositories

5. Relations using annotations (onetoone , onetomany , manytoone , manyttomany)

6. Embedded relations support (replication)

7. Transaction and services using annotations

8. DI container

9. Caching second level

10.  Search and count (inbuilt elastic search)(repository and query dsl)

11.  Logging and auditing using annotations

12. Graphql support

13.  Meta-data API

14.  Security (inbuilt authentication) ,role based autherization , acl

15. Everythingh is promise (no callback hell)

16. Validation

## Technologies used

library |  version |  Comment/alternative
------------ | ------------- | -------------
nodejs |  5.7.0 | node
express | 4.13.3 | Rest middleware
TypeScript | 1.8.4 | Rest middleware
monogdb | 2.1.3 | Documetndb , nosql , auto sharding
Mongoose | 4.3.5 | ORM for mongoDB
Metadata-reflect | 0.1.3 | For reflection and metadata
gulp | 3.9.0 | Compiling Typscript and Build process
passport | 0.2.2 | Authentication , sso , OAtuh , jwt token
Npm-acl | 0.4.9 | Popular acl library
Elastic search | 10.1.3 | Search and aggregation
Mongosastic | 4.0.2 | Library for integrating Mongoose with ElasticSearch
redis | unknown | Rest middleware

## Quick Start

Assumptions -
1. mongodb is installed and server is running on default port.
2. Node 6.9.0 is installed.

Please follow belos steps to check CRUD operations with nodedata
1. git clone https://github.com/ratneshsinghparihar/nodedata-demo-sample.git
2. cd nodedata-demo-sample/Demo-Sample
3. npm install
4. npm start
5. Post a JSON {"name": "testBlog"} to http://localhost:9999/data/blogs
6. Hit the api to get data(http://localhost:9999/data/blogs)
7. Hit the api with put method http://localhost:9999/data/blogs/{{blogId}}  with body {"name": "testBlog1"}
8. Hit the api with delete method http://localhost:9999/data/blogs/{{blogId}}

## How To Use with security

Follow the below steps to start using the framework.

1. Git clone https://github.com/hariadk/demo-sample.git

2. cd demo-sample/Demo-Sample

## Create a new user
1. POST {
"user":{"name":"a111","password":"a"}
}
in http://localhost:9999/register.
This will create a new user in db.

2. Now we can use this user information to login, for both session based and token based authentication

3. If we need to change the logic for user creation, change the method getNewUser in current-user-detail-service.ts file.Sample code is in place.

For using session based authentication use below steps:

1. Do above steps 1 & 2

2. Checkout branch PasswordAuth

3. npm install

4. tsd install

5. Mongodb running on 27017(default port).

6. Post a JSON {"name":"john","":"john"} to http://localhost:9999/data/users. This will create a test user in db.

7. open cmd, run 'gulp compile-ts' then run gulp.

8. Hit http://localhost:9999 which will take you to login page.

9. use john as username and password, and a session will be created.

For using Token based auth use below steps

1. All the steps done above except checkout branch TokenAuth.

2. Once logged in , a token will be created.

3. To change the token expiring time, change the file security-config.ts.
 public static tokenExpiresInMinutes: number = 2;//2 minutes

4. The number indicates minutes of token expiry not hours.

## Rest level 3 APIs

Node-data exposes the entities as level 3 REST APIs in HAL format.
Read more about:
[HAL specification] (http://stateless.co/hal_specification.html)

[Rest API levels] (http://martinfowler.com/articles/richardsonMaturityModel.html)

In short, REST level 3 in addition to HTTP verbs(get, put, post etc.) introduces the concept of discoverability.
When we navigate to the base-url(assuming base-url for API is "http://localhost:8080/data/") for API, we get all the exposed rest APIs in the system.
```json
[
  {
   "roles": "http://localhost:8080/data/roles"
  },
  {
   "users": "http://localhost:8080/data/users"
  }
]
```

### Suppose we want to get all the users in the system, we go to: "http://localhost:8080/data/users".
```json
{
  "_links": {
   "self": {
    "href": "http://localhost:8080/data/users"
   },
   "search": {
    "href": "http://localhost:8080/data/users/search"
   },
   "action": {
    "href": "http://localhost:8080/data/users/action"
   }
  },
  "_embedded": [
   {
    "_id": "56d692a24043588c0c713564",
    "email"<EMAIL_ADDRESS>
    "name": "Alex Brown",
    "_links": {
     "self": {
      "href": "http://localhost:8080/data/users/56d692a24043588c0c713564"
     },
     "roles":{
      "href": "http://localhost:8080/data/users/56d692a24043588c0c713564/roles"
     }
    }
   },
   {
    "_id": "56d692be4043588c0c713565",
    "email"<EMAIL_ADDRESS>
    "name": "Daniel Jones",
    "_links": {
     "self": {
      "href": "http://localhost:8080/data/users/56d692be4043588c0c713565"
     },
     "roles":{
      "href": "http://localhost:8080/data/users/56d692be4043588c0c713565/roles"
     }
    }
   }
  ]
}
```

If we want to fetch all the roles for any user, we can simply fetch the roles url from inside the "_links" object for the given user. We just need to know what the base URL is, and after that we just follow the links to get any entity, its relations and so on.

## Model driven system

A model driven system allow one to build a solid backend by defining model . Convention approach enables developers to define specification on models and those specifications can be execute by framework or implemented by developer it self .

```typescript
@document({ name: 'students', strict: Strict.true })
export class StudentModel {
    @field({ primary: true, autogenerated: true })
    _id: Types.ObjectId;

    @field()
    name: string;

    @field()
    age: number;

    @field()
    gender: string;

    @onetomany({ rel: 'courses', itemType: CourseModel, embedded: true })
    course: CourseModel.CourseModel;
    }
```
Here the Student Model has attribute is decorated with document with name student which will tell the system to persist each Student Model as a document with name student and schema will be restricted.

@Field will provide the specification for fields in model like primarykey , string field etc. @oneToMany annotation will build a embedded relation with couseModel in the system.

## Data repositories (Only interface)

Data repository exposes the basic CRUD operations for a defined model which can be used anywhere in application whether services or controllers. It also allows rest path definition and  authorization settings using attributes. The framework will automatically create the implementation of the interface which can be overridden by developer if required.

```typescript
@repository({ path: 'blogs', model: BlogModel })
export interface BlogRepository extends dataRepository {
	findByName();
    doPublish();
}
```
Here the basic CRUD operations (findone , finadall , save , saveall , delete,page) will be provided by dataRepository. custom methods can be define here and will be immplemented in services.

## Unit of work
Once a model and its repository is ready , following code can be written
```typescript
 let newCity = new city();
 newCity.name = name;
 newCity.post().then((sucess) => resolved(sucess));
 newCity.put().then((sucess) => resolved(sucess));
```

## Auto rest end point generations from repositories

Once the repository interface defined the framework will automatically generates the rest point . In otherward as a developer you don't need to create the controllers.

like for above BlogRepository the framework will generate and handle following automatically

```html
findOne
Get http://localhost:8080/data/blogs/1/
findAll
Get http://localhost:8080/data/blogs/
create
Post http://localhost:8080/data/blogs/
update
Put http://localhost:8080/data/blogs/1/
delete
Delete http://localhost:8080/data/blogs/1/

```

for Custom methods the framework will generate and handle url like

```html
http://localhost:8080/data/blogs/search/findByName?name=testblog
http://localhost:8080/data/blogs/searchAll?name=testblog
http://localhost:8080/data/blogs/action/doPublish/
```

If custom logic need to be added or entire repository action (like save) need to overridden then a service can be created for the custom logic and service method invocation can be done by defining in attribute over the respective repository's method like below (here we want to do logging after the save)

 ```typescript
@PostAuthorize("@currentUserAutherizationServiceImpl.logSavedEntity(principal, returnObject)")
<S extends T> S save(S entity);
```

## Relations using annotations (one to one , onetomany , manytoone , manyttomany)

Relations between models can be established by adding following declarations. To explain we will be using following entities.

  ```typescript
@document({ name: 'subjects', strict: Strict.true })
class SubjectModel {
    @field()
    name: string;
}

@document({ name: 'students', strict: Strict.true })
class StudentModel {
    @field()
    name: string;
}

@document({ name: 'teachers', strict: Strict.true })
class TeacherModel {
    @field()
    name: string;
}
```

### OneToMany
One-to-many refers to the relationship between two entities A and B in which an element of A may be linked to many elements of B, but a member of B is linked to only one element of A.

For instance, think of A as mentor, and B as student. A mentor can have several students, but a student can have only one mentor. Following code snippet establish this relation on Teacher entity.
 ```typescript
@document({ name: 'teachers', strict: Strict.true })
class TeacherModel {
    @field()
    name: string;
    @onetomany({ rel: 'students', itemType: StudentModel, embedded: false })
    mentoring: Array<StudentModel>;
}
```

We have different keywords while declaring the relation. These keywords are used in all the declaration. They are explained as below:
Name
Description
Rel
Set document name to which this property is mapped to
itemType
Set Entity type to which property is mapped to
embedded
Set to true will embed whole document as property value otherwise only primary key will be set as property value

### ManyToOne
Many-to-one is vice-versa implementation of one-to-many relation. It’s just that entity is present on other end.
We will use example from OneToMany example and add that relation on Student entity.
 ```typescript
@document({ name: 'students', strict: Strict.true })
class StudentModel {
    @field()
    name: string;
    @manytoone({ rel: 'students', itemType: TeacherModel, embedded: false })
    mentor: TeacherModel;
}
```

### OneToOne
One-to-one refers to the relationship between two entities A and B in which one element of A may only be linked to one element of B, and vice versa.
For instance, think of A as teacher, and B as subject. A teacher has only one subject, and a subject is taught by only one teacher. Following code snippet establish this relation on Teacher entity.
 ```typescript
@document({ name: 'teachers', strict: Strict.true })
class TeacherModel {
    @field()
    name: string;
    @onetoone({ rel: 'subjects', itemType: SubjectModel, embedded: false })
    subject: SubjectModel;
}
```

### ManyToMany
Many-to-many refers to the relationship between two entities A and B in which A may contain a parent record for which there are many children in B and vice versa.
For instance, think of A as Student, and B as Subject. A student can have several subjects, and a subject can be taken by several students. Following code snippet establish this relation on Student entity.
 ```typescript
@document({ name: 'students', strict: Strict.true })
class StudentModel {
    @field()
    name: string;
    @manytomany({ rel: 'subjects', itemType: SubjectModel, embedded: false })
    subjects: Array<SubjectModel>;
}
```

## Embedded relations support (*replication*)
A relation can be saved two ways:
1. Link to the related document
2. Embed the related document
Embedding document helps to get the object and relational data using single query from database thus reducing the database/server hits. This behaviour is managed by using ‘embedded’ keyword. When set to true, it fetches the document and embed whole document into the property. In this case, document is replicated and managed by the system. All the embedded document’s update/delete will automatically update the parent document.

*For embedded, please make sure that there is no circular embedding into the system. Although system checks for any circular embedding of the object and throws error.*

Transaction and services using annotations - (Not Yet Implemented)
At the moment, transaction is not supported. But eventually, we will support basic transactions using @transactional annotation.
Refer to: [Website] (https://docs.mongodb.org/manual/tutorial/perform-two-phase-commits/) for mongodb transaction.

## DI container

Node-data implements a light-weight annotation driven dependency-injection container. All the services(@service) and repositories(@repository) can be injected in other classes. Construction injection (only for services) and property injection are supported currently. To inject the dependency, use the annotation @inject. @inject takes optional "type" parameter. When type cannot be inferred from the usage (interface or other types), we can pass the "concrete" type as a parameter to inject.
Currently, we support concrete types only. If anyone wants to use interfaces, check out [Website] (http://inversify.io/) for more.

*Usage*
 ```typescript
@service({singleton: true})
class MyService{
...
}
```
*Inject dependency in another service(constructor and property)*
 ```typescript
@service()
class MyAnotherService{
@inject()
private myServiceAsProp: MyService;

// constructor injection
constructor(@inject() myService: MyService){
}
}
```

*Inject dependency in any another class(only property injection as of now)*
 ```typescript
class MyNormalClass {
@inject()
private myService: MyService;
@inject()
private myAnotherService: MyAnotherService;
}
```

## Caching second level
The proposal for caching is like below
```typescript
@document({ name: 'courses', strict: Strict.throw })
@cache({expirtion: Policy.Update ,concurrencyStrategy:Strategy.Read_Write })
export class CourseModel {
    @field({ primary: true, autogenerated: true })
    _id: Types.ObjectId;

    @field()
    name: String;

    @onetomany({ rel: 'teachers', biDirectional: true})
    @cache
    teachers: Array<TM.TeacherModel>;

    @manytomany({rel: 'students', biDirectional: false})
    students: Array<SM.StudentModel>;
}
```
In above example the courses in the system will be cached as per policy and concurrency defined . if you look for teachers for a course that will be served by the cache but if you look for students for a course that will come from persitent in lazy loading manner.

The choice for Caching (Redis , memcahed ,local) and its setting can be define in config.ts file.

## Search and count (inbuilt elastic search)(repository and query dsl)

### Searching
Searching is done on MongoDB by default.
Provision is made to search using elasticsearch by changing the settings in the Config file.
Search on elasticsearch is currently done only on fields that are indexed in the elasticsearch.
All the search methods are needed to be exposed on the Repository.
Currently only the "And" search operations are supported.

Search on all documents can done using following

http://localhost:999/data/repository_name/searchAll?limit=10& skip=10&sort=fieldname&order=desc&gt=fieldname&gt_value=1510823040

limit= for top or bottom no of records
skip= no of dcouments to skip

sort= field upon which sorting needs to be done
order= ascending ot descending

lt=fieldname for less than comparision
lt-value=value-to-be-compared

gt=fieldname for greater than comparision
gt-value=value-to-be-compared (Number)

lte=fieldname for less than equal comparision
lte-value=value-to-be-compared (Number)

gte=fieldname for greater than comparision
gte-value=value-to-be-compared (Number)

### Configuring ElasticSearch:

### Installation:
Elastic search can be installed from https://www.elastic.co/
### Config Class:
Set "ApplyElasticSearch" to true to enable ElasticSearch
Set the path of the ElasticSearch service at "ElasticSearchConnection"

### Model Class:
For all the fields where the ElasticSearch indexing is requried, set the property in "@field" as "searchIndex:true"
e.g. As in the "name" and "age" properties, the searchIndex is set to true.
 ```typescript
class PersonModel {
    @field({searchIndex : true})
    name: string;

    @field()
    lastname: string;

    @field({searchIndex : true})
    age: number;

    constructor(){
    }
}
```

### Configuring Search:
All the search methods are defined at the Repository classes.
Currently the methods are needed to be defined in a fixed format.
The method name should start with "findBy".
It should then be followed by all the fields that are needed to be searched joined by "And"

e.g.
 ```typescript
class PersonRepository {
    findByName() {
    }
    findByNameAndAge() {
    }
    findByNameAndLastname(){
    }
}
```

### How the search happens:

The API's are defined in such a way that if ALL of the fields to be searched are indexed, then the data is fetched from ElasticSearch.
If any one the fields to be searched is NOT indexed in ElasticSearch, the data is fetched from MongoDB.
Let us consider the above mentioned "PersonModel" and "PersonRepository"
The methods "findByName" and "findByNameAndAge", queries using the fields "name" and "age". Since they are defined as Indexed, the data will be fetched from ElasticSearch.
The method "findByNameAndLastname", queries "name" and "lastname". Since "lastname" is not defined as indexed, the data will be fetched from MongoDB.

## Logging

It will be completely on developers hand , The framework will allow the metadata of a class , method with logging attribute to be accessible to developers.
User can also inject the logger using DI.
 ```typescript
class Calculator{
	@log
    add(a: number, b: number){
    	return a + b;
    }
}
```

## Auditing
The proposal for Auditing is @Audit attribute which can be applied over model or over repository or in both.
```typescript
@Audit({auditModel: CourseAuditModel})
export class CourseModel {
}
```
If appllied over model then developer needs to create a audit schema model similar to current model , remove any non auditable field and add audit fields (createdby, lastmodifiedby, deletedby, createddate, lastmodifieddatae) (or extend from). then this new audit schema model need to be passed as a parameter in attribute. If no schmea is provided then framework will autmatically create audit schema including all columns.

```typescript
@repository({ path: 'blogs', model: BlogModel })
export interface BlogRepository extends dataRepository {
    @Audit
	save();
}
```
If appllied over repository then all write opertation will be audited in a dedicated document for the model.

## Optimistic Locking
The docuement databases are infamous for concurrent updates . in high concurrency the situation multifolds itself. we are proposing a simple mechanism of optimatic locking by decorating the suspected method on repository by
You need to add version property in your model like below
```typescript
@jsonignore()
    @field()
    __v: any;
```
Once above field is added in model then you can apply optimistic locking in below way on repository methods like put,patch etc ..
First Developer need to import below mentioned decorator and constant file.

```typescript
import { OptimisticLocking } from "nodedata/core/decorators/optimisticlocking";
import { OptimisticLockType } from "nodedata/core/enums/optimisticlock-type";
```
Apply optimistic locking in below way.

```typescript
@OptimisticLocking(type = OptimisticLockType.VERSION)
put()
```

in other to support it the corresponding model should have a column decorated with @version attribute
```typescript
@Version
@JsonIgnore
@field(name = "version")
version: int;
```
@version attribute could be applied to int , date fields. Once this is done , for every write query the version check will be apllied hence if somone has stale data it won't be allowed to write.

## Graphql support
For Graphql, atrribute over the  Model will enable the graph queries to be executed.like
```typescript
@document({ name: 'users', strict: Strict.true })
@Graphql
class UserModel {
    @field()
    name: string;
    @manytomany({ rel: 'friends', itemType: FreindModel, embedded: true })
    friends: Array<FriendModel>;
}
```
Once define like above the framework will automatically add GraphqlObjectType and GraphqlSchema.

Example GraphQL query (request body for post on /user/grpahql/):
```javascript
user(id: "1") {
  name
  friends {
    name
  }
}
```
Example response:
```json
{
  "data": {
    "user": {
      "name": "John Doe",
      "friends": [
        {
          "name": "Friend One"
        },
        {
          "name": "Friend Two"
        }]
      }
    }
  }
  ```
Example GraphQL mutation:
```javascript
mutation updateUser($userId: String! $name: String!) {
  updateUser(id: $userId name: $name) {
    name
  }
}
```
## Meta-data API

Metadata gives the structure of the object. The structure consists of the properties defined in the entities.

For e.g. ‘http://localhost/metadata’ will return all the objects metadata :
```json
{
  "_links": [
    {
      "name": "subjects",
      "metadata": "http://localhost/Metadata/subjects"
    },
    {
      "name": "students",
      "metadata": "http://localhost/Metadata/students"
    },
    {
      "name": "teachers",
      "metadata": "http://localhost/Metadata/teachers"
    }
  ]
}
```
Further running ‘http://localhost/Metadata/students’ will give:
```json
{
  "id": "students",
  "properties": [
    {
      "name": "name",
      "type": "String"
    },
    {
      "name": "subjects",
      "type": [
        "http://localhost/Metadata/subjects"
      ]
    }
  ]
}
```
For primitive types, name of the type is shown.  If the entity has a relationship with another entity then the link of that object's metadata is shown.

## Security (inbuilt authentication) ,role based autherization , acl

### System has two types of inbuilt authentication:
1. *Session based*
2. *Token based*

### Session based
It takes the username and password from a user, validates it against the user document in the mongodb. If user is found it creates a session for it.
To use this a user needs to edit the config.ts file.
```typescript
export class Security {
    public static isAutheticationEnabled: boolean = true;
    public static isAuthorizationEnabled: boolean = false;
    public static isAutheticationByUserPasswd: boolean = true;
    public static isAutheticationByToken: boolean = false;
}
```
Both isAutheticationEnabled  and isAutheticationByUserPasswd should be set to TRUE.
isAutheticationByUserPasswd  and  isAutheticationByToken are mutually exclusive.

### Token Based
It takes the username and password from a user, validates it against the user document in the mongodb. If user is found it creates a token and a refreshToken for that user, and stores in user document itself. Session is not created in this case.
The token expiry time can be set in security-config.ts file.
 ```typescript
public static tokenExpiresInMinutes: number = 2;//2 minutes.
```
The token is set in the cookies and sent to the browser.Using that token, user is considered valid, and provided access to the system.
Once the token is expired, user can just hit the /token API with refreshToken as the query param. RefreshToken value can be found in the browser cookies. This API will generate a new token for the user, and replace the old token in the user document in the DB, as well as in the cookies. Using the new token user can access the system again, without having to login again and again.

To enable token based authentication just edit the config.ts file in following manner
```typescript
export class Security {
    public static isAutheticationEnabled: boolean = true;
    public static isAuthorizationEnabled: boolean = false;
    public static isAutheticationByUserPasswd: boolean = false;
    public static isAutheticationByToken: boolean = true;
}
```
Currently any user who is AUTHENTICATED, has access to the entire DB. This is because, AUTHORIZATION is not implemented. In the absence of authorization, the user has access to every document in the db.

### FaceBook Authentication(SSO)

Facebook authentication uses facebook to authenticate a user. If the user is present in the db, it stores the token in the user document and creates a session for the user in the application. In case its a new user, it first creates the user in the DB and then creates a session for the user in the application.
To enable it the only thing needs to be done is in the config.ts file.
```typescript
export class Security {
    public static isAutheticationEnabled: boolean = true;
    public static isAuthorizationEnabled: boolean = false;
    public static isAutheticationByUserPasswd: boolean = true;
    public static isAutheticationByToken: boolean = false;
}
```

## Everything is promise (*no callback hell*)
Callback-Hell in nodejs occurs when we have multiple levels of callbacks(as shown in the sample below). This severely affects readablitly of the code. Node-data internally uses [Q](https://github.com/kriskowal/q/wiki/API-Reference) to wrap the function calls and returns a promise. Using Promise chains flattens the pyramid and the code is cleaner.
 ```typescript
 return Q.nbind(this.find, this)(params)
        .then(result => doSomething(params1))
        .then(result => doSomethingElse(params2))
        ...
        .catch(error => Q.reject(error))
 ```
Instead of (Callback hell):
```typescript
this.find(params, (error, data) => {
	doSomething(params1, (error, data) => {
		doSomethingElse(params2, (error, data) => {
			...
		});
	});
})
```

## Validation
Proposal is to create a validation service where annotations will be used to validate required attributes in any entity.

For example check below code fragment

```typescript
class UserModel {

    @field()
    @NotNull() // to ensure that this attribute is never null
    name: string;

    @field()
    @number() // to ensure that this attribute is integer
    age: number;

    @field()
    @email() // to ensure that this attribute is in mail format
    email: string;

    @field()
    @length(10) // to ensure that this attribute is not having more than 10 char, and all char are numbers
    mobileNumber: string;

    @field()
    @min(10)
    @max(20)// to ensure that this attribute is not more than 20 and not less than 10
    count: number;
}
```

The user will have freedom to choose the entity attribute to be validated before save or update.

## statistics/count API
Further running ‘http://localhost/statistics/students’ will give:
```json
{
  "id": "students",
  "properties": [
    {
      "name": "count",
      "type": "number",
      "value":15
    }
  ]
}
```
Further running ‘http://localhost/statistics/’ will give:
```json
[{
  "id": "students",
  "properties": [
    {
      "name": "count",
      "type": "number",
      "value":15
    }
  ]
},
{
  "id": "teachers",
  "properties": [
    {
      "name": "count",
      "type": "number",
      "value":5
    }
  ]
},
]
```
where condition is supported

## Diffrence between waterline and Node-Data
The waterline is a greate opensource porject and has been an inspiration for us but there is a big difference between Node-data and waterline . The Node-Data is not an another ORM , its a wrapper over famous ORMs like(mongoose , seqlize , neo4j) . Node-Data provides an abstraction over these famous ORMs so that Developer don't have to deal with them individually and they can write models and transaction over these ORMs with same codebase.

## pure js project supported
Node-data now is fully supported inside a normal js project , no typescript dependency (check BMMaster branch for template)

## bulk and performance improvements
## Entity Manager
Entity action manager will help you to write your business logic codes in a controlled environment. By controlled environment we mean that developer should have the control on before and after of any transcation to the system. Let take an example for our better understanding.

Suppose we are doing a transcation to add a new student in the system and we are maintaing a total count of students in the class. So in this case, we would have written a code to update total student count after creating a new student.
```
function addAndUpdate(){
  studentRepo.post(newStudentObj).then(success => {
	 // update total students cont in school
     classRepo.put({_id: "5a24fc4d485fcd66084863e2", totalStudentCount: curTotalStudentCount + 1});
   });
}
```
So problem with this code is we have to call addAndUpdate() method manually to work correctly. But imagine a new developer came and created a new student by simply calling studentRepo.post(newStudentObj); and he might forget/(dont know) to update the total student count in class.

In this scenario Entity Manager will make sure that a common business functionality should always execute on a transcation by overriding its postCreate() method. postCreate() method will always execute after any create (post) on the system.

```
postCreate(params: EntityActionParam){
	classRepo.put({_id: "5a24fc4d485fcd66084863e2", totalStudentCount: curTotalStudentCount + 1});
    return super.postUpdate(params);
}
```

How to enable Entity Manager feature in your project:
1. extend/inherit your repository class from AuthorizationRepository and override the entity action methods
Entity Action methods:-
preUpdate

postUpdate

preBulkUpdate

postBulkUpdate

preRead

postRead

preBulkRead

postBulkRead

```typescript
preUpdate(params: EntityActionParam): Q.Promise<EntityActionParam> {
        return Q.resolve(params);
    }

postUpdate(params: EntityActionParam): Q.Promise<EntityActionParam> {
        return Q.when(params);
    }
export interface EntityActionParam {
    inputEntity?: any;
    oldPersistentEntity?: any;
    newPersistentEntity?: any
}
```
## Transaction
   no transaction on documents(@document) side , @transaction is supported on sql entities(@entity) repositories
   if calling a document transaction within a method with @transaction , it will not rollback and developer need to handle this.
## process control
```typescript
    @processStartEnd({ action: "importLead", type: "project", indexofArgumentForTargetObjectId: 1 })
    public read(filePath: string, projectId, toDelete?) {
    }
```
## Workers and Async Api
```typescript
    @worker()
    public read(filePath: string, projectId, toDelete?) {
    }
```
quick response with
```json
{
  "id": "3423423",
  "processName":"",
  "status":"inprogress"
  "subscriptionProperties": [
    {
      "channel_id": "3423",
      "type": "pushnotification",
      "event_id":15,
      "action_id":16
    },
     {
      "url":"http://localhost:8080/data/process/3dfgs3/",
      "token":"324324fsdfs32rfsd",
      "type": "rest",
      "metadata":{}
    }
  ]
}
```

## upload files into server
```
@upload({destination:"../report-all/"})
    douploadreport(filePath) {
        var path = filePath[0].path;
        console.log("report uploaded successfully for " + path);
    }
```

## PUB-SUB using Messageing
to define a repository to act like an pub-sub
```typescript
@repository({ path: 'workerprocess', model: WorkerProcess, exportType: ExportTypes.PUB_SUB})
export class WorkerRepository extends DynamicRepository {}
```
This will use a database queue (persistent) for the repository and on evey transaction it will emit the messages to whoever is connected to database.

This pub-sub is reliable and persistent (not like pusher,redis pub-sub).

To consume the message create a onMessage method on repo , insise this method you can receive all output to repo.
```typescript
export class WorkerRepository extends DynamicRepository {
     public onMessage(message: WorkerProcess) {
        if (message.status == "connected") {
            this.wps.addWorker(message);
        }
        if (message.status == "disconnected") {
            this.wps.deleteWorker(message);
        }
    }
}
```
In cases where high write operations are expected a dedicated queue might required for that set
edicatedMessenger:true
```typescript
@repository({ path: 'workerprocess', model: WorkerProcess, exportType: ExportTypes.PUB_SUB, dedicatedMessenger:true})
export class WorkerRepository extends DynamicRepository {
}
```

## RealTime server using websockets
Node-Data supports real time communication to server using websockets.
first step is to tell server.js/app.js to create a socket server like below .
passing httpserver(express server or node native http server) (server like below) object in Main will turn the current http-server into socket server.
```typescript
Main(Config, securityConfig, __dirname, data.entityServiceInst, seqData.sequelizeService,server);
```
next is to tell a repository to expose websocket end point
```typescript
@repository({ path: 'workerprocess', model: WorkerProcess, exportType: ExportTypes.WS})
export class WorkerRepository extends DynamicRepository {}
```
If you need websocket and rest both on repo use it like below
```typescript
@repository({ path: 'workerprocess', model: WorkerProcess, exportType: ExportTypes.WS | ExportTypes.REST})
export class WorkerRepository extends DynamicRepository {}
```
Now just like rest end points from client side messages can be received and emitt real time using socket.io-client library (socket server will be hosted on web server  ws://localhost:8080 )

if repo is WS then every changes in the repo will be send to connected clients automatically.
security and acl will applied obiviously before sending.

## websockets security client side changes
All security reules applied to rest api are still applicable for webscoket apis
for authentication/autherization client need to send information like below
```typescript
const socket = io('ws://localhost:8080',
    {transports: ['websocket', 'polling'],
    query: {
            name: "ui-test", netsessionid: "abc123", email<EMAIL_ADDRESS>phone: "+918600147266"
        }
});

```
if succeded then server will establise an uws session with client, client need to tell upfornt which channels (aka repo path) he want to listen
```typescript
const socket = io('ws://localhost:8080',
    {transports: ['websocket', 'polling'],
    query: {
            name: "ui-test", netsessionid: "public", email<EMAIL_ADDRESS>phone: "+918600147266",
			channels:"workerprocess,order"
        }
});

socketio.on('workerprocess', function (data) {

        console.log("workerprocess message received-->", data);
    });

```
in order to send the messages back to server , action is repo's action ,heders will have security session token, message will have request body
```typescript
 socket.emit('order', {
                action: 'bulkPost',
                headers: { netsessionid: 'abc123' },
                message: [{ }]
            });
```
## websockets security for microservices and workers
other microservices and workers in ecosystem can also use  mechnism to client to send and receve messages,
for realiable messaging (like server restart or worker restart , pending messages should recieve again
```typescript
const socket = io('ws://localhost:8080',
    {transports: ['websocket', 'polling'],
    query: {
            name: "ui-test", netsessionid: "public", email<EMAIL_ADDRESS>phone: "+918600147266",
			reliableChannles:"workerprocess,payment"
        }
});
```
## websockets security server side changes
security config file is responsible for telling the consumers what they can listen and what they can emit.

"acl": true will run acl code for each messages before sending to connected clients.

"acl": false will broadcast to all connected client under the role.

if there are multiple instance of worker(realiable channel) and only one should get message following settings helps
"emitToSingleWorker": true
```typescript
export class SecurityConfig {

    public static ResourceAccess: Array<IResourceAccess> = [
        {
            name: "worker",
            acl: [
                {
                    "role": "ROLE_USER",
                    "accessmask": 5,
                    "acl": true
                },
                {
                    "role": "ROLE_PUBLIC",
                    "accessmask": 1,
                    "acl": false
                },
                {
                    "role": "ROLE_WORKER",
                    "accessmask": 15,
                    "acl": false,
                  	"emitToSingleWorker": true
                }
            ],
            isRepoAuthorize: true
        }
      }
```
## why node-data coulde be a best fit for your next no-sql design
no-sql designs are continous process and node-data has been design to help developers to build right no-sql design and allow them to easily refactor the current modeling to next design . In most of the cases data migration don't create bottleneck on design changes , its the transaction code which stop the developer to rewrite them again , here node-data helps developers to refactor the code easily and allow them to build new experinces out of existing experinces with out so many breaking changes.

for online support use gitter
https://gitter.im/node-data/node-data-support

for raising a ticket use jira
[JIRA URL] (https://node-data.atlassian.net/secure/RapidBoard.jspa?rapidView=2&view=detail)

## Our sponsers
<a href="https://www.taletnica.com"><img src="https://raw.githubusercontent.com/ratneshsinghparihar/Node-Data/master/images/talentica.png" width="200"></a>
<img src="https://raw.githubusercontent.com/ratneshsinghparihar/Node-Data/master/images/atlassian.png" width="200">
<a href="https://www.browserstack.com"><img src="https://raw.githubusercontent.com/ratneshsinghparihar/Node-Data/master/images/browserstack-logo-600x315.png" width="200"></a>

repository: igorjs/Node-Data

repo_name: igorjs/Node-Data


text:
# bitbucket_snagger
Snag public git repos from the internet and upload them to your private bitbucket server

# Credentials
* username, password and base_url are stored in a file at `~/.bitbucket_snagger.ini` and cannot be passed on the command line
* For an example file, see https://github.com/GeoffWilliams/bitbucket_snagger/tree/master/doc/.bitbucket_snagger.ini
* The permissions on `~/.bitbucket_snagger.ini` must be `0600`
* You can remove credentials with the logout command when you are finished

# Logging out
```shell
bundle exec bitbucket_snagger logout
```

# Creating and uploading a single git repo to bitbucket

* `--projectKey` is the 3 letter `projectKey`, eg `pup`
* `--repositorySlug` is the repository to upload to within the project, eg `apache`
* `--upstream` is the upstream repository to merge changes from
* `--verbosity` sets debug mode (optional)
* `snag` is the command to run (always `snag` to update)

```shell
bundle exec bitbucket_snagger \
  --projectKey pup \
  --repositorySlug apache \
  --upstream https://github.com/puppetlabs/puppetlabs-apache \
  --verbosity debug \
  snag
```

# Creating and updating lots of repos in bitbucket
Just make yourself a handy bash script, like this:

```script
#!/bin/bash
cmd="bitbucket_snagger --projectKey pup"
$cmd --repositorySlug accounts --upstream https://github.com/puppetlabs/puppetlabs-accounts snag
$cmd --repositorySlug apache --upstream https://github.com/puppetlabs/puppetlabs-apache snag
$cmd --repositorySlug concat --upstream https://github.com/puppetlabs/puppetlabs-concat snag
$cmd --repositorySlug firewall --upstream https://github.com/puppetlabs/puppetlabs-firewall snag
$cmd --repositorySlug git --upstream https://github.com/puppetlabs/puppetlabs-git snag
$cmd --repositorySlug haproxy --upstream https://github.com/puppetlabs/puppetlabs-haproxy snag
$cmd --repositorySlug inifile --upstream https://github.com/puppetlabs/puppetlabs-inifile snag
$cmd --repositorySlug java --upstream https://github.com/puppetlabs/puppetlabs-java snag
$cmd --repositorySlug java_ks --upstream https://github.com/puppetlabs/puppetlabs-java_ks snag
$cmd --repositorySlug motd --upstream https://github.com/puppetlabs/puppetlabs-motd snag
$cmd --repositorySlug mysql --upstream https://github.com/puppetlabs/puppetlabs-mysql snag
$cmd --repositorySlug noop --upstream https://github.com/trlinkin/trlinkin-noop snag
$cmd --repositorySlug nsswitch --upstream https://github.com/trlinkin/puppet-nsswitch snag
$cmd --repositorySlug ntp --upstream https://github.com/puppetlabs/puppetlabs-ntp snag
$cmd --repositorySlug postgresql --upstream https://github.com/puppetlabs/puppetlabs-postgresql snag
$cmd --repositorySlug puppet_agent --upstream https://github.com/puppetlabs/puppetlabs-puppet_agent snag
$cmd --repositorySlug ssh --upstream https://github.com/saz/puppet-ssh snag
$cmd --repositorySlug staging --upstream https://github.com/voxpupuli/puppet-staging snag
$cmd --repositorySlug stdlib --upstream https://github.com/puppetlabs/puppetlabs-stdlib snag
$cmd --repositorySlug sudo --upstream https://github.com/saz/puppet-sudo snag
$cmd --repositorySlug tagmail --upstream https://github.com/puppetlabs/puppetlabs-tagmail snag
$cmd --repositorySlug tomcat --upstream https://github.com/puppetlabs/puppetlabs-tomcat snag
$cmd --repositorySlug vcsrepo --upstream https://github.com/puppetlabs/puppetlabs-vcsrepo snag
```
Making this prettier is left as an exercise for the reader

## Notes
* Attempting to access insecure `http` repositories will work but will output a warning message


text:
_     _              _                     ___    ___
    | |   | |            | |                   / __)  / __)
    | |__ | | _____  ____| |  _     ____ ___ _| |__ _| |__ _____ _____
    |  _ \| |(____ |/ ___) |_/ )   / ___) _ (_   __|_   __) ___ | ___ |
    | |_) ) |/ ___ ( (___|  _ (   ( (__| |_| || |    | |  | ____| ____|
    |____/ \_)_____|\____)_| \_)   \____)___/ |_|    |_|  |_____)_____)

What's this?
============

BlackCoffee is a CoffeeScript dialect that adds hygienic macros (also known as black magic, hence the name). We aim for inclusion of this exension into mainline CoffeeScript.

Applications include:
- compile-time calculations,
- file inclusion,
- conditional compilation,
- i18n translation,
- html resource versioning,
- syntactic sugar,
- and whatever else you can think of doing at compile-time.

Besides macros, BlackCoffee sneaks one additional feature in CoffeeScript: Coco-like `!->` and `!=>` procedures. Prefixing an exclamation mark to the function operator, causes the function not to do an implicit return of the last expression.

Installation and usage
======================

You can obtain BlackCoffee through npm:
```sh
npm install blackcoffee
```

..or clone the repository:
```sh
git clone https://github.com/paiq/blackcoffee
```

In both cases you'll have a local installation, assuming you don't want to replace your regular CoffeeScript compiler. You'll find the main compiler executable here `blackcoffee/bin/coffee` or here `node\_modules/blackcoffee/bin/coffee`.

The compiler can be used in the exact same way as the regular CoffeeScript compiler (except that macros are supported, of course). In addition, BlackCoffee comes with its own very simple CLI named `blackcoffee`, which supports multiple source files and command line flags that can be used by macros. Read the 'blackcoffee cli' section for more info.

To install blackcoffee system-wide, *replacing any already installed CoffeeScript version*:
```sh
sudo npm install -g blackcoffee
```

...or:
```sh
git clone https://github.com/paiq/blackcoffee
cd blackcoffee
sudo bin/cake install
```

One-time macro calls
====================

The `macro` keyword can be used in two distinct ways. When it's followed directly by a closure, that closure will be executed at compile time. In case the closure returns a BlackCoffee node (see below) it will replace the original macro-call. Otherwise the macro-call will be removed or replaced by `undefined`.

The compile-time closure calls do not get any arguments. They do get a `this`-object that will be the same for all calls to macro closures, which can safely be used to maintain state. This object is also reachable through `cfg` in the global compile-time namespace.

Examples:
```CoffeeScript
macro ->
	@someStateVar = []
# compiles to nothing, because `[]` is not a BlackCoffee node.

macro ->
	macro.fileToNode "test.coffee"
# `macro.fileToNode` reads a js or coffee file, and returns the BlackCoffee
# node for it. As the macro closure returns a node, it will replace the call.
# So in effect, the file is included.

fileContents = macro ->
	macro.valToNode ''+macro.require('fs').readFileSync 'file.txt'
# `macro.valToNode` converts a json-able value to a BlackCoffee node. So
# `fileContents` will contain whatever is in 'file.txt'. Of course, as we're
# using `require('fs')` this will not work when compiling in the browser.
```

Named macro definitions
=======================

When the `macro` keyword is followed by an identifier and then a closure, it's a definition. Every time the identifier is used as a closure call later on in the program, the closure call is replaced by the result of a compile-time call to the defined macro. Arguments to the macro are passed to the compile-time closure as BlackCoffee nodes.

Examples:
```CoffeeScript
macro macroWithoutArgs -> macro.csToNode '3 * a'
# A named macro is defined here, but no code is generated yet.

z = macroWithoutArgs() + 4
# Here we're actually using the macro. Expands to: `z = 3 * a + 4`.

macro replaceFooWithBar (node) -> node.subst {foo: macro.csToNode 'bar'}
# Here, the macro takes an argument. `subst` is a method that can be used on
# every type of BlackCoffee node, to recursively search and replace
# identifiers with a node.

arr = replaceFooWithBar -> [foo+foo, -> foo]
# Expands to: `arr = [bar+bar, -> bar]`
```

Helper functions
================

We've already seen some examples of helper functions defined in the compile-time `macro.` namespace. Let's go over them one by one:

**macro.valToNode(value)**
Convert a json-able `value` to a node.
```CoffeeScript
buildInfo = macro -> macro.valToNode
	time: new Date().getTime()
	host: macro.require('os').hostname()
```

**macro.csToNode(scriptString)**
Parse a string of BlackCoffee script and return its main node.
```CoffeeScript
macro -> macro.csToNode "x = a+b+(#{process.env.buildMagic})+4"
```

**macro.jsToNode(scriptString)**
Creates a `literal` node, embedding a piece of unprocessed Javascript. As this node just embeds an opaque piece of Javascript, `subst` (see below) will not have any effect on it.
```CoffeeScript
macro -> macro.jsToNode @someFancyToolThatGeneratesJavascript()
```

**macro.fileToNode(filename,language)**
A little wrapper around `csToNode` and `jsToNode` that tries to load `filename` from disk using `fs.readFileSync`. Of course, this won't work when compiling in the browser. If `language` is `'js'` or `'cs'`, that is how the file will be interpreted. If it is not set, `fileToNode` will make a guess based on the file extension.

This helper can be used for file inclusion, though one may want to write a wrapper macro around it, to search in the appropriate path(s) and maybe to dependency tracking and such.

```CoffeeScript
macro -> macro.fileToNode 'includeMe.coffee'
# or
macro include (fn) -> macro.fileToNode @myPathSearcher(fn+'.coffee')
include 'includeMe'
```

**macro.codeToNode(closure)**
Takes a closure (function), and returns its body as a node. So the closure itself is *not* part of the node. Note that `codeToNode` is the only helper function that is not actually a function. It's a predefined macro. It needs to be, because it needs to capture the node of its argument instead of the value.

```CoffeeScript
macro swap (a,b) -> macro.codeToNode(-> [x,y]=[y,x]).subst {x:a, y:b}
swap c, d
```

**macro.nodeToVal(node)**
Try to evaluate the `node` at compile-time and return the value. Any errors (such as referencing run-time variables), will throw at compile-time.

```
# Example for those who long for the bad old C-preprocessor days. ;-)
macro ifdef (key) ->
	key = macro.nodeToVal key
	macro.csToNode(if @defines[key] then "if true" else "if false")
throw 'party' ifdef 'firstBeta'
```

**macro.idToVal(node)**
In case `node` is a bare identifier, return its string value. Return `undefined` otherwise.
```
# Example for those who long for the bad old C-preprocessor days. ;-)
macro ifdef (key) ->
	key = macro.nodeToId key
	macro.csToNode(if @defines[key] then "if true" else "if false")
throw 'party' ifdef firstBeta
```

Working with Nodes
==================

WARNING: Manipulating BlackCoffee nodes directly exposes compiler implementation details. Therefore, documentation is mostly absent and things may change between compiler versions without notice. It is recommended to use these techniques as little as possible.

**macro.[NodeType]**
The compile-time `macro` object provides direct access to BlackCoffee `node` classes. You can use these to test if an argument node has some specific type, or to programatically generate nodes. Node types and their constructor arguments can be found in the compiler sources, in `nodes.coffee`.

```CoffeeScript
macro something (arg) ->
	if arg instanceof macro.Bool
		@someting()
	else
		@somethingElse()
macro debug (args...) ->
	if @debugging
		new macro.Call(new macro.Literal("debugImpl"), args)
```

**macro.walk(node,visitor)**
For each of `node`s (recursive) child nodes, call `visitor(child)`. In case the visitor returns a BlackCoffee node, that node is used to replace the original child. If `false` is returned, the child is removed (or replaced by undefined if it cannot be removed). Otherwise, the original child is left unmodified.

```CoffeeScript
macro delegateArithmetic (func) ->
    operators =
        '+': 'add'
        '-': 'sub'
        '*': 'mult'
    macro.walk func.body, (node) ->
        if node instanceof macro.Op and (op = operators[node.operator])
            macro.csToNode("(a).#{op}(b)").subst {a: node.first, b: node.second}

# Next, we'd have to define the `add/sub/mult` methods for the types that we'll
# be working with in a `delegateArithmetic` section.
Array::add = (other) -> 42 # do something smart here instead
Number::sub = (other) -> -42
# etc...

# So, now this uses regular javascript operators:
eq 7, 3+4
eq "3,45,6", [3,4]+[5,6]

delegateArithmetic ->
    # And this uses the arithmetic methods defined on the prototypes:
    eq [3,4,5], [1,2,3]+2
    eq 20, [1,2,3]*[2,3,4]
    eq [1,0,1], [3,2,4]-[2,0,3]
    eq 9, 3*3
```

blackcoffee cli
===============

This version of CoffeeScript comes with the usual `bin/coffee` compiler/runner/repl, adapted to work with macros. You may choose to use the additional `bin/blackcoffee` compiler instead, as it allows for compilation of multiple source files to one target. This is especially useful if you want to prefix each script with a set of common macro definitions.

Syntax: `bin/blackcoffee [-o OUTFILE_JS] [-m OUTFILE_SRCMAP] [-f KEY[=VAL]]... [--] [INFILE]...`

I think these options are pretty much self evident, except for `-f`, which can be used to set key/values on the `flags` object available in the compile-time context. This allows you to specify any sort of build options in your build script, which you can then use in your macros.

Example:
```sh
bin/blackcoffee -o test.js -m test.srcMap -f dev macros.coffee test.coffee
```
macros.coffee:
```CoffeeScript
macro LOG (str) ->
	macro.codeToNode(->console.log x).subst {x: str} if flags.dev
```
test.coffee:
```CoffeeScript
# We can use macros defined in the other file here. The following will
# compile to nothing, unless the '-f dev' flag is specified at compile time:
LOG "Hello developers!"
```

repository: EmielM/blackcoffee

repo_name: EmielM/blackcoffee


text:
# About

Speed up your [lumen](https://github.com/laravel/lumen) based api development with this boilerplate. At this time it's integrated with [jwt-auth](https://github.com/tymondesigns/jwt-auth) and [lumen-generator](https://github.com/flipboxstudio/lumen-generator).

## Installation

1. Clone this repository and run :
```bash
composer install
```
2. Create .env file and set up your database credential
3. Generate jwt secret key using :
```bash
php artisan jwt:secret
```
4. You are done here

## Usage

If you willing to generate model, migration, controller sure you can get it by executing available command provided by [lumen-generator](https://github.com/flipboxstudio/lumen-generator).

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


text:
# Leak report

The allocation initially starts inside the `strip` function, which was called by `is_clean`,
which itself was called inside a `for` loop inside the `main` function. The allocation
is for storing the string result of `strip` in `cleaned` which is then compared to the
original unstripped string, `str`. `strcmp` is used to compare the two strings,
where the output is stored in `result`.

`cleaned` needs to be freed, but before this can be done we must check if `cleaned`
actually contains data. This is because one of the strings being compared is all spaces.
A simple `strcmp` will do the trick.

gha_language: C