teleren/devto huggingface dataset:
Daily Challenge #112 - Functions of Integers on the Cartesian Plane
Tags: challenge
Published: 2019-11-09 16:52:40

---
title: Daily Challenge #112 - Functions of Integers on the Cartesian Plane
published: true
series: Daily Challenge
description: Write a function to calculate the sum of functions of integers. 
tags: challenge
---
Consider integer coordinates `x`, `y` in the Cartesian plane and three functions `f`, `g`, `h` defined by:
<pre>
f: 1 <= x <= n, 1 <= y <= n --> f(x, y) = min(x, y)
g: 1 <= x <= n, 1 <= y <= n --> g(x, y) = max(x, y)
h: 1 <= x <= n, 1 <= y <= n --> h(x, y) = x + y
</pre>
where `n` is a given integer (`n >= 1`, guaranteed) and `x`, `y` are integers.

In the table below you can see the value of `f(n)` where `n = 6`.
![](https://i.imgur.com/vMxGoAM.png)

The challenge is to calculate the sum of `f(x, y)`, `g(x, y)`, and `h(x, y)` for all integers `x` and `y` such that `(1 <= x <= n, 1 <= y <= n)`

The function `sumin` (sum of `f`) will take `n` as a parameter and return the sum of `min(x, y)` in the domain `1 <= x <= n`, `1 <= y <= n`. The function sumax (sum of `g`) will take n as a parameter and return the sum of `max(x, y)` in the same domain. The function `sumsum` (sum of h) will take `n` as a parameter and return the sum of `x + y` in the same domain.

<pre>
sumin(6) --> 91
sumin(45) --> 31395
sumin(999) --> 332833500
sumin(5000) --> 41679167500

sumax(6) --> 161
sumax(45) --> 61755
sumax(999) --> 665167500
sumax(5000) --> 83345832500

sumsum(6) --> 252
sumsum(45) --> 93150
sumsum(999) --> 998001000
sumsum(5000) --> 125025000000
</pre>

*Hints:*
- Try to avoid nested loops.
- Note that `h` = `f + g`

Good luck!

***
_This challenge comes from g964 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!_
Axiosfit, a cool way to organize your HTTP client requests
Tags: typescript, angular, nestjs, axios
Published: 2019-11-09 16:49:46

> [Original Post](https://blog.yggdrasilts.com/axiosfit-a-cool-way-to-organize-your-http-client-requests)

Nowadays, all the developers have had to build applications that need communication with other applications or services even more important if you are in a microservices architecture. Depending on how much communications you have had to use, the big amount of endpoints that would be needed to handle could turn into a big headache.

The main purpose of [Axiosfit](https://www.npmjs.com/package/@yggdrasilts/axiosfit?activeTab=readme) is giving you a pill to minimize this headache 😜 and helping you to manage all of these endpoints in an organized way.

## What is Axiosfit?

[Axiosfit](https://www.npmjs.com/package/@yggdrasilts/axiosfit?activeTab=readme) is the first component of [YggdrasilTS](https://github.com/yggdrasilts) tool set and, like its [README](https://github.com/yggdrasilts/axiosfit/blob/master/README.md) sais, it is a project inspired by [Retrofit](https://square.github.io/retrofit/) to create declarative HTTP clients using [axios](https://github.com/axios/axios), one of the most popular libraries used in Javascript.

It has been thought to be used inside [TypeScript](http://www.typescriptlang.org/) projects, both worlds, frontend and backend, and it helps you to have your HTTP clients organized.

Since it is developed in [TypeScript](http://www.typescriptlang.org/), all of its main features are a set of [Decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) that make easy to configure your HTTP clients to interact with different APIs.
A new JavaScript library for building user interfaces, Easy, Fast, And readable Syntax, Mix With React + Flutter Style
Tags: react, javascript, vue, angular
Published: 2019-11-09 16:14:00

# Hello in Brex world

A JavaScript library for building user interfaces with easy ***syntax*** system and esay controll each widget in each component and Design simple views for each state in your application.

- **Fast and Lite.** lite library to help you to create a **Complex UI** with simple ways.
- **Tools.** give you more library & methods helping you create all you want.
- **Easy Style.** using **React** *style component* with *methods* & **Flutter** *Widget style* with *fast readable system*
- **Easy Control** all things in component is a widget

## Simple Example

- Without Hooks

```javascript
 Brex(Component(function() {

  this.state = {
    ...this.state,
    name: 'HoSheiMa',
  }

   return View({
     children: [
       Child({
         text: 'Hello ' + this.state.name
       })
    ]
})
```

- With Hooks (Beta)

```javascript
 Brex(Component(function() {

   [name, setName] = this.useState('HoSheiMa'); 

   return View({
     children: [
       Child({
         text: 'Hello ' + name
       })
    ]
})
```

- Advance Example

```javascript
var Main = function() {
  
  /**
   * // without Hooks
   * this.state = {
   *  ..this.state,
   *  x: 0,
   * }
  */

  // with Hooks
  [x, setX] = this.useState(0);

  var redText = createNativeElement({
    attrs: {
      style: "color:red;"
    }
  }); // ? Create a custom child using createNativeElement function
  
  return View({
    children: [
      // children :D
      redText({
        text: "Hello world x: " + x,
        events: {
          click: function() {
            /**
              * // without Hooks
              * this.setState({
              *  x: x + 1,
              * })
            */

            // with Hooks
            setX(x + 1); 
          }
        }
      })
    ]
  });
};

Brex(Component(Main)); // init main point to start from it.
```

for more example visit [Full example section.](https://github.com/HoSheiMa/Brex/tree/master/examples/%40component) with lastest version.
GitHup Link : https://github.com/HoSheiMa/Brex
Vscode extension kill-process
Published: 2022-12-09 14:08:58

---
title: Vscode extension kill-process
published: true
date: 2019-11-09 16:05:37 UTC
tags: 
canonical_url: https://blog.niradler.com/vscode-extension-kill-process
---

while developing web apps often have this moment when I need to remember the commands to kill a process by port, usually, it is more than one command and when I move from os to os the command is changed, so my solution for that was first of all to create [command line tool](https://github.com/niradler/manage-ports) for that, and now for the even easier and quicker way a vs-code [extension](https://marketplace.visualstudio.com/items?itemName=niradler.kill-process).

![Vscode extension kill-process](https://cdn.hashnode.com/res/hashnode/image/upload/v1642373578737/BJQUthWHm.gif)

GitHub: [Link](https://github.com/niradler/kill-process-vscode)

VScode Marketplace: [Link](https://marketplace.visualstudio.com/items?itemName=niradler.kill-process)

NPM: [Link](https://github.com/niradler/manage-ports)
You can't beat this algorithm
Tags: machinelearning, webdev, javascript
Published: 2019-11-09 14:28:58

So in my company ([Hackages.io](https://hackages.io)) we have what we call a HackFriday. So every other Friday we have one full day to experiment with tech we want to know more about. For me it was deep learing, but as a frontend dev I discovered it is quite hard to implement in the frontend, this is how IRMA was born.

# IRMA
IRMA (Invicible Rock-paper-sissor Medium Algorithm) is a fortune teller that can predict with an accuracy of ~70% your next move at rock-paper-sissor.
You can try the game [here](https://irma.netlify.com), but be careful of the spell that could be cast on you if you beat her...
You can also use the j-k-l buttons on your keyboard to play faster.

# Technical part
So IRMA is just a statistical computing algorithm that learn from the player. She remember every moves and try to predict the next one based on the previous successions. If you think you can be smarter than her and generate random move, try to stay bellow 50% accuracy after 100 moves. 
Human beeings are not able to deliver true randomness, and IRMA know it. Let's take for exemple the 20 first moves an user (me) made:
```
["📝", "✂️", "✂️", "🗿", "✂️", "📝", "🗿", "📝", "🗿", "🗿", "✂️", "🗿", "📝", "✂️", "📝", "🗿", "✂️", "📝", "🗿", "✂️"]
```
It looks pretty random and it seems like it would be really difficult to predict my next move.
Now let's try to divide this list in 3-grams, the 3-grams is the list of all successions of 3 choices that were made by the user. 
This is not the same as dividing the list by groups of 3, for exemple the list `[a, b, c, d]` would produce 2 grams: `[a, b, c]` and `[b, c, d]`.

Here we have :
```
["📝", "✂️", "✂️"]
["✂️", "✂️", "🗿"]
["✂️", "🗿", "✂️"]
["🗿", "✂️", "📝"]
["✂️", "📝", "🗿"]
["📝", "🗿", "📝"]
["🗿", "📝", "🗿"]
["📝", "🗿", "🗿"]
["🗿", "🗿", "✂️"]
["🗿", "✂️", "🗿"]
["✂️", "🗿", "📝"]
["🗿", "📝", "✂️"]
["📝", "✂️", "📝"]
["✂️", "📝", "🗿"]
["📝", "🗿", "✂️"]
["🗿", "✂️", "📝"]
["✂️", "📝", "🗿"]
["📝", "🗿", "✂️"]
```
Still looks pretty random, but maybe you can already see some pattern. That is because, even for only 20 values I struggled to create random data, fearing to repeat myself, and yet I still did without realising it.

Now let's take the last 2 values : `["🗿", "✂️"]` and filter out all the grams that do not start with those values:
```
["🗿", "✂️", "📝"]
["🗿", "✂️", "🗿"]
["🗿", "✂️", "📝"]
```
As we can see I have the tendency to put a `"📝"` after writing `["🗿", "✂️"]`, so IRMA will play `"✂️"`. Now do this but with a lot of data and several grams sizes and you have a fully fonctionning IRMA.

# Conclusion

IRMA is not deep learning, but it can still be considered machine learning. Unlike deep learning it does not require a lot of computing power, to prove this, IRMA run solely in the frontend with Javascript.
It can be a good alternative for developpers who want to implement a bit of "magical" intelligence to their frontend easily without extreme statistical knowledge and without deep learning disadvantages.

If you have idea to improve IRMA or idea of real world adaptation don't hesitate to leave a comment ;)
What are your plans for 2020?
Tags: discuss
Published: 2019-11-09 14:19:07

Hi all! Ready for 2020?

Is there something that you want to learn? Have you already planned your path for the next year?

Here's my _would like to do_ list (yeah, a simple _todo_ isn't enough):

* __Multithreading in C#__: this is one of my greatest lack, so I want to learn more about it (estimated time: 1 month)
* __Gremlin DB__: I've already worked with it, but I want to learn more about it and, in general, about graph DBs (estimated time: 1 month)
* __Docker + Kubernetes__: those technologies are always looked as _the future_ of software development. So, it's time to learn more about them! (estimated time: 3 month)
* __Microsoft Orleans__: I know what this project is, and it looks interesting. But I've only read something on the homepage of the project, so I don't so many ideas about it (estimated time: 1 month)
* __ML.NET__: even here, I don't know so much about it. Well, I know nothing about Machine learning and similar (estimated time: 4 months)

And... that's it!

What about you? Do you know these arguments?

What would you like to learn next year?
Publishing Dart Packages with Github Actions
Tags: githubactions, flutterplugin, dartpackage, dart
Published: 2019-11-09 13:24:21

*A tutorial that will get you started with automated publishing of Dart packages to the pub.dev package repository, in less than 3 minutes.*

In a couple of minutes from now, you will have a Github Action workflow that does all the heavy lifting of publishing your dart package or 
Flutter plugin to [pub.dev](https://pub.dev/) for you.

Let’s get started.

## Get your credentials
First you need to get and setup your credentials for publishing the package. Make sure that you publish your first version manually from the command line so that your package gets listed and you become the owner of that listing.

After that, find your `credentials.json` file either in `~/.pub-cache` or `~/<your flutter root>/.pub-cache/`

```sh
$ cat ~/.pub-cache/credentials.json 
{
 “accessToken”:”<access-token>”,
 ”refreshToken”:”<refresh-token>”,
 ”tokenEndpoint”:”https://accounts.google.com/o/oauth2/token",
 "scopes":["openid","https://www.googleapis.com/auth/userinfo.email"],
 "expiration":1570721159347
}
```

Copy your access and refresh tokens and [create secret variables in your Github project](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) and name them 
`OAUTH_ACCESS_TOKEN` and `OAUTH_REFRESH_TOKEN` respectively. They will match the names in the script below later.


## Set up your Github Actions workflow

You can either choose to setup your actions direcly from the Github website or just add 
[this YAML configuration file](https://gist.github.com/DennisAlund/e82039c42da7a67beaf6a0ab1bfd991f) 
into your project and push the change to the Github repository.

### <project>/.github/workflows/dart.yml


{% gist https://gist.github.com/DennisAlund/e82039c42da7a67beaf6a0ab1bfd991f %}


## Publishing new versions

This script will now publish a new version of your package to pub.dev every time you merge to the master branch.
It’s important to rember that each new version that you are publishing must have a new semantic version number in your pubspec.yaml and you should also declare a corresponding explanation of what you have updated in the `CHANGELOG.md`. The deployment **will complain** if you don’t.
Joining a modern software development team
Tags: work, softwareteam
Published: 2020-01-02 21:41:18

---
title: Joining a modern software development team
published: true
date: 2019-11-09 13:03:48 UTC
tags: Work,software team
canonical_url: 
---

A few weeks ago I started a new job as a PHP/Laravel developer. This job is something I’ve really hoped for, as I get to work in a team with two developers who are more senior than me. Until now I used to work mostly by myself. The problem of only working by oneself is that one stagnates. I’ve been reading articles and books and so have continued to grow somewhat, but being in a team where code reviews are done really stretches one. Working as a sole developer is as if you learn a language like French but never get to speak to a native speaker. You might think you are actually quite good at speaking French until you go to France and understand almost nothing that is being said to you.  
   
Most modern teams now do code reviews. It ensures everyone uses the same coding standards, e.g. my team prefers to use single quotes rather than double quotes. We only use double quotes if there is a string with a variable inside. They also want to make sure the code is written concise while still keeping it readable. I’ll often get tips on how the code can be improved. Code reviews are also good for the reason that everyone in the team gets a better understanding of the whole code base.  
   
I’ve also been learning more about using version control as I tend to have several pull requests waiting to be reviewed before they can be merged. This often has led to some frustrating merge conflicts that took a long time to resolve, but I’m optimistic that I’ll find better ways dealing with that too.  
   
At least we have a good automatic test coverage, so if something goes wrong I’m able to discover that quickly. Often writing the test takes a lot longer than making a quick change to something, but in the end it’s worth it.   
   
It’s the first time I only work in the backend. Before this I always worked as a Fullstack developer. So I’m learning a lot about creating APIs. Creating APIs comes with lots of advantages of course and it allows the separation of frontend and backend work. But on the downside it seems you end up sending a lot more data across the network. And it also makes scrapping of the content easier, so these are things one should be aware of and try to mitigate.  
   
My team makes heavy use of design patterns, so I’m working on refreshing my knowledge in that regards.  
   
 I hope this brief article gave you a little idea of what to expect when joining a modern software development team.
How do you run A/B split tests or experiments on your sites?
Tags: javascript, splittesting, abtesting, testing
Published: 2019-11-09 11:40:59

Please share how you're currently running experiments on your sites. E.g.:

 - What software you're using
 - Whether you build experiments in JS, backend code, WYSIWYG or CMS UIs
 - Who typically manages this process

I'm curious to learn how other developers and organisations run experiments because we're building an [open source split testing stack](https://mojito.mx/), called Mojito. It'd be useful to know what sort of features and use cases are common to target!
Javascript + localstorage = todo list
Published: 2019-11-09 11:40:15

Hi everyone!
This is my first post here and this to-do list is one of my recent projects, I would be glad to know your review about it.

The code is a little complex to read because there are many lines of codes ( ~870 JS ). I've used so many functions and handled many events.

This app needs no server-side coding, everything happens client-side.

+ It works with `localstorage` and saves your data there
+ Report if you discovered UX issues

*NOTE:* resize your browser to work with the app **if you're on desktop**.

[hmht.ir/page/todo](http://www.hmht.ir/page/todo)

And [here](https://github.com/sepehrsamavati/easy-todo) is the source code
Boosts for Programming
Published: 2019-11-09 11:23:53

---
title: Boosts for Programming
published: true
description: 
tags: 
---

To Prepare for Coding Flows

I am currently experimenting with these and the ratio of these habits to coding. Although I do not keep metrics for that yet and I do not measure the short term benefits of these techniques.

Half an hour each, or so:
(I should time them more strictly!)
1. Meditation
2. Socialisation
3. Reading
4. Making/Blogging/Vlogging
5. Taking a Nap
6. Walk a 500 paces (or a mile) [400 m is usually enough to get an insight]
7. Dance / Chillout to music
8. Aerobic Exercise
9. Anaerobic Exercise
10. Analysis of Progress
11. Code Review
12. Mob programming
13. Train typing
14. Train n-back
15. Practice shortcuts
16. Down-time
17. Study new things
18. Experiment with a toy project
19. Test yours skills with coding snippets
20. Journalling
Highest Paying Skills For Individuals In 2020.
Published: 2019-11-09 11:21:27

Wondering what could be the highest paying skills for individuals in 2020? With this ever-changing environment, one needs to upgrade his or her skills on a continuous basis. Among all those career options available if you are a Technology professional and possess a fine set of qualifications and capabilities, 2020 will bring you better employment options.

Whether you are a Data analyst, developer, designer, salaries are on the rise because of rising demand for IT professionals. Devin Fidler, research director at “Institute for the future” says “There are some overarching shifts poised to change the nature of work itself over the next decade.”

Labour force projection 2020 published by the US Bureau of Labor Statistics, predicts that there will be an increment of 20.5 million jobs by 2020.

The report predicts only a few profiles will grow more than 50% of the total in 2020. These profiles majorly include Information Technology domain. Here’s a look at just some of the highest-paying jobs, according to Robert Half Technology’s 2020 Salary Guide (PS these are not in any specific order)

for more details, you can read this 
https://codersera.com/blog/highest-paying-skills/
Get Started and Avoid Getting Stuck 
Tags: started, firedup, persistence, procrastination
Published: 2019-11-09 11:17:21

---
title: Get Started and Avoid Getting Stuck 
published: true
description: 
tags: #started #firedup #persistence #procrastination  
---

A Short Mix of Rituals:

1. 2 min Exercise or a 7 minute tabata
2. Cold Shock Shower
3. Rain Sounds
4. 10 min Breathe or WHM or Box meditation
5. 9 min code read, timed, repeat if necessary
6. Find a bug 
7. Write 5 TODOs
8. Vagal nerve massages, get parasympathetic
9. Drink Water or Tea
10. 10 min 40 Hz Audio binaural and Visual flickering
11. IMST exercising 
12. Clean up code

Rituals That Break Flow:

1. sugar
2. podcasts
3. videos
4. social media
5. music with lyrics or vocalisations
6. messaging 
7. lax self-care
8. dehydration
Don't think Viewmodel will replace SaveInstanceState
Tags: android, viewmodel, jetpack
Published: 2019-11-09 09:41:32

---
title: Don't think Viewmodel will replace SaveInstanceState
published: true
description: Because Viewmodel would save state, but it's not same as SaveInstanceState.
tags: #Android #ViewModel #Jetpack
cover_image: https://images.unsplash.com/photo-1536733203354-a125031aa773?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80
---

##Different Capabilities
Maybe some developer will excited about the ``ViewModel`` when it can save the state, and someone will thinking to replace ``SaveInstanceState`` into ``ViewModel``. After that you implement that you will get some mistake.

``ViewModel`` will only preserve data ``onConfigurationChange`` and when activity/fragment still processed and not get killed. So when you get state after activity get killed you should implement ``onSaveInstanceState ``and ``onRestoreInstaceState`` without ``ViewModel``. So would you choose one of them or use both of them. actually ``Viewmodel`` and ``SavedInstanceState`` complete each other, such as overlap in capability but not as a subset or superset of the other. You still need both of that.

``ViewModel`` and ``SaveInstancesState`` can kept the state ``onConfigurationChanes``, but only ``SaveInstanceState`` do that although the activity get killed.
So storing state when event activity or fragment is killed  by system, you will need ``onSaveInstanceState`` or ``onRestoreINstanceState`` not ``ViewModel``. or the other alternative you can use ``StateSaveHandle``.

But ``ViewModel`` have the other capability that ``SaveInstanceState`` dont have. ``ViewModel`` can continue operation process that was already started before confguration change.

I will give some example, lets imagine when your device in portrait screen, and you try to request some API but you have poor connection, before the request complete you try to rotate your device into landscape, and look what happen. If you use ``SaveInstanceState`` your current request will terminate first and then start the request again or restart the process. the other hand if you use ``ViewModel``, when you trigger configuration change the current process/request wouldnt terminated it will continue. 

##Conclusion
``ViewModel`` can keep state when the activity/fragment still alive, and then it can continue current process after configuration change. While ``SavedInstanceState`` can keep sate when activity/fragment alive or get killed, but the other hand when configuration change the current process will terminate and restart the process again.