teleren/devto huggingface dataset:
Introducing `Behaves`, a better way to define contracts/behaviors between classes
Tags: ruby, rails, opensource, showdev
Published: 2019-06-07 15:30:54

Hey guys!


I just published my first gem on RubyGems, and would love to hear your feedback!

{% github https://github.com/edisonywh/behaves %}


## Description

Behaves is a gem that helps you maintain contracts between different classes. This is especially useful for dealing for adapter patterns by making sure that all of your adapters define the required behaviors.

The idea for `Behaves` stemmed from my research into [adapter pattern in Ruby](https://www.sitepoint.com/using-and-testing-the-adapter-design-pattern/) and José Valim's article on [Mocks and explicit contracts](http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/).

I found that the current idiom to achieve `behaviors` in Ruby is through `Inheritence`, and then subsequently defining a "required" (I put quotation marks around it, because it's not exactly `required` until you run it) method, which does nothing except raising a `NotImplementedError`. While I don't necessarily think it's *bad*, I do think that there could be an alternative that's **more explicit**, **less boilerplate**, **cleaner ancestors hierachy**, thus the birth of `Behaves`.

Best of all? **No more runtime errors for defining behaviors!**


Do let me know what you think!
JavaScript and Scope II - Functions
Tags: javascript
Published: 2019-06-07 15:19:41

As you saw in the [previous article about JavaScript scope](https://blog.toddbiz.com/blog/2019-06-01-javascript-and-scope/), a function can create a new scope which determines the value to use when we have two different variables with the same name.

But is scope determined by where a function is declared, or where the function is run?

```js
var i = 10;

function foo() {
  var i = 2;
}

function bar() {
  i = i + 1;
  console.log ('value of i when bar is declared outside foo: ', i);
}


foo();

bar();
```
<div class="jsfiddle-link">
  <a href="https://jsfiddle.net/tchaffee/0jwyg6za/" target="_blank">Edit in JSFiddle</a>
</div>

In the example above it should be obvious that `i` will have a value of `11` when `console.log` runs. But what happens if we run `bar` inside of `foo`? The answer might surprise you if you are new to JavaScript.

```js
var i = 10;

function foo() {
  var i = 2;
    
  bar();

}

function bar() {
  i = i + 1;
  console.log ('value of i when bar is declared outside foo: ', i);
}


foo();
```
<div class="jsfiddle-link">
  <a href="https://jsfiddle.net/tchaffee/bue5zf9w/" target="_blank">Edit in JSFiddle</a>
</div>

The `i` variable again will have a value of `11` when `console.log` runs.

Because `bar` is declared in the global scope, it changes the value of the `i` variable that exists in the same global scope. Even when it runs inside of `foo`, it does not reference the `i` declared inside of the `foo` scope.

So what happens if we declare the bar function inside of the `foo` function?

```js
var i = 10;

function foo() {
  var i = 2;
  
  function bar() {
    i = i + 1;
    console.log ('value of i when bar is declared inside foo: ', i);
  }
  
  bar();

}

foo();
```
<div class="jsfiddle-link">
  <a href="https://jsfiddle.net/tchaffee/x3f1Ln8e/" target="_blank">Edit in JSFiddle</a>
</div>

Hopefully you guessed that `console.log` will show `i` having a value of `3`. The `bar` function is declared inside the scope of the `foo` function, so it will change and output the value of the `i` variable declared in the `foo` scope.

Many programming languages work like this, but not all of them so it's good to know the vocabulary for this. When scope is determined by where a function is declared (where it is written in the source code), we call it lexical scope. JavaScript uses lexical scope.

Learn more about scope in [JavaScript and Scope III - Arrow Functions](https://blog.toddbiz.com/blog/2019-06-07-javascript-and-scope-iii/)
How long have you stayed at a job where you were happy?
Tags: discuss, career
Published: 2019-06-07 15:16:11

---
title: How long have you stayed at a job where you were happy?
published: true
description: Flipping the perspective on Ben's post "What's the longest you've stayed at a job you were unhappy with?"
tags: discuss, career
---

Let's flip the perspective on Ben's earlier post...

{% link ben/what-s-the-longest-you-ve-stayed-at-a-job-you-were-unhappy-with-50n3 %}

Granted not every day can be sunshine and lollipops, but let's hear some stories of contentment.

**How long have you stayed at a job where you were *happy*?**

For those currently in a "happy place", what keeps you there?

For those who chose to move on from a good workplace, what drove that decision?
What was your win this week?
Tags: discuss, weeklyretro
Published: 2019-06-07 15:01:20

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

Looking back on your week -- what was something you're proud of? 

💪
💪💪
💪💪💪

All wins count -- big or small 🎉

Examples of 'wins' include:

- Getting a promotion!
- Starting a new project
- Fixing a tricky bug
- Cleaning your house...or whatever else that may spark joy 😄

Happy Friday!
How do you measure code quality / engineering team performance?
Tags: help, codequality, teamwork, discuss
Published: 2019-06-07 14:56:59

---
title: How do you measure code quality / engineering team performance?
published: true
tags: help, codeQuality, teamwork, discuss
---
I've been looking into this problem for a while now and here are the few things that I came up with(however NaN of them feel quite right):

1. Test code coverage
2. Amount of bugs / Amount of features (%)
3. AVG Page load time (assuming we talking about some sort of website)
4. Cyclomatic complexity (spaghettines  of the code) should be small 
5. Essential Complexity (unnecessary loops and ifs)-should be small 

So the question is how do you guys do it? and at what point (every 2weeks/ on the time of release/ every 1/2 year /every day/ every commit/ once in a blue moon)
(Tech) Writing experiment
Tags: writing, beginners
Published: 2019-06-07 14:14:42

---
title: (Tech) Writing experiment
published: true
description: 
tags: #writing, #beginners
---

One of my favorite YouTubers, Kate Cavanaugh (a novelist) has a series where she tries writing routines of famous authors, learns what works best for her, and incorporates it into her own process. I love the concept so much that I did my own (tech) writing experiment! Here's my attempt at Kate's routine. 

{% youtube i9ee_XfyAbc %}

Let me know if you try other people's routines, and if yes, what's your favorite one so far?
MacOS won’t be shipped with scripting languages in the future. (Python/Ruby/Perl/etc)
Tags: macos, python, perl, ruby
Published: 2019-06-07 13:44:42

---
title: MacOS won’t be shipped with scripting languages in the future. (Python/Ruby/Perl/etc)
published: true
description: 
tags: #macos #python #perl #ruby
---

I just saw [this article](https://www.macobserver.com/analysis/macos-catalina-deprecates-unix-scripting-languages/). I’m just passing this along in case you didn’t  know like me. **I recommend reading that article** but the short and sweet version is that MacOS 10.15 (Catalina) has depreciations and 10.16 will not be shipped with scripting languages. 

As they've quoted in the article, I'll share the important part from the [MacOS 10.15 beta release notes](https://developer.apple.com/documentation/macos_release_notes/macos_10_15_beta_release_notes):

> Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app. (49764202)
>
> Use of Python 2.7 isn’t recommended as this version is included in macOS for compatibility with legacy software. Future versions of macOS won’t include Python 2.7. Instead, it’s recommended that you run python3 from within Terminal. (51097165)

I was a little shocked to see this but then also not shocked at the same time. 

Any thoughts?
Wordpress concepts: Action and Filter hooks, power and foundation of Wordpress
Tags: wordpress, tutorial, beginners, webdev
Published: 2019-06-07 14:05:31

Let me be frank, you can't be a wordpress developer without knowing Wordpress hooks. Now what are wordpress action and filters? There's a lot of good and detailed articles out there about Wordpress action hooks and filter hooks and I'm not gonna repeat what they said before. 

<h4>Some cases to use hooks </h4> 
Since I'm not gonna write codes at this moment, so I think the best way to clear this concept for you is showing some examples. 
<strong>Wordpress Filter Hooks </strong>
Let's assume that you want to add some text below every post content. Basically you are changing a content, this is what a filter hook means; You can change a content. But how? 
Wordpress developer references or old Wordpress codex are great resources, they have all the hooks you need with detailed information and some examples. You just have to search for the right hook. 
Back to our example, You just need to search for something like:<em>Wordpress post content filter</em> 
These searches will probably lead you to Wordpress official docs and there you can find some good examples to use it. 

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

This was the filters, you can use it to change some specific data that the filter defined for. Now let's assume that you are developing a plugin and you want to let people to change some data in this plugin. This is something possible and very standard too, you can define some filters for the data you want and another one or even yourself will be able to hook into that filter and change the data. You can find more about this at <a href="https://developer.wordpress.org/plugins/hooks/custom-hooks/">Wordpress developer site</a>. 

<strong>Wordpress Action Hooks </strong> 
You want to go straight to the examples or define it with some gibberish words? OK! 
You want to be notified <strong>whenever</strong> a new post publishes on your site. So you want to execute a code when a certain thing happens, right? But how Wordpress knows that when to run your code? 
You use action hooks at this cases. Just like the filter hooks example, you should know what action you want to use. Search Wordpress developer site with keywords like this: <em>after post publish action</em>
Then you got some examples and codes that is very clear and you can understand it. 
You can have your own actions too. This way you can open an easy way for the people and of course future you to easily add code in certain places of your code. You can find more about this at <a href="https://developer.wordpress.org/plugins/hooks/custom-hooks/">Wordpress developer site</a>. 

So, do you think the hooks are the main power of Wordpress? I'll be glad to hear or ideas. 
 
<strong>Previous Article:</strong> <a href="https://dev.to/amirition/wordpress-concepts-series-be-a-good-wordpress-developer-1m3n">Wordpress concepts series: be a good wordpress developer </a>
<strong>Next Article</strong>: Who knows?
Single page application security ( for Typescript projects) 
Tags: typescript, security, authorization
Published: 2019-06-07 13:40:51

[**@zainabed/soteria**](https://github.com/zainabed/web-security-soteria) is Single page application security, It reduces amount of HTTP server calls by providing client side authorization. It provides APIs to validate user permissions against the secure area of application without consulting with server APIs.
These validation can be performed on application routing or on REST API calls.

It is an implementation of `@zainabed/security` specification APIs.
100 Roasts
Tags: showdev, discuss, javascript, webdev
Published: 2019-06-07 14:04:40

Hi!

I made a little side project where you can get feedback by 20 fresh eyeballs for your website or app. And even by 40 fresh eye balls. They will tell you why they wouldn't use your service and what's ugly.

What do you think, would you give it a try?

P.S: Private Emails are much much harsher than the videos, there I tell you why I wouldn't use your product and all the things I find ugly.

Have a nice day

https://feedbacktoaster.com/?ref=dev
Building Blog with Bocadillo - Installation
Tags: python, programming, bocadillo, tutorial
Published: 2019-06-07 13:39:50

I [published](https://dev.to/aligoren/bocadillo-yet-another-python-framework-57ii) a post about Bocadillo before.

In this series, we'll build a simple blog with Bocadillo.

I hope we can succeed.

**GitHub Repository for this series**: [https://github.com/aligoren/bocadillo_blog](https://github.com/aligoren/bocadillo_blog)

-----

## Basics

### Virtualenv

We will use virtualenv to isolate our dev environment.

```bash
mkdir bocadillo_blog

cd bocadillo_blog

virtualenv .

# after finish installation

source bin/activate
```

Our command line should be like that;

```bash
(bocodillo_blog) [YOUR_USER@YOUR_USER-pc bocodillo_blog]$ 
```

### Installation

You can install bocadillo using the following command

```bash
pip install bocadillo
```

### Extra Installations

You will need sessions to authentication. We will write a decorator for this.

```bash
pip install bocadillo[sessions]
```

## Bocadillo Requirements

You will need Python 3.6 or above versions to use Bocadillo.

## Requirements File

We assume deploy our blog app to our server. We need to add all dependencies into the requirements file.

```bash
pip freeze > requirements.txt
```

### Our First App

We'll create a file called **app.py** using our favorite editor. I prefer Visual Studio Code but you can use yours.

We'll change our project structure later.

```python
from bocadillo import App, configure

app = App()
configure(app)

@app.route("/")
async def index(req, res):
    res.text = "Hello World!"
```

That's all for now. Let's run this command to serve our application.

```bash
uvicorn app:app --reload
```

You don't need to install uvicorn. It's already installed with bocadillo. We used **--reload** flag, because we want to avoid always restart the application by manual.

Our app serving on port 8000 now. Let's open `http://localhost:8000` on our browser.

Yes! we did :)

We saw our **Hello World!** message.

![](https://thepracticaldev.s3.amazonaws.com/i/cml2isxioj7yk2ie84nj.png)

This was the first part of our series.
Why Coding and How To Get Started
Tags: girlswhocode, learning, coding, whycoding
Published: 2019-06-07 13:28:37

---
title: Why Coding and How To Get Started
published: true
description: Girls Who Code answers the question of "Why Coding" and my thoughts on how we learn
tags: Girls Who Code, Learning, Coding, Why Coding
---

Last night we hosted our first Summer Session of Girls Who Rock and Code at Hocking College.  Reshma Saujani and her team did a great job making a book that is a great and entertaining read introducing the basic of what coding is and answers the question of "Why Coding".  If you're looking for a great way to get involved w/ the community of coding and make an impact on those around you I HIGHLY recommend this organization.  We've been hosting it here at Hocking College and it's such a great way to be re-inspired and for my computer science students who volunteer with the organization it looks great on their resume and the experiences they are gaining are invaluable!  

Here's the link if you're looking to host or know a girl who'd love to join a chapter in your area https://girlswhocode.com/!
Creating a ZFS Image of a MySQL Data Directory
Tags: zfs, mysql
Published: 2019-06-07 13:18:27

---
title: Creating a ZFS Image of a MySQL Data Directory
published: true
description: Creating a ZFS image for backup is easier than you might think.
tags: ZFS, MySQL
---

_**Notes**: I wrote this documentation around 2013 as internal documentation at [Weever Apps](https://weeverapps.com/) for setting up RAID-Z as a method of making very quick backups of MySQL. Since we no longer use this setup and the documentation will never be used again, I felt it might be a good idea to post it out there for those who might find some use in it. Using RAID-Z for MySQL was amazing, and never failed us, and allowed hourly snapshot-based backups with no downtime. We've since moved to AWS RDS instances though._

_This will be part of multiple posts that combined will allow one to build a RAID-Z setup for MySQL. Or, at least it used to be able to! While this is geared towards Azure, I'm sure it would work anywhere._

_As I add more parts over the next few days I'll add links here._

# Article series

1. [Installing ZFS on CentOS](https://dev.to/rgeraldporter/installing-zfs-on-centos-2fkl)
1. [Creating a RAID-Z Drive for MySQL with ZFS on CentOS](https://dev.to/rgeraldporter/creating-a-raid-z-drive-with-zfs-on-centos-3484)
1. [Setting up RAID-Z for use in a MySQL Master-Master Replicator Pattern](https://dev.to/rgeraldporter/setting-up-raid-z-for-use-in-a-mysql-master-master-replicator-pattern-4eme)
1. **Creating a ZFS Image of a MySQL Data Directory**

# Instructions

Creating a ZFS image for backup is pretty easy.

First, a ZFS snapshot must exist. If one does not already, create one. 

If this is for MySQL and the tables in MySQL are using MyISAM, make sure to either turn off the server briefly, or, lock the tables momentarily. In my experience these locks just delay writes until unlocked, and snapshotting is _surprisingly_ quick in ZFS.

```sh
FLUSH TABLES WITH READ LOCK;
```

This example will assume you're grabbing the MySQL data directory, which would be stored in a tank called `sqlstorage`, with filesystem `data`. Adjust if your setup is differently named.

```sh
zfs snapshot sqlstorage/data@now
```

Now we can unlock the tables or start the MySQL server up again.

```sh
UNLOCK TABLES;
```

All we need is one command to send this snapshot to a file. Depending on the size of the file system, this could take a while.

```sh
zfs send sqlstorage/data@now >/tmp/sqlstorage-backup.zfs
```

_Is something badly out of date? Did this work for you? Please post a comment to help others who might use this for guidance._
CAN I DUPLICATE A FRESH REACT APP FOR ANOTHER APP?
Tags: help, react, javascript
Published: 2019-06-07 13:17:43

Hello everyone, Just recently i started learning React. From a background of writing html, css and vanilla javascript, React can be overwhealming. The download process takes longer than i expected and includes a ton of files which can be pretty intimidating for a beginner.

I thought to myself, can i just duplicate a new react app i just created with create-react-app command and use it to do other projects? i tried it and it actually worked but are there any outcomes from doing so? Thank you
VOV.CSS — The Intro
Tags: animation, css, libraries, webdev
Published: 2019-10-28 08:11:16

---
title: VOV.CSS — The Intro
published: true
date: 2019-06-07 13:06:19 UTC
tags: animation,css,libraries,web-development
canonical_url: https://medium.com/@vaibhav_tandon/vov-css-the-intro-5012882af4b3
---

### VOV.CSS — The Intro

![](https://cdn-images-1.medium.com/max/800/1*GlLtgvj01KnfGEjHnDNswQ.png)<figcaption>Image from nicolapietroluongo.com</figcaption>

For implementing small animations we usually have to write many lines of code and being one of the lazy ones, I am not at all interested in writing the same CSS again and again for my all projects.

After facing such problems, I have an idea to create my own animation library. Yes, I know there are thousands out there, so why not add my own.

It is a small CSS library based on the implementations of the classes, all of the code is written using keyframes and thus easy to handle and easy to use.

[VOV.CSS](https://vaibhav111tandon.github.io/vov.css/) is really simple to use, all you need to do is to add the CSS files to your HTML file.

OR

You can also add the CDN in the head section of your HTML file.

{% gist https://gist.github.com/vaibhav111tandon/11e6b6511f3f6151defad1db218284dc.js %}

After adding the CDN link or vov.css file to your HTML file, just add classes to your element’s class attribute, It is that simple.

Like this,

{% gist https://gist.github.com/vaibhav111tandon/b38a679760565705600276efd27c54e6.js %}

**vov.css** consists of approx 55+ different types of animating classes and still counting in [https://github.com/vaibhav111tandon/vov.css](https://github.com/vaibhav111tandon/vov.css).

Here are some of my favourite animations,

![](https://cdn-images-1.medium.com/max/859/1*tffsvmDwVn4MwEYcGXW8Ow.gif)<figcaption>roll-out-left</figcaption>

![](https://cdn-images-1.medium.com/max/792/1*twegEL9evVYDWWz7iN4bGA.gif)<figcaption>shake-vertical</figcaption>

![](https://cdn-images-1.medium.com/max/720/1*c_ozaXKJ3_2bK3WpcYj4uw.gif)<figcaption>blur-out</figcaption>

You can do a whole bunch of other stuff with vov.css when you combine it with jQuery or add your own CSS rules which I use on a daily basis to make websites more interactive and beautiful.

Thank you
IGTV Web Dev Coffee Talk with me
Tags: verticalvideo, contracting, webdev, coffee
Published: 2019-06-07 12:44:51

I've started an IGTV channel where every Friday I talk about web development. Currently, I'm talking about contracting, but in the future, I might expand to other topics such as different technologies, new projects and more.

My main profile has a bunch of Crossfit and motivational stuff, but this might change as I figure out what I actually want out of my IG channel. Any suggestions would be appreciated, and if you have any questions or ways to improve, I'm all ears.

If you want to skip over the Crossfit stuff and you only want to see tech stuff from my IGTV channel then follow me on here and I'll keep you posted. Otherwise, you can follow my IG profile and find out more about my life in general.

Here's a link straight to my IGTV content https://www.instagram.com/mike_d_brooks/channel/
Howto: Drop-down list Jira's components in Jenkins 
Tags: jenkins, jira, howto, regex
Published: 2019-06-07 12:21:02

In the previous receipt about [Drop-down list for values](https://dev.to/malexe/howto-drop-down-list-for-values-2aop) we learned how-to choice any predefined project.
At this receipt I've tell about how to create drop-down list for choosing component's names by regex from Jira via API.

Prerequisites: 

- [Active Choices plugin](https://wiki.jenkins.io/display/JENKINS/Active+Choices+Plugin)
- Jira credentials

Step 1: In job configuration add parameter *Active Choice Reactive Parameter*

Step 2: Set name for your parameter (for example *COMPONENT*)

Step 3: Select Groovy script and add next groovy-code
```groovy
import groovy.json.JsonSlurperClassic
import java.util.regex.*

def regexLine = "(((my|other)-(int|sys|bpl|pl|stp|tst)-([a-z,0-9,-]*)))"
def jiraUrl = "http://jira.domain.org"
def jiraProjectKey = JIRA_PROJECT

def juser = "JenkinsJiraUser"
def jpass = "PasswordOfJenkinsJiraUser"
def url = "curl -u ${juser}:${jpass} ${jiraUrl}/rest/api/2/project/${jiraProjectKey}/components"
def json = url.execute().text.replaceAll("\r\n", "")
def data = new JsonSlurperClassic().parseText(json)
def names = []
data.each{ component->
    if (component) {
        Matcher componentsMatcher = Pattern.compile(regexLine).matcher(component.name)
        if( componentsMatcher ) {
            names += component.name
        }
    }
}
return names
```

Step 4: Set to "Referenced parameters" *JIRA_PROJECT*

Step 5: Enjoy!