teleren/devto huggingface dataset:
Perl Weekly Challenge week #1 challenge #2: FizzBuzz
Tags: perl6, challenge, coding, oneliner
Published: 2019-03-29 17:57:08

---
title: Perl Weekly Challenge week #1 challenge #2: FizzBuzz
published: true
description: The classical fizzbuzz problem
tags: perl6, challenge, coding, oneliner
---

Here goes [the second first-week challenge](https://perlweeklychallenge.org/blog/a-new-week-a-new-challenge/).

> Write a one-liner to solve the FizzBuzz problem and print the numbers 1 through 20. However, any number divisible by 3 should be replaced by the word ‘fizz’ and any divisible by 5 by the word ‘buzz’. Those numbers that are both divisible by 3 and 5 become ‘fizzbuzz’.


![That's me with another Buzz, Lightyear Buzz](https://thepracticaldev.s3.amazonaws.com/i/jz19hhzxqmza9hi97872.jpg)

OK, here goes the solution. [Perl 6](https://perl6.org) being a functional language, it was not extremely difficult:


```perl6
say (1..20 ==> map( { ($_ == 15)??"FizzBuzz"!!$_ } ) ==> duckmap( -> Int $_ { ($_ %% 5 )??"Buzz"!!$_} ) ==> duckmap( -> Int $_ { ($_ %% 3 )??"Fizz"!!$_} ));
```

First thing is that I'm using the [*rocket* operator](https://docs.perl6.org/routine/==%3E) just for the hell of it. It nicely illustrates how the thing goes, in what direction and what it does. It's actually syntactic sugar for some functions that can be used as methods or take their "target" (note the pun on rocket) as a second argument. `map` and `duckmap` are such functions (and most *functional* functions too). So it's quite adequate. So the three stages of the rocket do this

* Get 15 out of the way in the firs stage
* In the second stage, we have a diverse list: numbers and one string. A simple `map` will have to check first if it's number, and then check if it's divisible. There might be some simple way of doing that, but it's much simple to use the [wonderful `duckmap`](https://docs.perl6.org/routine/duckmap), which only maps if it's a duck, hence its name; it passes through if it's not. So let's create a [pointy block](https://docs.perl6.org/language/control#for) that can only be applied to Ints, which are substituted.
* Third stage could be probably golfed down to the second, but it's a rocket and it needs to fly, so let's do the same for the third stage.

Here's what it prints

    (1 2 Buzz 4 Fizz Buzz 7 8 Buzz Fizz 11 Buzz 13 14 FizzBuzz 16 17 Buzz 19 Fizz)

Nice, ain't it? Check out the [Perl Weekly Challenge site](https://perlweeklychallenge.org/blog/a-new-week-a-new-challenge/) for more wonderful solutions in Perl and Perl 6!

Also check out [the first weekly challenge, translating and counting](https://dev.to/jj/perl-weekly-challenge-1-translate-letters-and-count-4cdf)
Perl Weekly Challenge #1: translate letters and count.
Tags: pws, perlweeklychallenge, assignment, perl6
Published: 2019-03-29 17:35:00

---
title: Perl Weekly Challenge #1: translate letters and count.
published: true
description: Solving the first weekly challenge.
tags: pws, perl weekly challenge, assignment, perl6
---
This is [the first part of the first perl weekly challenge](https://perlweeklychallenge.org/blog/a-new-week-a-new-challenge/). 

![No time! No time!](https://thepracticaldev.s3.amazonaws.com/i/vpk1ffqle21qtsf1jr3t.jpg)
> I haven't looked at the other solutions that have been published, but I'm pretty sure they'll go along these lines, at least in Perl 6.

Here's the challenge:

> Write a script to replace the character ‘e’ with ‘E’ in the string ‘Perl Weekly Challenge’. Also print the number of times the character ‘e’ is found in the string.

This was easy and almost straight out of the [Perl 6 documentation: `StrDistance`](https://docs.perl6.org/type/StrDistance). 

```perl6
my $changes = (my $pwc = ‘Perl Weekly Challenge’) ~~ tr/e/E/;
say $pwc;
say +$changes;
```

It could be golfed, but also ungolfed. Basic trick here is that I'm defining a variable `$pwc` on the fly so that I can apply [`tr`](https://docs.perl6.org/syntax/tr$SOLIDUS$SOLIDUS$SOLIDUS) to it. I could use [`.trans`](https://docs.perl6.org/routine/trans), because in Perls there is always more than one way to do it, but then I couldn't get the secondary effect of counting changes. I can do that with tr, which has the (Rakudo-only, whatever that means, because there's only one Perl 6 compiler, and that's Rakudo) nice secondary effect of returning an `StrDistance` object that can, in number context, return the number of changes. That's why we hold the changed string in `$pwc` and the *change object* in $changes. The last line is number-contextualized by putting a `+` in front.

You want to get your chops in any of the Perls, head to https://perlweeklychallenge.org and start coding!
Contributors Wanted: Night Mode/Themes on DEV
Tags: contributorswanted, opensource, meta, css
Published: 2019-03-29 17:27:55

We recently made night mode an option for the [dev.to](/) interface. You can change to the them in [/settings/misc](/settings/misc).

It's coming along nicely, but there are still a few places here and there that still need to be updated. If you come across anything that doesn't quite look right, we welcome pull requests.

### You can see existing issues tagged night mode [here](https://github.com/thepracticaldev/dev.to/issues?q=is%3Aissue+is%3Aopen+label%3Anightmode).

In order to make a change, find the appropriate line in SCSS and add a line right after with a CSS variable like this:

```scss
color: $medium-gray;
color: var(--theme-secondary-color, $medium-gray);
```

Doing this both ways ensures browser compatability. We may be able to remove the duplication over time.

This is the current list of CSS variables we have for night mode:

```scss
--theme-background: #161f2b;
--theme-color: #fff;
--theme-secondary-color: #cedae2;
--theme-top-bar-background: #141d26;
--theme-top-bar-color: #fff;
--theme-top-bar-search-background: #424a54;
--theme-top-bar-search-color: #fff;
--theme-top-bar-write-background: #00af81;
--theme-top-bar-write-color: #fff;
--theme-container-background: #27374c;
--theme-container-accent-background: #384b66;
--theme-container-background-hover: #37475c;
--theme-gradient-background: linear-gradient(to right, #293d56 8%, #282833 18%, #293d56 33%);
--theme-container-color: #fff;
--theme-container-box-shadow: none;
--theme-container-border: 1px solid #141d26;
```

Basically those are the variables available to be placed within the rest of our SCSS

Currently we are focused solely on night mode, but we are building this so that themes can be defined more dynamically in the future, in this vein:

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

In order to test this locally, you'll have to get the app up and running, but if you want to make speculative PRs without running the app locally, we wouldn't be opposed to that.

Thanks a lot, happy coding!
DevOps strategy - the secret to high-performing IT teams
Tags: devops, softwaredevelopment
Published: 2019-03-29 16:52:58

---
title: DevOps strategy - the secret to high-performing IT teams
published: true
description: Faced with slow, risky releases and a rift between operations and development, companies like Amazon, Google, and Netflix have adopted a deliberate approach to DevOps. Dive in and check what DevOps strategy will be right for you.
tags: DevOps, software development
cover_image: https://www.mindk.com/blog/wp-content/uploads/2019/03/jefferson-santos-450403-unsplash-1920x1080.jpg
canonical_url: https://www.mindk.com/blog/devops-strategy/
---
High-speed innovation allowed startups like Amazon, Google, and Netflix to dominate markets. Yet at some point, they all faced issues familiar to established companies. Slow, risky releases and a rift between development (dev) and operations (ops) pushed them to adopt a radical DevOps strategy.

Before the advent of DevOps, companies had separate “walled-off” teams of developers, testers, and operations. All too often they had conflicting goals and little insight into other “camps”.

Throwing issues over the wall to another team creates bottlenecks that slow innovation. In the world of Agile development and SaaS products, this can destroy your competitiveness.

[Continue reading...](https://www.mindk.com/blog/devops-strategy/)
True customer focus includes firing customers. Here’s why
Tags: softwaredevelopment, customers
Published: 2019-03-29 16:50:45

---
title: True customer focus includes firing customers. Here’s why
published: true
description: Let's look through customer focus in a different light and see what many of customer-centric companies businesses overlook — when and why you should reject some of your product users.
tags: software development, customers
cover_image: https://www.mindk.com/blog/wp-content/uploads/2019/03/photo-1534492242690-0c23c91413a9.jpg
canonical_url: https://www.mindk.com/blog/customer-focus-includes-firing-customers/
---
When you’ve just released your digital product, under the theme of customer focus you’re trying to capture whoever comes through the front door. We know it may sound crazy, but to better serve your customers you need to find the “right” ones, and reject others.

For most owners of small and medium businesses, there’s a subconscious pressure that they have to be customer-centric in everything they do. Oftentimes, going through the rush to make more sales and keep pace with the customer desires, businesses get into unpleasant situations.

The reality of customer-focused strategy is that you need to build relationships which are rewarding for both client and your business. This means that you need to maintain business hygiene by better serving the tribe of product fans and partners and getting rid of “toxic” clients.

Focusing on the right customers frees up resources and provides better care for your best сlients.

[Continue reading...](https://www.mindk.com/blog/customer-focus-includes-firing-customers/)
The Pandas Library for Python
Tags: python, tutorial, beginners
Published: 2019-03-29 16:31:03

---
title: The Pandas Library for Python
published: true
description: Getting Started With Pandas
tags: Python, tutorial, beginners, 
---

Zachary Wilson wrote a great post on getting started with Pandas, a powerful but straightforward data analysis package for Python. Full article [here] (https://kite.com/blog/python/pandas-tutorial). :bar_chart:
What was your win this week?
Tags: discuss, weeklyretro
Published: 2019-03-29 15:03:40

---
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
---

Happy Friday!!

Looking back at your week, what was something you're proud of?

All wins count -- big or small!

Examples of 'wins' include:

- Drinking less caffeine
- Contributing to OSS
- Fixing a trickster bug
- Watering your plants...or whatever else that may spark joy 😄 🎉
22-2222-22
Tags: dev, stupid, 2
Published: 2019-03-29 14:43:01

---
title: 22-2222-22
published: true
tags: dev, stupid, 2
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zxkqd08z6ejenjtu1oci.png
---

Opened my dashboard just now and that what I saw there =) 

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

Thanks for following, guys!
Kubernetes First Time Project - Auto-Restarting
Tags: kubernetes, javascript
Published: 2019-03-29 13:53:57

---
title: Kubernetes First Time Project - Auto-Restarting
published: true
description: My first kubernetes project to test out the auto-restarts
tags: kubernetes,javascript
---

# Kubernetes First Time Project - Auto-Restarting
Today I gave kubernetes a shot for the first time. I was interested in it's auto-restart feature, so I wrote a simple node.js program

```javascript
// application that randomly dies, and see how good kubernetes is at restarting it.
console.time('alive');
setTimeout(() => {
  console.timeEnd('alive');
  process.exit(0);
}, Math.random() * 60000);
setInterval(() => {
 console.log('feels good to be alive') 
}, 100)
```

I downloaded minikube, and virtual box, and ran

```bash
minikube start
minikube dashboard
```

Then I made a super basic Dockerfile

```docker
FROM node
ADD randomly-die.js .
CMD ["node", "randomly-die.js"]
```

Now we've got to build this Docker image, and then create a deployment with kubernetes

```bash
eval $(minikube docker-env)
docker build -t randomly-die:1.0 .
kubectl run randomly-die --image randomly-die:1.0 --image-pull-policy=Never
```

Now we can check the deployments section of the dashboard and see that we have a deployment named randomly-die

![minikube dashboard image](https://github.com/micahriggan/blog/raw/master/k8-uptime/dashboard.png "minikube dashboard")

From here we can see we have a replica set, and a single pod, which is running our container

Now if we check the pod logs we can see we're up and running

```
...
feels good to be alive
feels good to be alive
feels good to be alive
feels good to be alive
feels good to be alive
feels good to be alive
feels good to be alive
feels good to be alive
feels good to be alive
feels good to be alive
alive: 4856.096ms
```

# Scaling
Kubernetes makes it pretty easy to scale up how many containers are running. For my final test I wanted to see it run 10 randomly-die containers, and watch it restart them

```bash
kubectl scale deployment --replicas=10 randomly-die
# deployment.extensions "randomly-die" scaled
```
# Conclusion
Now we've got 10 containers running that randomly die, and we can watch the "restarts" counter increment as kubernetes restarts them.
![minikube scale image](https://github.com/micahriggan/blog/raw/master/k8-uptime/scaled.png "kubernetes scaled up")

Pretty cool!
Advocating internally for new technologies
Tags: career, beginners, programming, discuss
Published: 2019-03-29 13:06:32

---
title: Advocating internally for new technologies
published: true
description: Making your team adopt new technologies is never easy. What attitudes can raise your chances of success?
tags: ["career", "beginner", "programming","discuss"]
---


**Changing the status quo** and adopting new technologies is never easy. Whether we are talking about a new database, library or even way of approaching your problems, you should know what your are in for.

> Of course, your difficulties will be very different depending on the size and culture of your team! 

Do you even want to get started ?
 - **What are the Benefits ?** Whether it is ease of development, transparency, adaptability, performance... A case has to be made.
- **Knowledge :** you should know the manual/tutorials inside and out. For bleeding edge projects, you should have read some of the source.
- **Experience:** before you make everyone adopt something, you really should have toyed with it and it should have proved itself in a non-critical project. Ask around what people think.
- **Trust/Authority and commitment**: can you push this through? 

What will make the project successful?
- [Running code and rough consensus](https://en.wikipedia.org/wiki/Rough_consensus): **do** things, write code, take responsibility, and steer discussions away from uninformed opinions and towards what brings the most value.
- Don't break things *without reason*. Provide guidance and automation to update/migrate downstream clients/users. **Backward compatibility** is boring but everybody will thank you for it. 
- **Onboarding:** give assistance setting things up. Give advice about best practices. Offer solutions, do the work.
- **Support:** if you've built a consensus and brought people on board, don't waste everything. Proactively check-in with your colleagues, ask how things are going. Treat your your coworkers as **clients**.

At some point you will need to evaluate your project:
- **Be unbiased**: consider all options, give fair assessments, be transparent, and always keep in mind what is most important to your team or users.
- **Feedback**: is huge. Only if you listen can you improve your work, or cut your losses early.


Personally, in every **new project** I try to do two things like I've never done before. Never more, rarely less than two. It's great for learning, and soon you learn to judge things better. Changing **existing projects** and workflows is much more challenging: be gentle 😌.

> Did you like this post? Read more at https://talk.shapescience.xyz :)
For Me, Coding Is Kinda Like Baking
Tags: coding, baking, beginners, programming
Published: 2019-03-29 12:59:33

---
title: For Me, Coding Is Kinda Like Baking
published: true
description: 
tags: #coding #baking #beginner #programming
---

![Chocolate Chip Cookies](https://thepracticaldev.s3.amazonaws.com/i/vc8uxa769tbkg1dex58o.jpg)

I can’t tell you the first recipe I tried, though it was probably spiced drop raisin cookies (I will defend them as being good). My mother guided through the recipe with a patient hand while listening to gospel music using a mixer that has survived at least six presidents (I will make sure to get that mixer in her will). 

For awhile, I thought all would wanted to do was bake until I got into code. 

Now, don’t get me wrong, I am by no means an expert (to be honest that is exceedingly rare to be in this field), but I’ve noticed that there are some similarities in how one could a approach a code prompt to a baking recipe. 

Take Chocolate Chip Cookie Bars for instance (probably one of the easiest recipes for me to do). One thing is that the ingredients could be equal to the variables that you would have to set at the start of the recipe/program. Then you could have an overall function called `makeCookies()` with smaller ‘instructions’ inside of the function. One of the functions could be mixing the butter, sugar, eggs, and vanilla extract together with a while loop for assembling your dry ingredients. Another function could be a setTimeout for oven time with a for loop to check on the cookie bars (usually around 18 out of 22mins if using a 18” x 12” x 3/4” baking pan) with probably another while loop for clean up. 

I figured that when one first gets into code, it would do one some good to compare it to something else and for me it’s baking.
Attacking phone through BT headset
Tags: security, project
Published: 2019-03-29 12:12:36

---
title: Attacking phone through BT headset
published: true
description: Security conscious people don't use random USB sockets to charge their phones. Or at least use charging cable with data pins disconnected. But what about headsets? 
tags: security, project 
---

I sometimes have these security research project ideas. They are too long to rweet and I'm not on security forums where to post them. Since this is my software engineering blog, I will post them here.

As I was charging my [Bluetooth headset](https://en-fi.sennheiser.com/pxc-550-wireless), I remembered how you shouldn't use unknown USB ports to charge your devices or at least use charging cable that doesn't have USB pins connected. In this case I was using USB charger connected to wall socket. If I don't trust that charger, I shouldn't use it at all. (Interesting side note: If you don't trust Huawei, why do you trust cheap Chinese bulk manufacturers?) 

But it's just a headset, right? What use attacker could possibly have by compromising it? Well, the headset interacts with phone through bluetooth. It could attack the phone by using vulnerability in its bluetooth stack. That could be an interesting project. Write a PoC that uses vulnerability in headset's USB stack to inject code that uses vulnerability in phone's BT stack to inject code into phone.

I would use cheap headset because you probably need to take it a part to find out the hhardware and software it uses. Cheap headsets also are more likely to have poor security.
Should you be perfect?
Tags: career, productivity, tips, discuss
Published: 2019-03-29 11:56:40

---
title: Should you be perfect?
published: true
description: I was able to learn from failed projects by shipping them
tags: career, productivity, tips, discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/i3acgmtjbmf1o2chim09.png
canonical_url: https://sunnysingh.io/blog/perfection
---

> This article was originally published to [my newsletter](https://sunnysingh.io/news).

In my [personal branding article](https://sunnysingh.io/blog/personal-brand), I talked a lot about personal branding and the importance of being consistent. But I'm sure that some of you might be thinking...

> Consistency is great and all Sunny, but I have high expectations. I value quality over quantity.

I believe that those expectations are important, but not in the short term. It takes time to reach perfection, but in that process you will have to get better at your craft. How do you do that? By shipping more.

## Just ship it

_(you know, like [Nike's slogan](https://youtu.be/Fq2CvmgoO7I))_

The indie maker community places a lot of importance on shipping, meaning to release whatever you're working on to the public as quickly as possible. This is great advice for getting real world validation of your idea and have something to show for.

To actually ship something is harder, especially for those that deem perfection with high regard. But take this comic that I recently saw on Gary Vaynerchuk's Instagram:

[![View comic](https://thepracticaldev.s3.amazonaws.com/i/jrpykx274r635aue9ay9.jpg)](https://www.instagram.com/p/BsT4fP8F-pp/)

Perfection is an excuse that keeps you away from shipping. There's no shame in polishing a release to ensure that users don't experience software bugs or simple grammar mistakes, but after a certain point, you just have to put it out there.

I've learned a lot from failed projects. Imagine though if I took a lot longer to release them or even worse, not have released at all. There would be no real world feedback, experience, and lessons that I could use on future projects.

## Building a brand with content

If you want to learn how you _should_ be marketing on social media with **native content**, and not just posting links to your preferred platform, check out my podcast episode about [building a brand with content](https://sunnycommutes.fm/episodes/61-building-a-brand-with-content-zl5wOK).

{% youtube 9zwrbWcWm9g %}

---

> Perfection is an excuse that keeps you away from shipping.

So **no**, you don't need to be perfect. Keep improving and just ship it!
Don't name your global JavaScript function 'clear'
Tags: javascript, functions
Published: 2019-03-29 10:49:03

---
title: Don't name your global JavaScript function 'clear'
published: true
description: Don't name your global JavaScript function 'clear'
tags: javascript, functions
---

![](https://thepracticaldev.s3.amazonaws.com/i/b396ac8c3pp0r7ph40rk.jpg)

_Originally posted on [my blog](http://www.nikola-breznjak.com/blog/javascript/dont-name-global-javascript-function-clear/)_

## TL;DR

Same as the title, don't name your global JavaScript function `clear`.

## TL;DR

I learned the hard way not to use `clear` as the name for my global JavaScript function.

Given the example below:

```
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Test 1</title>

    <script>
        function clear() {
            document.getElementById('result').innerHTML = '';
        }
    </script>
</head>

<body>
    <button id="clear" onclick="clear()">Clear</button>
    <div id="result">Testing</div>
</body>

</html>
```

and clicking the `Clear` button, the `Testing` text will just not be removed.

I found this very cool [StackOverflow explanation](https://stackoverflow.com/questions/7165570/is-clear-a-reserved-word-in-javascript) of why is that. The gist of it is that this way the [document.clear](https://developer.mozilla.org/en-US/docs/Web/API/Document/clear) function is being called, and simply renaming it to something like `clearResult` works fine.