teleren/devto huggingface dataset:
Find all subsequences in the sequence 
Tags: scala, newbie
Published: 2019-08-16 09:26:34

Let's start with the signature of our function

```scala
def groupSubseq[T](in: Seq[T])(p: (T, T) => Boolean): Seq[Seq[T]]
```
Here **p** is predicate we use before add item to the existing subseq or create new one

We are going to use foldLeft

```scala
def groupSubseq[T](in: Seq[T])(p: (T, T) => Boolean): Seq[Seq[T]] = in
  .foldLeft(Seq.empty[Seq[T]])((seq, item) => seq match {
    case Nil => Seq(Seq(item)) // processing first element
    case currentSeq +: tail =>
      if (p(currentSeq.head, item)) {
        // new element satisfies the condition, add it to the subsequence
        (item +: currentSeq) +: tail 
      } else {
        // new element not satisfies the condition, start new subsequence
        Seq(item) +: seq
      }
  })
```


Looks like we've done here. But let me explain ))... This post is a result of a few similar tasks I've faced recently.

**Task 1**

*Find all the sequences of the same character in the given string and count number of the character in each sequence*

```scala
def countChar(seq: String): Seq[Char, Int] = ???

val test1 = "aaabbaaaabbb"

countChar(test1)

//res0: List((a,3), (b,2), (a,4), (b,3))

```

**Task 2**

*Count number of all the sequences of the same sign in the given sequence of Int*

```scala
def countSign(seq: Set[Int]): Int = ???

val test1 = Seq(1, 2, 3, -3, -2, 6, 7, 8, 9, -3, -1, -6, 7)

countSign(test1)

//res0: 3

```

Using our recent invention we may solve it easily

```scala
def countChar(seq: String) =
  groupSubseq(seq)(_ == _).map(seq => seq.head -> seq.length).reverse

countChar("aaabbaaacddddd")

// res0: Seq[(Char, Int)] = List((a,3), (b,2), (a,3), (c,1), (d,5))


def countSign(seq: Seq[Int]) = groupSubseq(seq)(_ * _ > 0).count(_.length > 2)

countSign(Seq(1, 2, 3, 4, -1, 1, -1, -2, -3, -4, 0, 0, 0))

// res1: Int = 2

```

I hope to see your pros and cons in the comments. Thanks for reading.
Entity-Systems for typescript based games
Tags: javascript, typescript, angular, gamedev
Published: 2019-08-16 09:23:04

# Entity-Systems for typescript based games

This post is also available [on my blog](https://heltweg.org/posts/entity-systems-for-typescript-based-games/) where I plan to write more about game development with typescript if you are interested :).

For my latest game project [Frozzen](https://frozzen-client.appspot.com/) I want to explore how an external UI, build with Angular, would work for a browser based game. Since Angular is written in Typescript that means ideally the game should also use the same.

I have used [Artemis ODB](https://github.com/junkdog/artemis-odb) as framework for a Java based game in the past and liked it a lot. Entity-Systems are much better introduced by any of the huge amount of articles out there (for example the classic on [T=Machine](http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/) but I feel they are especially well suited to Javascript/Typescript development.

If you work with a strict separation of logic into systems and data only into components there is a very natural way to serialize components, JSON. Whole levels can be expressed as an array of JSON data that is used to set up components. That is why I prefer a very basic but strict implementation like artemis over similar frameworks like PhaserJS.

I started my development with artemists, a Typescript port of artemis by darkoverlordofdata. Unfortunately the code is a bit outdated and does not use import/export and can not be directly imported for newer Typescript versions (since it extends the built-in Array).

With darkoverlordofdata’s permission I did a quick update to the Typescript parts of the code only, adding import/export support and fixing the build for newer Typescript versions. [You can find the updated version here](https://github.com/rhazn/artemis-ts). If you are looking for an example of that framework in action you can play an example level of Frozzen [here](https://frozzen-client.appspot.com/).

# About Me
I am a full stack developer and digital product enthusiast, I am available for freelance work and always looking for the next exciting project :).

You can reach me online at [https://heltweg.org](https://heltweg.org).
Deploy a personal blog with Hugo, Firebase and Gitlab
Tags: blog, devops, firebase, todayilearned
Published: 2019-08-16 09:15:40

# Blog requirements

I recently evaluated what how writing content and carving out a little personal space on the internet would look like for me and came up with a list of requirements:

* Own my content (No third party platforms as only distribution method. There was a time before medium and there will be a time after medium. Speaking of which, if you want to see the result "in action" you can find this article on my blog: [https://heltweg.org/posts/deploy-a-personal-blog-with-hugo-firebase-and-gitlab/](https://heltweg.org/posts/deploy-a-personal-blog-with-hugo-firebase-and-gitlab/) ;))
* Easy to set up and maintain (I don't want to set up and host databases or complicated CMS systems and when I come back to this in a month it should be easy to update.)
* Long term secure storage (By not hosting my content with a third party but in git I can easily back it up, keep old revisions and there is no worry of the hosting provider going down.)

All these requirements are solved by using a static site generator and keeping the original files versioned in git. When setting up some for of continuous integration (for example with gitlab) it should be reasonably easy to maintaining for a long time.

I chose gohugo as a site generator due to the excellent setup article written by Fabian Gruber here: https://www.fabiangruber.de/posts/setup-and-deployment

# Automated builds

I set up an automated build using gitlab using the following gitlab-ci.yml:

{% gist https://gist.github.com/rhazn/419bc208d9402f33df9f17c74ce3bf76 %}

This uses a docker image for Hugo and builds the static page from the sources provided.

# Continuous delivery

I chose firebase to host the website because I have previous experience with it. It is very easy to create and deploy a static website as well as wire it up with a HTTPS domain.

After creating a new project in firebase you'll need to get a token that allows gitlab to make deployments on your behalf:

**firebase login:ci**

Set it up as a secret variable in gitlab called "FIREBASE_TOKEN".

To add firebase to the gohugo project navigate to the directory in the CLI can call:

**firebase init**

Armed with the token that allows gitlab to deploy in your name as well as a configured firebase project we can add the last step to the gitlab-ci file - deployment.

You can see the full gitlab-ci.yml file here:

{% gist https://gist.github.com/rhazn/22e7f2199e165b48c145c9283dca15e1 %}

# About Me
I am a full stack developer and digital product enthusiast, I am available for freelance work and always looking for the next exciting project :).

You can reach me online at [https://heltweg.org](https://heltweg.org).
Improve your deployment productivity? Easy!
Tags: productivity
Published: 2019-08-16 09:15:23

Hey guys,

My team is working on a service that can boost your deployment productivity. 

We call it [DeployPlace](https://deployplace.com/). 

If you feel tired of boring deployment routine and server configuration tasks, we are here to help. 

It is a tool by developers for developers, with the possibility to easily deploy complex Java/Scala/Kotlin applications, as well as static websites or client-side projects directly from your CI.

Unlike other deployment tools, we show you every step we make in our live editor.

I'm really interested in your comments and feedback.

Feel free to AMA in comments!

You can check out the details at [deployplace.com](https://deployplace.com/)

P.S. I'd like to share my favorite productivity quote by Henry David Thoreau:
“It is not enough to be busy… The question is: what are we busy about?”
What is in your work bag?
Tags: discuss, codenewbie, question
Published: 2019-08-16 09:00:43

---
title: What is in your work bag?
published: true
description: What do you take in your work bag everyday? 
tags: discuss,codenewbie,question
---

###I start my internship in two weeks! 🎉 Help a worrying newbie out!

#What do you take in your bag everyday to work?

I'm worried about not taking the right stuff, or worse, taking the wrong stuff...

Tell me the most important equipment in your bag, the things you couldn't live without.

So far:
1.Pen
2.Notebook
3.Antiperspirant (I need to worry about that stuff)

Assuming laptop will be kept at work but I'm not sure.
Categorical Variables and Cardinality
Tags: machinelearning, datascience, bigdata, pandas
Published: 2019-08-16 08:47:21

---
title: Categorical Variables and Cardinality
published: true
description: One approach to deal with categorical variables 
tags: #machinelearning #datascience #bigdata #pandas
---

One approach to deal with categorical variables is One-Hot Encoding. 
But there is an important thing to keep in mind when using it. 
Cardinality and it means the number of unique values in a column.

It's always better to create a one-hot encoding for columns with lower cardinality because in a large dataset one-hot encoding can expand the size of the dataset.

High cardinality columns can either be dropped from the dataset, or we can use label encoding.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/m4ej5qvwqv1vu25l6x4n.png)
New service for deployment automation
Tags: devops
Published: 2019-08-16 08:42:16

Hi guys,

We are working on a service for deployment automation. No more routine server configuration and deployment setup. Simply connect your CI and that's all.

The service is called [DeployPlace](https://deployplace.com/).

DeployPlace is a transparent deployment tool by developers for developers, with the possibility to easily deploy complex Kotlin/Java/Scala applications, as well as static websites or client-side projects directly from your CI.

Unlike other deployment tools, we show you every step we make in our live editor.

We just launched our pre-launch campaign on IndieHackers and look for Early Adopters. 

You can check out the details at [deployplace.com](https://deployplace.com/)

Feel free to share your feedback and thoughts regarding our project. 

Thanks!
TADHack Global 2019: the largest hackathon worldwide. Join the fun!
Tags: hackathon
Published: 2019-08-16 08:27:09

Want to compete for a $34k prize in a laid-back developer event? Meet us at TADHack Global 2019 and become part of a weekend that draws an inspiring group of technologists and telecommunication leaders from all over the world!

<a href="https://tadhack.com/2019/global/tadhack-netherlands/">Join the hack</a>

Date and time
12–13 October 2019
9:00–18:00 CEST

Location

In Belgrade, Berlin, Johannesburg, London, Romania, Kuala Lumpur, Sri Lanka, Chicago and Popayán. Remote entry from another location is also possible. The event will be streamed live on YouTube.
To hack with us at our location:

IoT Academy
Scheepsbouwweg 8
3089 JW Rotterdam
<a href="https://goo.gl/maps/KHBWDEZgjbWzhons6">View map</a>

About TADHack Global

<a href="https://tadhack.com/2019/global/tadhack-netherlands/">TADHack Global</a> is a yearly worldwide hackathon about the latest internet, IT and telecoms technologies. The idea of the hackathon is to help people learn about existing technologies and work together in teams towards solving problems that matter in work, home and community life.

This year’s hack

This year’s hackathon runs across 10 to 15 cities around the world. Remote entries are also allowed, which means participants may also hack from the comfort of their own home.

Teams can already look up the <a href="https://tadhack.com/2019/global/tadhack-netherlands/">sponsored technologies</a>  in telecommunications that will be used during the global TADHack 2019 and think about which to use. <a href="https://developer.kpn.com/?utm_source=dev.to&utm_medium=TADHack&utm_campaign=aug19">KPN and KPN partners’ APIs</a> will also be available in the Netherlands. Our partner VoIP Innovations, for instance, will sponsor voice and webRTC technologies.
The best hack will win a cash prize of $ 34.000! The best team of Rotterdam will be rewarded credits for at the API Store as well.

Past hack inspiration

Hacks in previous years included many interesting sponsor technologies such as programmable telecoms (voice, video, messaging), internet of things, cloud computing, robotics, machine learning, speech and face recognition, mobile payments, enterprise communications, decentralized web, blockchain, encryption and open source. In 2015, a dancing robot was among the many exciting developments made with existing technologies.
Check out websites of previous hacks from <a href="http://www.tadhack.com/2018">2018</a>, <a href="https://tadhack.com/2017/global">2017</a>, <a href="http://tadhack.com/2016/global">2016</a>, <a href="http://tadhack.com/2015">2015</a> and <a href="http://tadhack.com/2014">2014</a>, or watch the <a href="https://www.youtube.com/watch?v=bLIYYA0SQVo">5 year TADHack anniversary movie</a>.

Join the hack

You are very welcome to join us in Rotterdam for the weekend. Have some fun and free food, meet cool people and at the same time, have a chance at winning a cash prize!

Register your team <a href="https://tadhack.com/2019/global/tadhack-netherlands/">here</a>.
Three pro tips for tackling impostor syndrome
Tags: productivity, beginners, programming
Published: 2019-08-16 07:26:44

---
title: Three pro tips for tackling impostor syndrome
published: true
description: 
tags: #productivity #beginners #programming
---

There is no shortage of articles about impostor syndrome on dev.to and other programming websites. 

It's a perennial topic for developers. It will ALWAYS be something we have to deal with. It's a career where we can NEVER know everything - the possibility to feel lost will always be with us.

Here are three of my favourite resources that contain practical tools you can start using right now to tackle it. At best, it's irritating, at worst debilitating. But there are practical steps you can start taking today that will help you overcome it. 

# Increase your knowledge

Impostor syndrome is often a feeling of not knowing enough, or having missed the basics. 

Rob Connery's Impostor's Handbook attempts to fill the gap. It's excellent. Everything you wished you knew about programming and CS that you were too afraid to ask your colleague about because you were afraid they would finally see through it. Link below, money well spent (I'm not associated with Rob, I just loved the book).

This is particularly great for self-taught developers. I showed it to my colleague and his eyes lit up - he called it a goldmine!

https://bigmachine.io/products/the-imposters-handbook 

# Understand the problem

Knowing what you're up against is important when it comes to any problem. 

Here's my dissection of impostor syndrome as a FEELING - an emotional state, with understandable roots and a definite way out. Once you learn that the feeling of being an impostor is not correlated to the reality of how you are perceived, you can 

{% link daraghbyrne/how-to-beat-impostor-syndrome-and-stop-feeling-like-a-fake-18m8 %}

# Embody success

Our bodies can change our minds. How we position ourselves, in a physical sense, can change the we you feel about ourselves. Learn how with Amy Cuddy's excellent Ted Talk. Posture is power! And changing your body language is free. 

{% youtube Ks-_Mh1QhMc %}


How about you? What are your pro tips?

_I write about mindfulness and meditation for software developers over at [CodingMindfully.com](https://codingmindfully.com)._
C# Generic Collections
Tags: datastructures, javascript
Published: 2019-08-16 06:49:29

---
title: C# Generic Collections
published: true
description: Finding out what the System.Collections.Generic namespace holds
tags: C#, Data-Structures, javascript
---

One thing I’ve heard before and definitely am guilty of repeating before knowing the meaning of, is the statement: “Javascript doesn’t have arrays it has lists”. I’ve always understood this to basically mean nothing because “functionally, they’re the same” and when you’re learning Javascript for the first time, this can be a good philosophy to have because you don’t get bogged down with theory and can focus your attention on just building things. When I began delving into C# however, starting to use it on a daily basis, this philosophy caught up with me quickly. I’ve known for quite a long time that arrays in languages other than Javascript have a fixed length that you must declare at some point. It was incredibly intimidating and I struggled to understand how you work around this limitation. I’d like to share with you my “Aha!” moment I had when I finally understood that learning data structures and when to use them became so pivotal to creating proper, functional and optimized code.

C# has a namespace in the .NET library called [System.Collections.Generic](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic?view=netframework-4.8) and it’s within here that you can find your lists, stacks, and queues. These are typically data structures you have to build out manually in Javascript. You can instantiate any of these like a normal object declaration.

	List<T> grades = new List<T>();

Sidenote: If this is the first time you’re seeing the <T> it’s a [generic type parameter](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generic-type-parameters), meaning you can fill in that parameter with any type recognized by the compiler like string or double.

Lists do obviously come with a higher memory cost than normal arrays but solves our issue of needing to know how many items are going to be in our array if you’re not sure . My favorite thing about using these built in data structures is that they come with methods built in as well. You can easily implement a binary search on a list by calling .BinarySearch() on the List object instance.
Switching RxJava schedulers between app code and corresponding tests
Tags: rxjava, kotlin
Published: 2019-08-16 19:50:23

---
title: Switching RxJava schedulers between app code and corresponding tests
published: true
tags: rx-java, kotlin
canonical_url: https://varunbarad.com/programming/rx-java/2019/08/16/switching-rxjava-schedulers-between-app-code-and-corresponding-tests.html
---

A simple way to switch between using appropriate schedulers in app code and using trampoline schedulers for tests.

<!-- end excerpt -->

When using RxJava we need to specify the schedulers which we want to use to 1) perform the given task and 2) return result of the operation chain.

One of the interesting ways I found while working on a take-home challenge for a company was as below:

```kotlin
object VarunSchedulers {
    private var schedulers: RxSchedulers = RxSchedulers.Default

    fun enableTesting() {
        this.schedulers = RxSchedulers.Test
    }

    fun disableTesting() {
        this.schedulers = RxSchedulers.Default
    }

    fun io(): Scheduler = this.schedulers.io()
    fun computation(): Scheduler = this.schedulers.computation()
    fun main(): Scheduler = this.schedulers.main()

    private sealed class RxSchedulers {
        abstract fun io(): Scheduler
        abstract fun computation(): Scheduler
        abstract fun main(): Scheduler

        object Test : RxSchedulers() {
            override fun io(): Scheduler = Schedulers.trampoline()
            override fun computation(): Scheduler = Schedulers.trampoline()
            override fun main(): Scheduler = Schedulers.trampoline()
        }

        object Default : RxSchedulers() {
            override fun io(): Scheduler = Schedulers.io()
            override fun computation(): Scheduler = Schedulers.computation()
            override fun main(): Scheduler = AndroidSchedulers.mainThread()
        }
    }
}
```

Now let’s take the example of fetching a network query, we can simply do this

```kotlin
pandaService.getCutestPanda()
    .subscribeOn(VarunSchedulers.io())
    .observeOn(VarunSchedulers.main())
    ...
```

And when we write our unit-tests we can easily turn testing-mode on and off using the `@Before` and `@After` methods.

```kotlin
class SomeTestClass {
    @Before
    fun setupTests() {
        VarunSchedulers.enableTesting()
    }
    
    @After
    fun tearDown() {
        VarunSchedulers.disableTesting()
    }
    
    // Write your tests
}
```

Now whenever we are inside tests, then automatically the `trampoline` schedulers are assigned and respectively appropriate schedulers by default in case we are not in tests.

If you have more such tricks up your sleeve or something in here isn’t clear to you or you just want to chat then hit me up on twitter [@varun\_barad](https://twitter.com/varun_barad).
New React API proposal
Tags: react
Published: 2019-08-16 06:26:00

---
title: New React API proposal
published: true
description: 
tags: react, react js
---

For SVG icons currently, we are preferring like functional components like this

const SvgIcon = () => (
    SVG icon tag...
);

here I am not taking any props for the functional component but if any updates happened parent component child component(SvgIcon) which is an SVG icon is rerendering.
Here we can use memo but the React memo is not preferable for small components like this as a component should have memoizable content (props) or complex computations.

In SVG icon we can imagine any static text () or image the same happens.

So here I am proposing like better if we anyone API (naming convention can be anything) in internal it can be wrapped with memo or else any other but it should be rendered only once

any suggestion, queries.

Thanks to all
I Electrical Engineer Turned Javascript Developer, Ask Me Anything!
Tags: ama
Published: 2019-08-16 06:04:10


Hi, I'm changing my profession, from an electrical engineer to Javascript Developer. I am interested in learning through projects. And I participate in one that is carried out by a Free Software community called Open Source Weekends. I am interested in projects that have to do with education, productivity and social networks, and that relate these three things

--
Guillermo
How do you set up a productive team despite management's interference?
Tags: discuss, productivity
Published: 2019-08-16 05:57:02

---
title: How do you set up a productive team despite management's interference?
published: true
description: A discuss about setting up a productive team amidst management's interference.
tags: discuss, productivity
cover_image: https://thepracticaldev.s3.amazonaws.com/i/9dgq3wt39eyfwv8viev4.jpg
---

Setting up a productive team is hard especially when dealing with management that feels software developers don't understand the business and its goals.


In this case, how do you set up a productive team of software developers?


Thanks for your time!