teleren/devto huggingface dataset:
Pandas tools you didn't know you needed, putting it together: groupby+from_records
Published: 2020-03-19 14:55:29


Say we are trying to fetch unique instances of several conditions: 
```python
index_cols = 'brain_region', 'stim_type', 'frequency', 'phase_delay_frac', 'stim_amplitude', 'phase_type', 'brain_region'
```
Each of these dataframe columns contains several unique entries repeated multiple times. Eg `brain region` takes the values of `pfc` and `v_hpc`. 
Let's use an example key to examine:
```python
# Fetch an entire day's worth of events:
summary = (SpikePhase * MazeTrials & key).fetch(format='frame').reset_index()
key = dict(fid='bucket_5_m036_1570900150_', single_unit=1, phase_type='theta_hilbert_bessel')
for brain_region in summary['brain_region'].unique():
  for stim_amplitude in summary['stim_amplitude'].unique():
    for phase_delay_frac in summary['phase_delay_frac'].unique():
      for frequency in summary['frequency'].unique():
        for phase_type in summary['phase_type'].unique():
          for stim_type in summary['stim_type'].unique():
             # specify primary key for fetching and populating
             group_key['stim_amplitude'] = stim_amplitude
             group_key['phase_delay_frac'] = phase_delay_frac
             group_key['frequency'] = frequency
             group_key['stim_type'] = stim_type
             group_key['phase_type'] = phase_type
             group_key['brain_region'] = brain_region
# fetch specific to treatment
             spikes_phases = (MazeTrials *
                              * EventRelatedSpikesAndPhases 
                              & group_key
                              ).fetch(format='frame')
```
becomes simply:
```python
# Iterate over indices of interest:
for index, dff in summary.groupby(index_cols):
    # make a dictionary holding values of index
    group_key = {key: value for (key, value) in zip(index_cols, index)}
    # fetch specific to treatment
    spikes_phases = (MazeTrials * EventRelatedSpikesAndPhases & group_key).fetch(format='frame').reset_index()
```
Note the absence of nested for loops! 
Once we have all treatment-specific events, we can do some computation on them within this loop and build the list of computed results. In the last line of the snippet below, we will concatenate them into a dataframe: 
```python
    # ...continued from above
    # do some computation here
    spikes_phases['log_stim_amplitude'] = np.log(spikes_phases['stim_amplitude'])
    # add to our list of dataframes (preallocated outside the loop):
    group_results.append(spikes_phases)
# Concatenate dicts into a dataframe:
group_df=pd.DataFrame.from_records(group_results).set_index(index_cols)
```
The columns of group_df now have our index_cols, original data column, and our computed column:
```python
> group_df.columns
Index(['brain_region', 'stim_type', 'frequency', 'phase_delay_frac', 'stim_amplitude', 'phase_type', 'spike_phase','log_spike_phase'])
```
Show DEV: K8s Slack bot for Helm installs
Tags: kubernetes, slack, showdev
Published: 2020-03-19 14:34:21

It feels so good to be coding again! I used to be a full time dev but I moved into Product Management 4 years ago and I've been yearning to get back coding ever since.

Given the lockdown caused by Coronavirus, I made the decision to spend some time learning Go and it has been a breath of fresh air. I'm also learning the internals of Kubernetes and the ecosystem around it.

In order to stay motivated, I decided to start an open source project called [KubeWise](https://github.com/larderdev/kubewise).

It's a Kubernetes bot which sits in your cluster and listens for Helm installs and upgrades. When it finds one, it sends a message to a Slack channel so people on your team can follow along and understand what is running in the cluster and how it is being used.

In operation, it looks like this:
![Demo of KubeWise working](https://dev-to-uploads.s3.amazonaws.com/i/h637apsi56ehc4p5ua81.gif)

It's super easy to install (thanks to [Helm](https://helm.sh/), which I've been learning all about this week).

Simply [create a Slack bot](https://my.slack.com/services/new/bot), grab the API token, invite it into a channel, then pass the API token to Helm like this:

```shell
kubectl create namespace kubewise
helm repo add larder https://charts.larder.dev
helm install kubewise larder/kubewise --namespace kubewise --set slack.token="<api-token>" --set slack.channel="#<channel>"
```

Amazingly, a few people have noticed this project already and one person even submitted some code. They even said this kind thing:

> I can't believe something doesn't already exist that does exactly this. It's so obviously useful :)

I SWEAR I don't know this person at all!

Anyway, it feels like it's going well so far. If you use Helm, please try the project out. I'd be delighted to receive any feedback at all.
Daily Challenge #208 - Delete Occurrences of an Element
Tags: challenge
Published: 2020-03-19 14:24:46

---
title: Daily Challenge #208 - Delete Occurrences of an Element
published: true
series: Daily Challenge
description: Delete a set number of recurrences of an element. 
tags: challenge
---
Given a list `lst` and a number `N`, create a new list that contains each number in `lst` at most `N` times without reordering. 

For example if `N = 2`, and the input is `[1,2,3,1,2,1,2,3]`, you take `[1,2,3,1,2]`, skip the next 1 and 2 because this would lead to those numbers being in the result more than `N` times. Finally, take 3, which leads to `[1,2,3,1,2,3]`.

`deleteNth([1,1,1,1],2)` // return [1,1]

`deleteNth([20,37,20,21],1)` // return [20,37,21]

###Tests
`deleteNth([20,37,20,21], 1)`
`deleteNth([1,1,3,3,7,2,2,2,2], 3)`

Good luck!
***
_This [challenge](https://www.codewars.com/kata/554ca54ffa7d91b236000023) comes from JustyFY on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Algorithm 202: Falsy Bouncer in 4 Ways
Tags: algorithms, javascript, beginners, falsy
Published: 2020-03-19 14:15:45

A falsy bouncer algorithm is a step by step approach to removing all false or falsy values usually from an array. Falsy values includes: ``false``, ``null``, ``undefined``, ``0``, ``NaN``, and ``""``.

```javascript

falsyBouncer([undefined, 1, 0, 60000, null, NaN, '', "njoku Samson"])
// [ 1, 60000, 'njoku Samson' ]

```
Do you think this is achievable? How can this be done? 

Let me share 4 ways to bounce falsy values from an array.

### Prerequisite
This article assumes that you have basic understanding of javascript's array methods. 

### Let's bounce falsy values from an array using:

* for...of...loop, push()

```javascript
      function falsyBouncer(array) {
        let sanitizedArray = [];

        for (element of array) {
          element ? sanitizedArray.push(element) : sanitizedArray;
        }

        return sanitizedArray;
      }
```

* forEach...loop, includes(), push()

```javascript
      function falsyBouncer(array) {
        let falsyValues = [false, null, undefined, 0, NaN, ""];
        let sanitizedArray = [];

        array.forEach(element => {
          !falsyValues.includes(element)
            ? sanitizedArray.push(element)
            : sanitizedArray;
        });

        return sanitizedArray;
      }
```

* filter()

```javascript
      function falsyBouncer(array) {
        let sanitizedArray = array.filter(element => Boolean(element));

        return sanitizedArray;
      }
```

* reduce()

```javascript
      function falsyBouncer(array) {
        let sanitizedArray = [];

        sanitizedArray = array.reduce((acc, element) => {
          if (Boolean(element)) {
            return [...acc, element];
          } else {
            return acc;
          }
        }, []);

        return sanitizedArray;
      }
```

### Conclusion

There are many ways to solve problems programmatically. I will love to know other ways you solved yours in the comment section.

If you have questions, comments or suggestions, please drop them in the comment section.

> Up Next: [Algorithm 202: Where I Belong in 3 Ways](https://dev.to/ebereplenty/algorithm-202-where-i-belong-in-3-ways-1chk)

You can also follow and message me on social media platforms. 

**[Twitter](https://twitter.com/eberetwit) | [LinkedIn](https://www.linkedin.com/in/samson-ebere-njoku-profile/) | [Github](https://github.com/EBEREGIT)**

Thank You For Your Time.
How do you come up with new side projects? 
Tags: beginners, webdev, discuss
Published: 2020-03-19 14:09:48

---
title: How do you come up with new side projects? 
published: true
description: Side projects are great ways to grow our knowledge and skill, but where do you start? How do you get your ideas for new side projects? 
tags: beginner, web-dev, discuss 
cover_image: https://upload.wikimedia.org/wikipedia/commons/7/7a/Dones_amb_creativitat.jpg
---
_image by By [freepik](https://www.freepik.com/free-vector/character-illustration-of-people-with-creative-ideas-icons_3425186.htm)_

Side projects are great ways to grow our knowledge and skill, but where do you start? How do you get your ideas for new side projects? 

For me, I need someone else's passion to really get into side projects, so my process starts at a hackathon or meetup where I meet someone who wants to do something great.
Dynamic parameters in Go
Tags: go
Published: 2020-02-23 05:45:24

Coming from a dynamic programming background it was a bit of getting used to, to the typed ecosystem of go especially with function signatures. 

One of the things that was boggling me was how to pass dynamic parameters to a function. 
In ruby we could
```ruby
def someFunc(arg1, *moreArgs)
  puts moreArgs
end
```

Now we could call `somefunc("hello", "george", "joseph")`

It was all simple there, but coming to go, it wasn't that straightforward, although go provides a way to do this. Look at the below snippet

```go
func someFunc(arg1 string, a ...string) {
	fmt.Println(arg1)
	fmt.Println(arg1, a)
	fmt.Println()
}	

```

Observing the snippet line by line, notice the last parameter of `someFunc`, it is called `variadic parameter`. From the go docs

```
 If f is variadic with a final parameter p of type ...T, then within f the type of p is equivalent to type []T. If f is invoked with no actual arguments for p, the value passed to p is nil. Otherwise, the value passed is a new slice of type []T with a new underlying array whose successive elements are the actual arguments, which all must be assignable to T. The length and capacity of the slice is therefore the number of arguments bound to p and may differ for each call site.

```

Okay, what it means is that if the final parameter of a method is of type ...T, then it is considered as type []T inside that method. What this means is that it works similar to `*moreArgs` in ruby. If we need to pass multiple arguments of type T, we can and they all will be available in the slice []T.

We could call the function as below: 
```go
	someFunc("hello")
	someFunc("hello", "apple")
	someFunc("hello", "apple", "orange")
```
What projects are you working on and how are you maintaining your focus?
Tags: motivation, discuss, productivity, career
Published: 2020-03-19 14:03:27

Hey everyone!👋🏽

Given current events, we might not all be feeling as motivated or as productive as we were just a few weeks ago (maybe more). But you're probably working on something really awesome and we'd love to hear about it!

**What are you working on right now? How are you maintaining your focus? Tell us about your project (and add links if you want to)!**

I'll go first:

I'm working on two books right now. (I know!) One is a translation of a book I released two months ago called _The Developer's Guide to Content Creation_. [The translated version is in Brazilian Portuguese](https://gumroad.com/stephaniemorillo#ojZco) and is being done by a developer and an agency in Brazil. I'm really excited for it to be released in April.

The second one is a brand new book with all-new content. It's called [_The Developer's Guide to Book Publishing_](https://gumroad.com/stephaniemorillo#RQucf) and is meant to help developers navigate traditional publishing and self-publishing. I started writing it in February and [shared a progress report](https://twitter.com/radiomorillo/status/1240634510041133057?s=20) on Twitter recently.

**Staying motivated.** It hasn't been easy. For one, I wrote my first book in 11 days and did everything—writing to editing to book design to release—in just six weeks. I didn't take a break between both books, which I should have! Then everything with COVID-19 happened, and it has been hard to concentrate. I'm working to be more patient with myself. I even pushed back the release date by a month to give myself the space to do a great job without stretching myself thin. But the good news is I'm feeling a little bit better every day. These projects mean a _lot_ to me and even though it might seem that they don't matter in the face of our new reality, they absolutely do. 

Our projects matter. :)

Looking forward to learning about what you're working on!
High-Performance Computers on the Cloud - vagon
Tags: cloud, creatives, startup
Published: 2020-03-19 13:54:52

🚂 vagon is a personal cloud-computer that is built to help creatives with flexible performance. 

https://vagon.io

Architects, CAD designers, video editors, animators, researchers - they all need powerful computers to create things and that’s what we are trying to provide. 

🎨 Our goal is to make running graphics software such as Adobe or Autodesk products possible even from a Chromebook or a veteran Macbook Air. 💻

After months and sleepless nights, it’s time to launch our beta. 
👩🏽‍💻👨🏻‍💻 More features and native apps will come soon.

Through our web app, you can
🚂 create your personal vagon computer,
⚙️ install your software,
📁 sync your files,
and use it as you use any other computer.

It is not for gaming btw. 🎮 🙃

You can access your vagon anywhere - you only need a decent connection and a computer to use it. 🌎
An intro to Azure Durable Functions
Tags: azure, serverless, wecoded, womenintech
Published: 2020-03-19 13:50:11

Durable Functions is an extension built on top of the Azure Functions platform and it gives you the ability to define how multiple individual functions can be orchestrated to work together in a workflow. 

The extension takes care of:

- Scalability
- Maintains execution position of the workflow
- Workflow state storage

Some use cases are:

- Chained functions.
- Fan out, fan in.
- Human interaction.
- Async HTTP APIs

I explain a bit more and provide a simple example of how to get started with durable functions in this video.

{% youtube 6suaQcRCRAk %}

I plan on creating more content around Azure; it's great to share what I've been learning.

If you have ANY feedback at all, please let me know in the comments below or reach out to me on socials.

Thanks for reading and possibly watching!
A list of board games and party games you can play online
Tags: coronavirus, fun, games, mentalhealth
Published: 2020-03-19 13:44:44

---
title: A list of board games and party games you can play online
published: true
description: Fun games you can play with friends online during the Coronavirus pandemic
tags: coronavirus, fun, games, mentalhealth
---
With everyone staying at home due to coronavirus, a lot of people who are into board games are talking about how we can carry on playing games together when we can't physically meet. It turns out there are quite a few online platforms and a lot of games can be easily adapted to the internet.

I think playing online is a good way to stay connected with friends even though our daily lives have been so disrupted by self isolation and lockdowns. With that in mind, I thought I'd compile all the suggestions I've seen into one list:

🎲[Online board games and party games list](https://github.com/MatMoore/online-board-games-and-party-games)🎲

These games work best if you start a voice call (e.g. via [discord](https://discordapp.com/)) to talk to each other while playing.

I was already familiar with [Board Game Arena](boardgamearena.com/), and it has a good set of games, but unfortunately it's very overloaded right now. I can also vouch for [Jackbox Party Packs](https://jackboxgames.com/) which are fun party games that are meant to be played in the same room, but I've successfully played them over a video call before. There are also lots of websites that focus on specific games such as [Pretend you're xyzzy](https://pyx-2.pretendyoure.xyz/zy/game.jsp) (Cards Against Humanity) or [dominion.games](https://dominion.games/).

Some of the websites don't include the rules, so if you want to try out a game you haven't played before, I recommend looking up the rulebook on [BoardGameGeek](https://www.boardgamegeek.com/).

If you already own a bunch of games, some of them can work over the internet if you set up a top down camera to show the board.

I also came across a list of [improv games that work over video conferencing](https://github.com/pamelafox/improvlists/blob/master/collections/Improv-games-for-video-conferencing.md) from [Pamela Fox](https://twitter.com/pamelafox). I haven't tried any of these yet but they sound like they would be fun to play.

If you have any more suggestions [please add them to the list!]( https://github.com/MatMoore/online-board-games-and-party-games)
Building Modern PHP/Yii2 Application using AWS
Tags: aws, php, yii2
Published: 2020-03-19 13:41:42

PHP has been the most popular programming language in Indonesia. I personally don't think it will change anytime soon. The language itself has been consistently adding a lot of new features these past few years, making programming in PHP safer and more structured. Very different face to the language I picked up in my high school years.

Among all popular PHP frameworks, it is by happenstance that I use [Yii Framework](https://www.yiiframework.com/) as my main PHP framework for my startup. It was still running for 6.5 years when the company got acquired, although some of the components were already scraped and rewritten in other languages for performance and compatibility considerations. It was also happenstance that I chose AWS as my cloud provider for the company, and it was really great choice.

This series will discuss about how to build Modern PHP Yii2 application on AWS. These are some of best practices that I have borrowed from other people and worked well in my experience. With the fast growing number of services that AWS released, I will introduce new ideas that can help more developers using Yii2 to be more productive and agile.

The list below will keep expanding so don't forget to check it out from time to time. If you have any ideas or requests, please drop a comment :)

1. [Deploying Yii2 Application to Amazon ECS and AWS Fargate using AWS CDK](https://dev.to/petrabarus/deploying-yii2-application-to-amazon-ecs-and-aws-fargate-using-aws-cdk-building-modern-php-yii2-application-using-aws-41kh)

    a. [Adding AutoScaling to Amazon ECS with AWS CDK](https://dev.to/petrabarus/adding-autoscaling-to-amazon-ecs-with-aws-cdk-building-modern-php-yii2-application-using-aws-126a)

2. [Building CI/CD Pipeline using AWS CodePipeline, AWS CodeBuild, Amazon ECR, Amazon ECS with AWS CDK ](https://dev.to/petrabarus/building-ci-cd-pipeline-using-aws-codepipeline-aws-codebuild-amazon-ecr-amazon-ecs-with-aws-cdk-1gfa)
3. [Using Amazon DynamoDB for Session Storage in PHP/Yii2 Application (with AWS CDK)](https://dev.to/petrabarus/using-amazon-dynamodb-for-session-storage-in-php-yii2-application-34d3)
It's fine - you are not stupid!
Tags: weareinthistogether, womenintech, covid19
Published: 2020-03-19 13:10:28

# Soziale Distance Day 6 + WFH (work from home) Day 5

Since last week Friday I'm working from home and being on soziale distance. I heard from people who say it's the rise of the introverts, I'm talking to people who are really not doing good with the situation and I also know people who are something in-between.

> We are humans, we are different and it's good that we are different!

The first few work from home days I was super productive. I even worked more hours than normal. I did a lot of documentation, wrote a Slack Communication Etiquette for the company I'm working for (@s2engineers) and came up with new ideas.

###It's fine
Yesterday in the afternoon I was fighting hard against procrastination. Today I'm super unproductive. My concentration is just miserable. And guess what? **IT'S FINE**.

At the moment I need to read a lot about LiveShare from VS Code and to understand how it's working and which connection it's using, to check if we as a company are allowed to use it. 
A.n.d - I - j.u.s.t - d.o.n.'t - g.e.t - i.t. 

My first reaction was, *"oh dammit Feli, common - you really could do better"*. 
... 😡
... 🧐
... 😕

But then I asked myself, what would I say to someone else who is in this situation? *"IT'S FINE! you are not stupid, you are not too slow, but you are too hard to yourself. Give yourself time. Most of us now need time to get use to the situation."* 

###Why I'm sharing this?
Because I want people who fighting the same problems to know: 
Y.o.u - a.r.e  - n.o.t  - a.l.o.n.e. 
Because I want **you** to not be too hard with your self. Just because you don't understand something or take longer to complete a task/ to fix a bug/ to set up a project doesn't mean you're stupid!


In doubt, always ask yourself: what would you recommend to someone else?

This situation is new for all of us, nobody of us has experience with an epidemic.

### - WeAreInThisTogether -
Awesome CSS Hamburger Menu - HTML5 CSS3 Tutorial
Tags: codepen, javascript, html, css
Published: 2020-03-19 13:06:58

---
title: Awesome CSS Hamburger Menu - HTML5 CSS3 Tutorial
published: true
description: Awesome CSS Hamburger Menu - HTML5 CSS3 Tutorial
tags: codepen, javascript, html, css
---



{% youtube AG3G17Q27Fg %}

<hr/>
[Do Not Forget To Like & Subscribe In The Channel:](https://www.youtube.com/AhmadEmran?sub_confirmation=1)
<hr/>

{%codepen https://codepen.io/ahmadbassamemran/pen/dybpaLE %}