teleren/devto huggingface dataset:
Jenkins Slack Notifications
Tags: jenkins, slack
Published: 2018-10-13 16:23:07

---
title: Jenkins Slack Notifications
published: true
tags: jenkins, slack
canonical_url: https://committed.software/posts/jenkins/slackNotifications/
---

[![slackNotifications](https://committed.software/static/slackNotifications-a661d0493d23b1574f3bf93fbf29bdc8-84ad3.png)](/static/slackNotifications-a661d0493d23b1574f3bf93fbf29bdc8-63613.png)

To add a slack notification from our continuous integration builds on Jenkins Blue Ocean we use the [Slack Notification](https://plugins.jenkins.io/slack) plugin. Adding a set of functions to the Jenkinsfile which is then called in the `post` section of the pipeline. We use the git command to extract the committers name and the hash of the commit so we can link to the commit in bitbucket and add the author’s name if the build has failed or is unstable so it will be brought to their attention.

```groovy
pipeline {
  agent { 
    ...
  }

  stages {
    stage('env') {
      steps {
        notifyStarted()
      }
    }
        ...
  }
  post {
    success {
      notifySuccess()
    }
    unstable {
      notifyUnstable()
    }
    failure {
      notifyFailed()
    }
  }
}

def notifyBuild(String buildStatus = 'STARTED', String colorCode = '#5492f7', String notify = '') {

  def project = 'projectName'
  def channel = "${project}"
  def base = "https://bitbucket.org/committed/${project}/commits/" 
  
  def commit = sh(returnStdout: true, script: 'git log -n 1 --format="%H"').trim()
  def link = "${base}${commit}" 
  def shortCommit = commit.take(6)
  def title = sh(returnStdout: true, script: 'git log -n 1 --format="%s"').trim()
  def subject = "<${link}|${shortCommit}> ${title}" 

  def summary = "${buildStatus}: Job <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>\n${subject} ${notify}"
  
  slackSend (channel: "#${channel}", color: colorCode, message: summary)

}

def author() {
  return sh(returnStdout: true, script: 'git log -n 1 --format="%an" | awk \'{print tolower($1);}\'').trim()
}

def notifyStarted() {
  notifyBuild()
}

def notifySuccess() {
  notifyBuild('SUCCESS', 'good')
}

def notifyUnstable() {
  notifyBuild('UNSTABLE', 'warning', "\nAuthor: @${author()} <${RUN_CHANGES_DISPLAY_URL}|Changelog>")
}

def notifyFailed() {
  notifyBuild('FAILED', 'danger', "\nAuthor: @${author()} <${RUN_CHANGES_DISPLAY_URL}|Changelog>")
}
```
Why code coverage is not a reliable metric
Published: 2018-01-13 20:22:57

---
title: "Why code coverage is not a reliable metric"
published: true
description: Why code coverage is not a reliable metric
tags: 
---

I often hear statements like "Let's increase code coverage" or "What's our code coverage?" (mostly from managers). And I think to myself "Oh, boy...".

Not because I don't like unit tests or think they're useless. On the contrary. I think unit tests are very important and useful.

What I'm against is using code coverage as a metric. Because it can mean nothing. And it usually doesn't.
<h1>Let me explain why</h1>

Consider the following class that validates and email address:
<code>
<pre>
class EmailValidator
{
    public bool ValidateEmail(string email)
    {
        // just for demo purposes
        // I know it's not a very good email regex :P
        return new RegEx("[a-zA-Z0-9_]+[@][a-z]+[.]com").matches(email);
    }
}
</pre>
</code>
And a class used for unit testing the email validator:
<code>
<pre>
class EmailValidatorTest
{
    void TestValidEmail()
    {
        Assert.IsTrue(EmailValidator.ValidateEmail("someone@email.com"));
    }
}
</pre>
</code>
<h1>What's my code coverage?</h1>
Well, I only have one class with one method. And my unit test goes though that code. That means my entire "codebase" is covered. Yay! 100% coverage!
That means my code is bullet-proof, right? <b>WRONG!</b>

Why? Because my regex, although not very complex, covers a lot scenarios.
I've only written a unit test for small letters.
I haven't written unit tests for emails that are comprised of:
- empty string
- caps
- numbers
- underscore
- alphanumeric characters
- combinations of the above (and there are plenty)

So, what's my *REAL* coverage? I would say less than 15%.
<h1>What about real life?</h1>
I'm not saying code coverage is always unreliable. But it only works as expected for simple cases. Like the following:
<code>
<pre>
bool IsEven(int n)
{
    if(n%2 == 0)
        return true;
    else
        return false;
}
</pre>
</code>
Two unit tests for this code will give 100% coverage and that's actually all the unit tests you need for this.

But you don't have code like this in real life. From my experience, less than 5% of any codebase has code that's dead simple like this.

Most of the time, you use third party libraries that have classes/functions like the regex I used above. Even though I only wrote one line, there are a bunch of if/else statements hiding behind that.
<h1>Conclusion</h1>
What I disagree with isn't code coverage per se. That actually helps the developer to visualize the areas in which s/he hasn't written any unit tests at all.

The problem is most people don't understand that 
<b>high code coverage &ne; code reliability</b>.

You can have >95% code coverage and your application can be unacceptably buggy (I've actually witnessed this myself).
What things can we (or should we) be using Python for instead of JavaScript?
Tags: discuss, python, javascript
Published: 2018-01-13 20:00:03

---
title: What things can we (or should we) be using Python for instead of JavaScript?
published: true
tags: discuss, python, javascript
---

In my day to day work as a web dev I use JS all over the stack, but in my free time I've decided (rather pragmatically) to learn Python. 

A question for all those monoglot/polyglot pythonistas out there,

What aspects of JavaScript-centric frontend/backend web development could be done more simply, efficiently or successfully in Python? 

Off the top of my head I'm thinking:
- web servers?
- build system tooling?
Impact of Meltdown fix on AWS
Tags: meltdown, cloudcomputing, amazonwebservices
Published: 2019-10-26 16:59:16

---
title: Impact of Meltdown fix on AWS
published: true
date: 2018-01-13 13:46:38 UTC
tags: meltdown,cloud-computing,amazon-web-services
canonical_url: 
---

On 3rd January, Google Project Zero Team [disclosed](https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html) about the two hardware vulnerabilities: [Meltdown](https://meltdownattack.com/meltdown.pdf) and [Spectre](https://spectreattack.com/spectre.pdf). Whereas Meltdown is specific to Intel processors, Spectre affects almost all modern processors.

As soon as they were disclosed, all of the cloud providers started working on patching the hypervisors with the fix. In this post, we will talk about how AWS handled the same.

AWS Instances are broadly classified into two categories: [PVM](https://en.wikipedia.org/wiki/Paravirtualization) and [HVM](https://en.wikipedia.org/wiki/Hardware-assisted_virtualization). While HVM hypervisors were patched online without affecting any of the running instances, AWS notified the customers to reboot their PVM instances before 6th January.

We noticed increased CPU utilisation for almost all of our instance groups significantly.

![](https://cdn-images-1.medium.com/max/1024/1*CclTRJnjEt24auzmzc0UMg.png)<figcaption>Increased CPU Utilisation on our 3-node Cassandra Cluster running on r4.large instances</figcaption>

**{1}** By 4th January, [AWS](https://aws.amazon.com/security/security-bulletins/AWS-2018-013/) patched the hypervisor with [Kernel Page Table Isolation (KPTI)](https://lwn.net/Articles/741878/) which caused \> 100% increase in the CPU utilisation. Some of the cassandra consultant and managed hosting companies have noticed [the](https://twitter.com/BenBromhead/status/950245250504601600) [same](http://thelastpickle.com/blog/2018/01/10/meltdown-impact-on-latency.html). Performance impact of KPTI mitigation depends purely on the system calls made by the application. So, the performance impact may vary accordingly.

**{2}** On 12th January, AWS rolled out something which reduced the performance impact back to the pre-meltdown patch level. Although, AWS hasn’t disclosed anything about the same yet.

We noticed something similar in RDS instance too.

![](https://cdn-images-1.medium.com/max/1024/1*2oDHNPgOFXs1nGwfOUstUw.png)<figcaption>Increased CPU Utilisation on our RDS instance</figcaption>

AWS patch protects from any instance-to-instance concerns (one instance can read the memory of another) and instance-to-hypervisor concerns (instance can read hypervisor memory). AWS still recommend all customers to upgrade their instance kernel to mitigate any process-to-process concerns.
git remotes with ssh aliases
Published: 2018-03-08 07:43:57

---
title: git remotes with ssh aliases
published: true
tags: 
canonical_url: https://tilde.team/~ben/blog/git-remotes-with-ssh-aliases.html
---

did you know that `~/.ssh/config` aliases work for git remotes??

~/.ssh/config

```
Host gh 
HostName github.com 
User git 
IdentityFile ~/.ssh/gh\_key
```

you can now use `gh:username/repo` as the remote in place of `git@github.com:username/repo`, which is much shorter and easier to type many times!

`git clone gh:benharri/learngit`

there are many other use cases for the `ssh_config` file. for example, here is my config for the tilde machine for easy ssh connections.

```
Host tilde 
HostName tilde.team 
User ben
```

then use `ssh tilde` to start a new ssh session. this also works with `scp`: try something like this `scp file.txt tilde:workspace/.` in place of `scp file.txt ben@tilde.team:workspace/.`

the ssh\_config file is super useful. check `man ssh_config` for a full list of options!

Tags: [git](tag_git.html), [ssh](tag_ssh.html)

<!-- text end -->

[Comments? Tweet](http://twitter.com/intent/tweet?url=https://tilde.team/~ben/blog/git-remotes-with-ssh-aliases.html&text=<Type%20your%20comment%20here%20but%20please%20leave%20the%20URL%20so%20that%20other%20people%20can%20follow%20the%20comments>&via=nebsirrah)
How I Made A Gradient Generator  
Tags: javascript, beginners, css, showdev
Published: 2018-01-13 19:39:32

---
title: How I Made A Gradient Generator  
published: true
description: A quick overview on how I went about using Javascript to build a lightweight hex decimal gradient generator.  
tags: javascript,beginners,CSS,showdev
---

Being my first post on dev.to I think it's best to introduce myself first. I'm Scott Andrews and i'm a second year computing student at the university of Worcester in the United Kingdom. I started programming with HTML and CSS at the age of 12 and never looked back. I have a couple of website clients and am about to publish my first IOS app.

I went about starting to build the website by first choosing jQuery to be my javascript framework of choice. I went for jQuery as it enabled me to quickly and easily hide sections of html code and respond to hover events. jQuery also adds simple animations which is powerful. 

After a bit of google searching I came across stack overflow (which is where I spend 90% of my time on the internet.) the required javascript method to be able to create a random hex decimal value.

`randomColourOne = "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16);});`

Once the value was created it needed to be assigned to the background of the website. For that I used the -webkit-linear-gradient css style which does still have its compatibility issues but runs fine on codepen.

`var background = document.getElementById("background");
    background.style.backgroundImage = "-webkit-linear-gradient("+ randomColourOne +" , "+ randomColourTwo +")";`

That was in essence the bulk of the Javascript. The whole code is available at codepen.
{% codepen https://codepen.io/ScottAndrews/pen/OjEWme %} 

Thanks Guys, Scott Andrews
Do you have a blog?
Tags: discuss
Published: 2018-01-13 19:19:25

---
title: Do you have a blog?
published: true
tags: discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/si8jg2qk7y810lwtb471.jpg
---

Hi,

I'd like to discuss blogging and hear your experience. Also, I want to find some blogs to subscribe to :-)  

1) Do you have a blog? Please share it if you do, and if you don't, why?

2) Do you enjoy blogging? How often do you write? How many time does it consume for you? How many times did you start and stop blogging?

3) Has blogging paid off for you? Have you got freelance contracts or job thanks to your blog?

4) How do you host the blog? Which services do you use? What are your plans for the next make-over?

5) Do you follow other developer blogs? How? RSS, Twitter, dev.to?
Evening Rust: Episode 1 - Rusty Beginnings
Tags: video, coding, rust, competition
Published: 2018-01-13 11:00:41

---
title: "Evening Rust: Episode 1 - Rusty Beginnings"
published: true
description: I journey to Mars, appropriately colored, to continue my Rust learning.
tags: video, coding, rust, competition
---

{% youtube f1IEq7Meh2o %}

After landing on Mars I fight off the native string inhabitants: they steadfast refuse to create substrings for me. From there I go on to create a poor bit-processing algorithm. All in Rust -- in which I learned a few new things. 

Subscribe to my [Twitch Channel](https://www.twitch.tv/mortoray) to watch live. Commentary appreciated.
How I learned the most about using XML with PHP
Tags: php, library, sql, database
Published: 2018-01-13 08:50:32

---
title: How I learned the most about using XML with PHP
published: true
description: Explanation on why I wrote my own database system and thoughts on how to overcome obstacles.
tags: php,library,sql,database
---
**Disclaimer:** *The software in question that used this solition was only used by two people - one of which was me. Only one of those two had write access - also me. This solution never was a business solution and was never used in production.*

Quite some time ago, I was writing some PHP software for the web that would need to use a database. I wanted to design the software as portable as possible so that it wouldn't be too much hassle to migrate to another provider. MySQL was too big for what I wanted and while SQLite is powerful itself, I figured it would better suit my needs.

Sometimes when writing software, you run into a problem. Usually, there are multiple ways to solve it. My problem was, that I could not use SQLite in my PHP application, since my hosting provider did not allow me to install it and wouldn’t install it themselves.

Solution 1 would be to switch to another hosting provider which supports SQLite and run the program there. Solution 2 would be to search for another database system which does not require any installation at all. And solution 3 was what I chose to do: Write my own database solution.

While this has some very clear disadvantages like costing time, it has two main advantages. Firstly, you can control how the system behaves since you write it from scratch. Secondly, you gain a lot of experience by writing something you have never written before.

And that's how [NWDatabase][1], a database system that comes with a PHP library and creates files with an XML syntax, was born. A software created while learning about XML, classes and much more. Surely not the best idea for production but not all that terrible for learning.

[1]: https://github.com/nitricware/NWDataBase

**P.S.:** *This post was slightly altered after the first 24h, reacting on some comments.*
How to debug and solve "Permission denied(403)" issue for Kubernetes
Tags: kubernetes, rbac
Published: 2018-01-13 08:35:10

---
title: How to debug and solve "Permission denied(403)" issue for Kubernetes
published: true
description: enable audit chain to let you know which issue encounter and solved with `kubectl create [cluster]rolebinding <name> <cluterrole name> <user name which met the 403>` 
tags: kubernetes,RBAC
---

When using kubernetes, authorization issue is a boring thing since we usually not care about the authorization part, we just want the feature work, like HPA.

So for this, I strongly recommend you to enable audit chain to let you know which user is on 403 in the cluster, since kubernetes often use some broker user to do the final operation instead of the user you think it should be.

To enable audit chain, refer to [audit configuration](https://kubernetes.io/docs/tasks/debug-application-cluster/audit).

After you enable audit, you can check the audit log via `tail -f` when you debug the permission denied issue. You will see something like this in audit log:
```
2017-03-21T03:57:09.106841886-04:00 AUDIT: id="c939d2a7-1c37-4ef1-b2f7-4ba9b1e43b53" ip="127.0.0.1" method="GET" user="admin" groups="\"system:masters\",\"system:authenticated\"" as="<self>" asgroups="<lookup>" namespace="default" uri="/api/v1/namespaces/default/pods"
2017-03-21T03:57:09.108403639-04:00 AUDIT: id="c939d2a7-1c37-4ef1-b2f7-4ba9b1e43b53" response="200"
```

You can find the 403 ones, and try to grant (`kubectl create clusterrolebinding bindname --cluster-role=role_name --user=user_name [--group=group_name]`) the users or groups with proper role or cluster role (`kubectl get cluster role`) in proper scope.


Anyway, you have to be familiar with kubernetes, and a little knowledge about kubernetes RBAC, or you will still no idea what I am talking about.

Thanks.
Explain *aaS and other variants Like I'm Five
Tags: explainlikeimfive
Published: 2018-01-13 07:53:45

---
title: Explain *aaS and other variants Like I'm Five
published: true
tags: explainlikeimfive
---

____ as a Service, IaaS, SaaS, PaaS, etc. What are they? Are there something common between them?
Should you Fire a Coworker for Making an Honest Mistake?
Tags: programming, bug, workplace, discuss
Published: 2018-01-13 10:14:40

---
title: "Should you Fire a Coworker for Making an Honest Mistake?"
published: true
tags: Programming,bug,workplace,discuss
cover_image: http://leruplund.dk/wp-content/uploads/2018/01/Gravhøj-2000x800.png
canonical_url: http://leruplund.dk/2018/01/13/should-you-fire-a-coworker-for-making-an-honest-mistake/
---

A while back my hairdresser accidentally cut my ear. It was just a small cut and I hardly felt it but since cuts in ears have a tendency to bleed a lot my hairdresser felt really bad and almost starting crying.

After having driven home with one hand on the steering wheel and the other hand holding a towel to my ear (it’s hard to drive a stick that way), why wife went into conniptions and while she tried stopping the bleeding she demanded that I find a new hairdresser.

“Why would I do that?”, I asked.

“Well, obviously this one is highly incompetent. And she even made you pay 100 DKK for this mess”.

I said: “I am not going to find a new hairdresser. I just invested 100 DKK to be absolutely sure that this hairdresser will never cut my ear again.”

So far I have been right. The nice little scar on my ear reminds my hairdresser to be extra careful and thorough :-).

* * *

[Once in a while](https://dev.to/ben/what-was-the-worst-bug-youve-ever-written-2cn7) you read about developers being fired for making honest although massive bugs. The question is: Is it the right thing to fire people?

Personally, I think it is the wrong thing to do. Making an honest mistake is not enough to get you fired.

But it all depends on how you handle that mistake. If the person who made the mistake steps up to the plate, takes responsibility and does everything he or she can to fix it and learn from it, then you as a company will not get a better co-worker by firing and hiring somebody else. The new guy might even make the same mistake. It’s also very likely that the mistake happened because the processes in your company are not good enough.

What is the right thing to do?
Quick Hulk Code Pen
Tags: css, codepen
Published: 2018-01-13 04:37:21

---
title: Quick Hulk Code Pen
published: true
description: I give you "Hulk table rage"
tags: css, codepen
canonical_url: https://www.iamdeveloper.com/posts/quick-hulk-code-pen-18i1/
cover_image: https://c1.staticflickr.com/3/2825/34089505692_6d6cb68560_h.jpg
series: my codepens
---

Short and sweet. One of my [goals for 2018](https://dev.to/nickytonline/2018-resolutions-1deo) is to start doing Code Pens. Here's my first one. Simple and fun. I give you [Hulk table rage](https://codepen.io/nickytonline/pen/jYKYWY).
{% codepen https://codepen.io/nickytonline/pen/jYKYWY %}

Cover photo courtesy of Flickr user [steelex709legocreations](https://www.flickr.com/photos/steelex709legocreations/34089505692/in/photostream).
Types of Network Architecture
Tags: networks, basics
Published: 2018-01-13 01:25:12

---
title: Types of Network Architecture
published: true
description: 
tags: networks, basics
---

##What is Network Architecture
First and foremost, what is network architecture? It's basically the physical and logical design which refers to the software, hardware, protocols and the media of transmission of data. Simply put, it refers to how computers are organized and how tasks are allocated among these computers. The two types of widely used network architectures are **peer-to-peer** aka **P2P** and **client/server** aka **tiered**.

###Peer-to-Peer Architecture
In a peer-to-peer network, tasks are allocated to every device on the network. Furthermore, there is no real hierarchy in this network, all computers are considered equal and all have the same abilities to use the resources available on this network. Instead of having a central server which would act as the shared drive, each computer thats connected to this network would act as the server for the files stored on it.

![peer-to-peer](http://fcit.usf.edu/network/chap6/pics/peer.gif)

####Advantages of a peer-to-peer network
- Does not require a dedicated server which means its less costly.
- If one computer stops working, the other computers connected to the network will continue working.
- Installation and setup is quite painless because of the built-in support in modern operating systems.

####Disadvantages of a peer-to-peer network
- Security and data backups are to be done to each individual computer.
- As the numbers of computers increases on a P2P network... performance, security, and access becomes a major headache. 

###Client/Server Architecture
In a client/server network, a centralized, really powerful computer(server) acts as a hub in which other computers or workstations(clients) can connect to. This server is the heart of the system, which manages and provides resources to any client that requests them.

![client/server](http://fcit.usf.edu/network/chap6/pics/clntserv.gif)

####Advantages of a client/server network
- Resources and data security are controlled through the server.
- Not restricted to a small number of computers.
- Server can be accessed anywhere and across multiple platforms.

####Disadvantages of a client/server network
- Can become very costly due to the need of a server as well as networking devices such as hubs, routers, and switches.
- If and when the server goes down, the entire network will be affected.
- Technical staff needed to maintain and ensure network functions efficiently.