teleren/devto huggingface dataset:
Counting IP Addresses in a Log File
Tags: linux
Published: 2019-10-14 19:30:19

---
title: Counting IP Addresses in a Log File
published: true
date: 2019-10-11 23:00:00 UTC
tags: Linux
canonical_url: https://www.petefreitag.com/item/884.cfm
---

I've been using `grep` to search through files on linux / mac for years, but one flag I didn't use much until recently is the `-o` flag. This tells grep to only output the matched pattern (instead of lines that mach the pattern).

This feature turns out to be pretty handy, lets say you want to find all the IP addresses in a file. You just need to come up with a [regular expression](https://www.petefreitag.com/cheatsheets/regex/) to match an IP, I'll use this: `"[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"` it's not perfect, but it will work.

```
grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" httpd.log
```

**What if I want to see just unique IPs**

We can use the `uniq` command to remove duplicate ip addresses, but `uniq` needs a sorted input. We can do that with the `sort` command, like so:

```
grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" httpd.log | sort | uniq
```

**Show me the number of times each IP shows up in the log**

Now we can use the `-c` flag for `uniq` to display counts:

```
grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" httpd.log | sort | uniq -c
```

This will output something like:

```
    7 10.0.0.30 
    1 10.0.0.80 
    3 10.0.0.70
```

The counts are not in order, so we can pass our results through sort again, this time with the `-n` flag to use a numeric sort.

```
grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" httpd.log | sort | uniq -c | sort -n
```

The above will put them in order from least to greatest, you can pipe the result to `tail` if you only want to see the top N IP addresses!

Pretty handy right?
Azure SQL Server Database Failover Groups 
Tags: azuresqlserver, azuresqlserverdatabase, failovergroups, azure
Published: 2019-10-14 04:52:30

In this [tutorial](https://github.com/patricksameerajayalath/AzureTutorials/blob/master/Azure%20SQL%20Server%20Database%20Failover%20Groups.pdf) I’m going to show how to:

•	Create a Failover Group
•	Testing Failover End Points through SQL Server Management
•	Testing Failover End Points through Command Prompt
•	Make a Failover


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/a9eyozsik5d4lcs2xml1.jpg)


You can find the PDF version of this tutorial [here](https://github.com/patricksameerajayalath/AzureTutorials/blob/master/Azure%20SQL%20Server%20Database%20Failover%20Groups.pdf).

You can find all my Azure/.Net tutorials [here](https://dev.to/patricksameerajayalath) and [here](http://sameerajayalath.blogspot.com/).

Enjoy !!
Overcoming Obstacles
Published: 2019-10-14 04:36:19

            I have overcome many obstacles in my life the first being my 

birth. I was due at the end of September but made my grand entrance into 

the world bright and early on the ninth of July. Weighing in at a mere 

two pounds eight ounces. I spent ninety days in the hospital until I was

strong enough to live outside of an incubator.

           The next obstacle I encountered was moving to four different 

towns and attending six different schools between the years of

kindergarten to my Senior year of high school. I was a shy, awkward only 

child, that struggled after every move to yet again find my place and 

fit in with my peers. After that looking back I feel a lot of the 

 obstacles I faced were due to the choices I made in my life. 

           While still in high school I chose to get pregnant and  

married in that order. By twenty I was divorced and living back at 

home with my parents,and I accidentally burned their house down. My 

parents, my daughter and myself spent the next six weeks sharing a small 

motel room until  they found a new house,in yet again another town. At 

least this time it was a town we had already lived in so I already had 

friends there. I was also employed with Target at the time so I was able 

to transfer from my home store in Oklahoma City to the Norman store. 

From the motel we moved to a small two bedroom apartment in Norman. 

Smart move on my parents nothing will motivate your adult child living 

back at home with her parents to hurry up and move out 

of their home than to have her share a very small bedroom room with her 

with her own one year old child. And reinstate the same rules and curfew 

she had as a teen.

             Finally I got my own apartment with my daughter,was still 

employed with Target and was attending college.Fast forward two years

and I've dropped out of college and I'm married again. 

            Five years later my son is born and it takes me until he is

nne years old before I can obtain a definitive Autism diagnoisis for 

him. While knowing since he was aorund four years old that he had it. 

I never gave up until he had the diagnosis and the needed accomadations

at school to learn mainstream with his peers. 

              My most recent blessing disguied as an obstacle,was coming to 

terms with the fact that I had spent nearly twenty-five years with a

spouse who was abusive,and I had refused to see it or believe it.


          Had I not taken that path for my life I would not have had the 

blessing of Palomar and Ctrl+Shift code school being in my life today.

This is the first time in my life I can remember being excited to learn.

Anxious if I'm not working my coding assignments.Wanting to spend all of 

my time learning all that I can. And even though I'm stll not sure of 

what I'm doing I love every frustrating second of it.
JMeter integration with Selenium using WebDriver sampler
Tags: jmeter, selenium, webdriver, performancetesting
Published: 2019-10-14 04:12:52

Step 1:
Add plugin Selenium/WebDriver Support in JMeter.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/iyubs8c94ivzas9svnsg.png)

Step 2: Create a test plan - add thread group 
Add Config Element - jp@gc - Chrome Driver Config Sampler - jp@gc - Web Driver Sampler and Listener - View Results Tree.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5fdqn20u1zigcsz017dl.png)

Step 3: Download chromedriver.exe and provide the location in Chrome Driver Config as in above screenshot.e.g. -D:\Desktop\drivers\chromedriver.exe

Step 4 : Add scripts in Web Driver Sampler
   e.g:
    WDS.sampleResult.sampleStart()
    WDS.browser.get("https://www.google.com/");
    var searchBox = WDS.browser.findElement(org.openqa.selenium.By.name("q"));
    searchBox.click();
    searchBox.sendKeys('Test');
    searchBox.sendKeys(org.openqa.selenium.Keys.ENTER);
    WDS.sampleResult.sampleEnd()

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/9zcf5eoakvr8l1ypy6jy.png)

Step 5 : Run & Validate

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/mai9ukpmtxpgj79igzg1.png)

Notes:
1. WebDriver Sampler automates the execution and collection of Performance metrics on the Browser (client-side).
2. While using WebDriver sampler each thread will have a single browser instance and each browser consumes significant amount of resources.
Painless Status Reporting in GitHub Pull Requests - Designing CI/CD Systems
Tags: python, ci, continuousdelivery, github
Published: 2019-10-21 22:52:50

---
title: Painless Status Reporting in GitHub Pull Requests - Designing CI/CD Systems
published: true
date: 2019-10-14 04:00:00 UTC
tags: python, ci, continuousdelivery, github
canonical_url: https://tryexceptpass.org/article/continuous-builds-reporting-status/
cover_image: https://tryexceptpass.org/images/continuous-builds-reporting-status/continuous-builds-reporting-status.webp
---

Continuing the build service discussion from the [Designing CI/CD Systems](https://dev.to/tryexceptpass/designing-continuous-build-systems-6d9) series, we’re now at a good point to look at reporting status as code passes through the system.

At the very minimum, you want to communicate build results to our users, but it’s worth examining other steps in the process that also provide useful information.

The code for reporting status isn’t a major feat. However, using it to enforce build workflows can get complicated when implemented from scratch.

Since the pipeline covered so far in earlier articles already integrates with GitHub, it’s much easier to simplify things by taking advantage of GitHub’s features. Specifically, we can use the Status API to convey information directly into pull requests, and use repository settings to gate merges based on those statuses.

## Reporting status to GitHub

We had a brief discussion of this API in a previous article about [integrating pytest results with GitHub](https://tryexceptpass.org/article/pytest-github-integration/). It also covered GitHub Apps and how to authenticate them into the REST API. Today we’ll discuss more details about the Status API itself, keeping in mind a pre-existing App.

Reporting pull request status is a simple HTTP POST request to the status endpoint of the relevant PR. You can find that URL as part of the webhook event details related to the PR.

[Read On...](https://tryexceptpass.org/article/continuous-builds-reporting-status/)
Distributed Testing in JMeter
Tags: jmeter
Published: 2019-10-14 03:24:25

Step1:
Open JMeter.properties file from /bin folder. In the Remote Hots, give the IP address of all slave systems you want to connect to for Load testing.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/esf1nb1ve3g2gs7rue0t.png)

Once you have added remote system’s ip in jmeter.properties goto next step.

Step 2 : run keystore - crete-rmi-keystore.bat file from /bin folder. Enter 
   name : rmi
   password : changeit

Step 3 : run jmeter-server file on slave (remote) system

Step 4 : Run and Validate the test.

Notes:
 - all systems (master and slaves) have same ver of JMeter
 - all systems have java (preferably same ver)
 - all systems can connect to each other (are in same subnet)
 - no need to copy jmeter script (jmx) to slave systems
 - If you want to have 100 users and using  2 slaves. Give no as 50
The History of FireTest - A New PHP Test Automation Framework
Tags: php, showdev, html, webdev
Published: 2019-10-14 03:21:12

---
title: The History of FireTest - A New PHP Test Automation Framework
published: true
date: 2019-10-14 03:18:44 UTC
tags: php, showdev, html, webdev
canonical_url: https://ua1.us/updates/firetest/the-history-of-firetest/
---

UA1 Labs has officially released version 2.0.0 of FireTest. But why are we so focused on building yet another testing framework when there are so many already out there?

## What Exactly is FireTest?

FireTest is a PHP test automation framework that allows you to automate tests as you write code. It was written in PHP for testing PHP code.

## Why Did You Write Your Own Test Automation Framework?

For us the answer was simple, we looked into the many testing frameworks written for PHP and weren’t quite satisfied with what we were seeing. We wanted a light weight and flexible framework that wouldn’t get in the way of our workflow. We wanted to ensure that when we ran our automated tests that the results were valuable to us in catching bugs.

Most of the frameworks we looked at were so focused on code coverage, unit testing, CAP score. They missed out on the important thing. Does the code I’m writing still do what I want it to? And if we find a bug, how can I write a test so that the same bug doesn’t happen again. All other frameworks we worked with didn’t provide the flexibility we were looking for.

So we invented FireTest! We admit, it seems primitive in nature compared to the other popular testing frameworks, but we feel like we needed to get back to basics. Stop bloating our testing to reduce the complexity of the code you are writing. Instead we wanted to focus on simplicity and ease of use.

The post [The History of FireTest](https://ua1.us/updates/firetest/the-history-of-firetest/) appeared first on [UA1 Labs](https://ua1.us).
Intro to TypeScript Documentation with TSDoc
Tags: typescript
Published: 2019-10-14 03:02:47

---
title: Intro to TypeScript Documentation with TSDoc
description: Learn how to use TSDoc to generate API Documentation for TypeScript and JavaScript.
tags: typescript
published: true
canonical_url: https://coryrylan.com/blog/intro-to-typescript-documentation-with-tsdoc
---

In this post we will learn how to use [TSDoc](https://github.com/microsoft/tsdoc) and [TypeDoc](https://typedoc.org/) to create API documentation for TypeScript. TSDoc is a specification of how to comment our TypeScript code to help create API documentation and metadata for our codebase.

TSDoc is a spec maintained by the TypeScript team. Since TypeScript provides static typing, we can generate a lot of the information about our codebase without annotations found in JSDoc. Let's take a look at some TypeScript code that has some TSDoc comments.

```typescript
export class Math {
  /**
   * Returns the sum of two numbers.
   *
   * @remarks
   * This is our math utilities lib for shared projects.
   *
   * @param x - The first input number
   * @param y - The second input number
   * @returns The sum of `x` and `y`
   */
  static add(x: number, y: number): number {
    return x + y;
  }
}
```

TSDoc comments are regular comments but start with two asterisks `**`. TSDoc uses special tag annotations `@` to provide additional information for documentation. Once we describe our code, we can immediately get benefits by using an editor that understands TypeScript.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ie3eko5981kbtbh6xzic.png)

In the screenshot, we can see now that we have TSDoc comments in our editor and hints highlighting detail about the API of our method. Even if we are not going to generate public APIs using TSDoc we can still get benefits within internal or private code.

## TypeScript API Generation with TypeDoc

[TypeDoc](https://typedoc.org/) is an open-source project that uses TSDoc to generate API documentation. TypeDoc is a very straightforward project to use when creating TypeScript documentation.

```bash
npm install --save-dev typedoc

typedoc --out docs /src
```

We can install TypeDoc and then point TypeDoc to our source code. TypeDoc will generate a basic API site for us to use.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/fjvns3ruwusmq4osqdjh.png)

TypeDoc also has a really nice option to generate the API as a JSON result instead of a pre-generated doc site. Generating the API as JSON is useful for being able to create customizable and searchable APIs in existing documentation sites. If you want to try out TSDoc check out the [docs](https://microsoft.github.io/tsdoc/). Find the working [demo here](https://stackblitz.com/edit/typescript-swrwmb)
ULID in GO Lang 
Tags: security, audit, go, architecture
Published: 2019-10-14 02:32:31

---
title: ULID in GO Lang 
published: true
description: An implementation with some variation for timestamps 
tags: Security, Audit, Golang, architecture
---

I have digging around for some time in audit-able ready log systems, as a core part of a decentralized environments and the core for trust between hosts. In epyphite (soon to be release) trust and transparency are important. For that reason we needed to come out with a way to generate a Unique Identifier that can be concurrent and millisecond friend. Specially when it comes to decentralized and high reliant systems.

Its very important to be able to have a unique identifier, timestamped and ordered that can point and trace fast to different events.

I came across with this github repo covering ULID that suited in that moment our needs.

https://github.com/oklog/ulid

But we had a problem...
In our environment millisecond are valuable, and by "secure by design" principle, we could not have events sharing the same timestamp ID. Every change is important, and the ability to search fast in between is at the most importance

Searching around I found this great article

https://barkeywolf.consulting/posts/badger-event-store/


So I decided to code those specs into an small library to share on Github.

[HERE](https://github.com/epyphite/ulid)


Again.. all of this are WIP and they need to be expanded for use and documentation, but ...you will get the idea.

The goal is to be able to generate sub buckets for a millisecond in a consistent, ordered , to have different sub id's that we can use. We do have limitations.. but for the specific use case that we were having this implementation was enough.

:)

Any comments, feel free.
Happy Coding.
Correlation in JMeter
Tags: correlation, jmeter, performancetesting
Published: 2019-10-14 02:22:48

What is Correlation?
Correlation is Dynamic Referencing. This is the process of extracting some value from response of a step and referring it into request of other subsequent step.

Why to use Correlation?
For property transfer from one step to another. For example, after login to a website, unique session id is allocated, and this id is required in subsequent steps to interact with the server. So here Correlation will be needed.

How to implement Correlation?
using Regular Expression Extractor, in JMeter you can do correlation.

Steps for implementation.
Step 1 : Create a Test Plan with "Regular Expression Extractor" where you want to do dynamic referencing in JMeter.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/792p9m3u937bbf3vscno.png)

Step 2 : Execute the test, and copy response from First Request, navigate to "https://regexr.com/" as we need to provide regular expression in the Regular Expression Extractor from where response value(s) needs to be extracted.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/tpxy15jlyfh95hfqq39t.png)

Reference Name: Any name- e.g. ReferenceValue
Regular Expression: to match in the response of first. e.g. href="(.*?)"
Template: $1$
Match No.: Your regular expression can match multiple elements, so enter match number to take one. e.g. 14
Default Value: In case no match is found,default will be used. Optional field.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/7ci8j5j813bl733cozi9.png)

Step 3 : Refer the extracted value (referred by Reference Name) into a subsequent step.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/jbvbsw3a07unipy60a1m.png)

Step 4 : Run and validate the results.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/c2gauijzp0gw6yscqkxu.png)
DRAGnet
Tags: ruby, rails, react, redux
Published: 2019-10-14 02:11:15

<h1><center>Rails + React + Redux - Pt 8</center></h1>
*********************************************************

I'm actually really happy to be tinkering in React and Redux again! I've been spending a lot of time learning Python/Django and some time exploring Docker and Heroku. In this post I'm going to focus in on directory structure within the "/frontend" (React client) directory and some primary files within (index.js, app.js, root_reducer.js, etc).

*********************************************************
<h1><center> Let's get started! </center></h1>
*********************************************************

Below I'm introducing a web app called workflowy.com that I really enjoy using to plan projects and keep notes. It works really well organized by directories and files. In my first pass at this project I had far fewer files and directories but they grew really fast. I've found that it's better just to set as broad of a base structure first and refactor down once the project is closer to some form of completion.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/dchuep39e18tb6ol1gti.png)

The top level index.js file is your standard React index file. 

{% gist https://gist.github.com/JaredHarbison/0c6cda2a158e8b2bdf02031aeb761baf %}

The App.js file is really self-explanatory as well. Enjoy the simplicity before we jump into actions and reducers!

{% gist https://gist.github.com/JaredHarbison/bf26b2af27be575d8dc56cce95a4b83e %}

The next post will cover the actions files, where we need to make our fetch calls to retrieve the data from the Rails backend. 

*********************************************************
<h1><center> That's all folks! </center></h1>
Angular with Google Maps Tutorials
Tags: angular, googlemaps, webapp, tutorial
Published: 2019-10-14 01:14:20

I'm working on a project where I needed to add a map, so I decided to go for the Google Maps route. In this tutorial, I'm going to show you how to add Google Maps to your Angular app in 2 different ways. The first one will be using the AGM (Angular Google Maps) library and the second will be using purely Google Maps API.

You can do both parts of the tutorial or one or the other. They don't depend on each other.

- <a href="https://dev.to/pato_codes/setup-google-maps-with-agm-in-angular-app-33em">Setup Google Maps with AGM in Angular app</a>
<img src="https://thepracticaldev.s3.amazonaws.com/i/wv9f6it8pgfffh87nro6.png" />

- <a href="https://dev.to/pato_codes/setup-google-map-in-angular-app-the-pro-way-3m9p">Setup Google Map in Angular app (The pro way)</a>
<img src="https://thepracticaldev.s3.amazonaws.com/i/0v7c9zhfndhjtson2eed.png" />

<img src="https://thepracticaldev.s3.amazonaws.com/i/5a87eog40zvcsimuaew4.png" />
Setup Google Maps with AGM in Angular App
Tags: angular, googlemaps, webdev, tutorial
Published: 2019-10-14 01:13:18

Always wondered how to setup Google Maps the easy way in an Angular project?

Here's I'm going to show you how.

If you are looking to add a lot of functionality I will suggest you to add the map the way I teach you in my other tutorial: https://dev.to/pato_codes/setup-google-map-in-angular-app-the-pro-way-3m9p

<h2 id="agm">Setup Google Maps with AGM (Angular Google Maps)</h2>

If it was me working on a project that I needed to do some basic Google maps functionality I will approach it this way by using the AGM library. if the app needs more custom functionality I will do it using the Google Maps API only.

To learn more about AGM (Angular Google Maps) visit:
https://angular-maps.com/ 
https://stackblitz.com/edit/angular-google-maps-demo

<h3>Let's get Started!!</h3>
 
1) Create a new Angular project:
   ```javascript
   ng new angular-agm
   ```
2) Install the AGM library inside of you Angular app you just created
   ```javascript
   npm install @agm/core
   ```
3) Now open your <strong>app.module.ts</strong> file. Let's add the AGM library to our app. At the top of your file add the following line

   ```javascript
   import { AgmCoreModule } from '@agm/core';
   ```
4) Generate a Google Maps API key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en#key">here</a>

5) Add the AgmCoreModule to your imports array inside of the  <strong>app.module.ts</strong> file.
   ```javascript
   imports: [
    BrowserModule,
    AgmCoreModule.forRoot({
      apiKey: 'YOUR GOOGLE API KEY HERE'
    })
  ],
   ```
6) Paste your generated API Key as the value for your apiKey property.

7) Time to add the map to your HTML file. Go to your app.component.html and add the following:

   ```html
<agm-map [latitude]="lat" [longitude]="lng"></agm-map>
   ```

<i> Note: The latitude and longitude values are used to show the centered initial view of the map. </i>

8) Adding a marker to the map. Inside of your <strong>app.component.html</strong> add the following line:

   ```html
   <agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
   ```
Your html file will look like this:
   ```html
   <agm-map [latitude]="lat" [longitude]="lng">
     <agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
   </agm-map>
   ```
9) Go to your CSS file. app.component.css and add the following:
   ```css
   agm-map {
     height: 500px;
   }
   ```
 <i>Note: If you don't add the height, the map won't show on your app.</i>

10) Go to your app.component.ts file add the following variables:
  ```javascript
  lat = 40.730610;
  lng = -73.935242;
  ```
The variables are the ones defining where is the center of the map and also place the marker in the same place.

11) Start your server in the terminal:
   ```javascript
   ng serve --o
   ```

13) You should see something like this:
<img src="https://thepracticaldev.s3.amazonaws.com/i/nx9d88mz7q827dll1utn.png" />

14) The complete repo:
https://github.com/devpato/angular-agm-tutorial

<img src="https://thepracticaldev.s3.amazonaws.com/i/5a87eog40zvcsimuaew4.png" />