teleren/devto huggingface dataset:
How make analytics for your app in React Native ?
Tags: reactnative, javascript
Published: 2018-04-09 06:05:38

---
title: How make analytics for your app in React Native ?
published: true
description: Small script fro your app.
tags: reactnative, javascript
---


Hi, I'am Sergey and i like React Native.

Recently me needed analytics for my app in React Native and i make small script.

1. Go to https://appmetrica.yandex.ru , yeah this is Russian service for analytics, but he very cool.

2. Registration and create 'metrica'

3. Write this code

```
const API_KEY = 'WRITE_THIS_YOUR_KEY'
const BOTAN_URL = 'https://api.botan.io/track';
const DEFAULT_NAME = 'Message';

function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
  //better you use really UID in your app
}

export default function sendEvent(message, name = DEFAULT_NAME) {
    return fetch(`${BOTAN_URL}/?token=${API_KEY}&name=${name}&uid=${getRandomInt(0,9999)}`, {
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
          },
          method: "POST",
          body: JSON.stringify(message)
    })
    .then(res => res.json())
    .then(data => {
      return data
    })
}

```

4. Done!

How use this function?

```
componentDidMount() {
        getAllCategories()
        .then(data => {
            
            let categories = data.response.category
            
            sendEvent({},'loadCategories')

            this.setState({
                categories : categories,
                end_loading_categories : false
            })
        })
        .catch(() => {

            sendEvent({},'loadCategoriesError',() => {})

            this.setState({
                end_loading_categories : false
            })
        })
    }

```

Here's how it looks on the charts.

![Charts](https://thepracticaldev.s3.amazonaws.com/i/vhkqdxxbs2kn5t9zybmx.png)
Privacy On The Net
Tags: discuss
Published: 2018-04-09 05:10:44

---
title: Privacy On The Net
published: true
tags: discuss
---

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

I went to sign up for an Instagram developer account and saw the effects of the Facebook data scandal. Made me think, how do you solve the problem of privacy when business models are geared around knowing you better than you know you.
I recently discovered Parcel, and it's amazing
Tags: node, javascript, webdev
Published: 2018-04-09 04:46:22

---
title: I recently discovered Parcel, and it's amazing
published: true
description: Parcel is a new web asset bundler that focuses on ease of configuration, speed, and versatility
tags: node, javascript, webdevelopment
---

While playing around with WebAssembly and rust, I stumbled across [a plugin](https://github.com/koute/parcel-plugin-cargo-web) for an asset bundler I hadn't heard of before. Admittedly, my initial thought was "Dammit, why couldn't they just use webpack?" After all, webpack has served all my needs in the past and has seemingly become the defacto standard. "Time to roll up my sleeves and learn how to configure this thing..." I thought.

The first thing that struck me about [Parcel](https://github.com/parcel-bundler/parcel) is that there *is* no configuration file. In theory, I thought, that's great, but inevitably I'll need fine-grained control over *something.* 

*(Narrator: "He has yet to encounter such a scenario.")*

Indeed, I've only used Parcel for two personal projects thus far, but I haven't had to configure anything at all. Everything Just Works™, and I've used it to do some relatively exotic things:

- Compiling rust to WebAssembly and bundling the resulting artifact
- Bundling and exposing markdown files as React components

And then some not-so-exotic things, which are all supported out-of-the-box: Javascript, TypeScript, CSS, HTML, etc.

### More than just zero configuration

Zero configuration is a huge selling point, but it's not the only thing Parcel has going for it. Whereas bundlers like webpack transform javascript files exclusively, Parcel can transform anything (correction: webpack 4 can now transform other types of files). Any file type not supported out-of-the-box can be supported by way of plugin. The practical implication here is that you can use any type of file as your entry point, not just javascript. This allows for a more natural way of bundling assets. For example, I can specify an HTML file as my entry point, and it will recursively locate and bundle all assets from there.

Parcel accommodates this by operating at a fundamentally higher level than its counterparts–It actually *parses* supported file types and transforms the resulting abstract syntax tree. When it encounters a javascript file, it transforms `import` and `require` declarations. When it encounters HTML, it will transform `script` and `link` tags. When it encounters CSS files, it transforms `import` and `url` declarations.  

## Oh and it's f***ing fast

According to the README on Parcel's github page, it's twice as fast as webpack when not caching assets, and nearly an order-of-magnitude faster when caching assets. It caches assets by default, and I have yet to encounter a situation where I've needed to turn off caching. Anecdotally, the numbers check out.

So, next time you're in need of an asset bundler, you should seriously consider Parcel.
Can we say that JS can be compiled on Node.js? [Novice Quesiton]
Tags: javascript, discuss, python, compiler
Published: 2018-04-09 04:43:56

---
title: Can we say that JS can be compiled on Node.js? [Novice Quesiton]
published: true
description: 
tags: javascript, discuss , Python, compiler
---

I am reading [**You Don't know JS**](https://github.com/getify/You-Dont-Know-JS/blob/master/scope%20%26%20closures/ch1.md) it says,

> but despite the fact that JavaScript falls under the general category of "dynamic" or "interpreted" languages, it is in fact a compiled language. It is not compiled well in advance, as are many traditionally-compiled languages, nor are the results of compilation portable among various distributed systems.

So is it trying to say that JS compiled on Node.js

my another question is if Node.js is created with C++ then why do you we call it a JS platform/framework? Is it like PyPy? where Python compiler itself runs Python?

Any explanation/advice/guidance is appreciated. Sorry if I've not used any more technical terminology.
How can We implement Data Structures and Algorithms in Backend Frameworks to reach O(log(n)) Run Time ?
Tags: frameworks, algorithms, python, javascript
Published: 2018-04-09 03:56:35

---
title: How can We implement Data Structures and Algorithms in Backend Frameworks to reach O(log(n)) Run Time ?
published: true
description: 
tags: frameworks, algorithms, python, javascript
---

Backend frameworks/platforms like Node.js(EcmaScript) and Django(Python).

for example, I do think that calling SomeClass.objects.all().filter() will loop the whole data ( O(N) Linear Way) until it gets the full results . I think it would be okay if the data is kept small up to medium but for large data; I don't think so. Imagine million of these data and thousands of requests per day. How can We handle those request in an efficient way

* I can call raw SQL in Django (suppose I'm working with Django) if I need, that can allow for more efficient request with large amount of data

* I believe in that too.However if I need to make that, first I need to organize the data in sql appropriately  ( using Data Structures techniques like Hash Tables or Balanced Binary Tree) then I can quickly retrieve them later using Algorithms. What I'm asking is " Am I thinking Right?"  "is what I want to accomplish is right and achievable ?"  " Do Big Companies implement their own DS and Algorithms in that way ?" I've seen many people teaching DS and Algorithms separately and talk a lot about them and their power. But I've never seen both of them discussed and implemented in any framework by Teachers!!

From What I see , I started to believe that No Body Really care and I don't know Why?

* Being out of college with CS, and always only worked my way around DS & Algorithms mostly through Online Judges I don't know how to merge my knowledge into this?

> I hope my question doesn't sound vague or irrelevant I'm in learning phase, so please ignore any immaturity. Any explanation/advice/guidance is appreciated.
Is Docker the New Git?
Tags: docker, git, devops
Published: 2018-04-09 01:54:38

---
title: Is Docker the New Git?
published: true
description: Docker may not address your biggest concerns, but it might still be worth it.
tags: Docker,Git,DevOps
canonical_url: https://www.codingblocks.net/programming/is-docker-the-new-git/
---

Git is currently the default choice for source control. We may take that for granted today, but it was not always a clear winner. [Mercurial](https://www.mercurial-scm.org) was a serious contender for the [DVCS](https://en.wikipedia.org/wiki/Distributed_version_control) crown, but perhaps [the fiercest competition came from the status quo](https://www.google.com/search?q=git+vs+svn&oq=git+vs+svn&aqs=chrome..69i57j0l5.1487j0j7&sourceid=chrome&ie=UTF-8).

Some of the arguments that I am hearing about Docker today remind me of the arguments against Git in 2010 [while it was rocketing towards ubiquity](https://softwareengineering.stackexchange.com/questions/136079/are-there-any-statistics-that-show-the-popularity-of-git-versus-svn).

Arguments like...
* "My team is already invested in tech x..."
* "I don't particularly want my source control to be distributed..."
* "But we hardly ever branch..."

The heart of these arguments is the same:

_"It solves a problem that I don't have"_

Fair enough. Git and Docker both have a significant learning curve and can be a costly switch. This is not a change you should take lightly.

_But maaaaaaaybe..._

There are clear benefits to both <a href="https://www.atlassian.com/git/tutorials/why-git">Git</a> and <a href="https://dzone.com/articles/top-10-benefits-of-using-docker">Docker</a>. Containers are safe, convenient, and consistent for developers and deployments. They eliminate certain classes of problems, and they lower the <a href="https://blog.rapid7.com/2015/08/20/free-docker-logging-removing-barriers-for-mass-innovation/">barrier to innovation</a>.  I don't think there is much argument over that. The disagreement is over the <b>value</b> of those benefits.

<b>That</b> is why I am reminded of Git...and <a href="https://www.computerworld.com/article/3192897/cloud-computing/cloud-vs-on-premises-finding-the-right-balance.html">Cloud vs. On-Prem</a>...and <a href="https://www.quora.com/What-are-the-pros-and-cons-of-Java-and-C++">Java vs. C++</a> before that.

Point is: Docker may not address your <em>biggest</em> concerns, but it might still be worth it.

What do you think?

Will Docker be requisite for programmers in the same way that Git is today?
Week 1 Day 1: Design an Ecommerce Listing
Tags: ui, weeklyui, react, design
Published: 2018-04-08 22:56:43

---
cover_image: https://thepracticaldev.s3.amazonaws.com/i/1u140omo4551k97bg0f3.jpg
title: "Week 1 Day 1: Design an Ecommerce Listing"
published: true
description: "Week 1 Day 1 of my Weekly UI challenge: design the component!"
tags: ui,weeklyui,react,design
---

Welcome to Week 1, Day 1 of my Weekly UI challenge! As I stated in the [announcement post](), week 1 will focus on an **ecommerce listing** UI component; each day throughout this following week, I will pick one or two (usually related) subelements of the design to implement. For day one, our goal is to…

## Design the component

I personally used Sketch to design this week's component, but you can use Sketch, a similar UX/UI design program like Adobe XD, or really any other program (or just paper and pen/pencil!) to design your component.

If you decide you would rather not design your own component, you are more than welcome to follow along using my designs, but I think you'd really get the most of it if you designed your own. (plus I'd love to see what you all come up with!)

Here is what the listing component will look like, including a number of the component's alternative states:

![An ecommerce listing component design, with color-coded states for various component states, like "sold out", "added to cart", "remove from cart", etc.](https://raw.githubusercontent.com/geoffdavis92/weekly-ui/master/assets/ecommerce-listing/ecl-single-variants%402x.png)


This is what the various states of pieces of the component look like across a row of listings:

![A row of ecommerce listing components, with different states visible in respective listing components](https://raw.githubusercontent.com/geoffdavis92/weekly-ui/master/assets/ecommerce-listing/ecommerce-listing-design%402x.png)

## Now it is your turn

Hop on those design programs (or get out that pen and paper pad) and design your own **ecommerce listing**! Below is a calendar of what features I will be implementing on which day, as well as a few resources that may help you. 

Also, please add your repos and/or images of your designs in the comments for inspiration! I would love to see what designs you all create.

Happy designing! 🎉

### Week 1 Calendar

1. Design component 🎯
2. Display product name, price, and image
3. Add to cart button, favorite button
4. Sale price display, sold out states
5. Color variant thumbnail buttons
6. 100% a11y score
7. Tweaks, refactors, fixes

### Resources

- [Best Practices for Cards](https://uxplanet.org/best-practices-for-cards-fa45e3ad94dd) (since my design, and some ecommerce platforms, utilize the "card" type of design for listings)
- [Best Practices for Buttons](https://uxplanet.org/button-ux-design-best-practices-types-and-states-647cf4ae0fc6)
- [7 Rules for Creating Gorgeous UI](https://medium.com/@erikdkennedy/7-rules-for-creating-gorgeous-ui-part-1-559d4e805cda)
- [a11y Project](https://a11yproject.com/) (*great* resources for creating accessible web sites/apps)
- [Writing CSS with Accessibility in Mind](https://medium.com/@matuzo/writing-css-with-accessibility-in-mind-8514a0007939)
How do you deal with recruiters?
Tags: career, discuss
Published: 2018-04-08 21:36:12

---
title: How do you deal with recruiters?
published: true
description: 
tags: career, Discussion 
---

Almost daily, I get LinkedIn notifications, of some recruiter who tells me "I have been reading your resume and I think you're a perfect fit" or "You're the one"-Messages. The thing is, and I believe that, that there are recruiters out there, who really care about good candidates. But most of the time, I get contact to subjects I don't really relate to. Something like, a C++ DEV position (I've never touched C++) or after moving company (and even moving countries ), they do contact me and try to convince me in their email that I would be a perfect fit. This is to some extend very upsetting, as they clearly just spam me... How do you deal with this kind of people? Just ignoring them?
“dotnet new install” issue – “Error: Value cannot be null”
Tags: dotnet, template, core, cli
Published: 2018-04-08 19:34:56

---
title: “dotnet new install” issue – “Error: Value cannot be null”
published: true
canonical_url: https://www.slightedgecoder.com/2018/04/08/dotnet-new-install-issue/
description: How to resolve dotnet new installation issue.
tags: dotnet, template, core, cli
---

[.NET CLI](https://github.com/dotnet/cli) has made it easy to create [a new template](https://blogs.msdn.microsoft.com/dotnet/2017/04/02/how-to-create-your-own-templates-for-dotnet-new/).
But sometimes you might be frustrated the following not-so-helpful error message while creating a SPA template.
```bash
> dotnet new -i .\NewTemplate
Error: Could not install ".\NewTemplate".
Error: Value cannot be null.
Parameter name: key
```


## 🤔 The Cause

According to [Mike Lorbetske](https://github.com/mlorbetske), the error occurs when one of the `node_modules` folders contain a `template.json` file.

> TL;DR – the particular node modules that have been added to the project contain a template.json file

## 💡 Resolution

So if you have a `node_modules` folder in your template, **delete it** then you are good to go.
###### NOTE 📝: The next version of .NET CLI templating engine (dotnet new3) has --trace:authoring option but wouldn’t be helpful in this case [according to Mike](https://github.com/dotnet/templating/issues/1498#issuecomment-378501905).

## 🚪 Closing Remark

I’ve reported [the issue](https://github.com/dotnet/templating/issues/1498) on GitHub and Mike is preparing a PR to address this issue.
The issue page has the comprehensive steps to reproduce the error and how to resolve it.

**** UPDATE 2018/04/10 ****
The fix will be available in ["The CLI after 2.1.300-preview2"](https://github.com/dotnet/templating/issues/1498#issuecomment-380312603).


This issue was found while creating a new SPA template for [ASP.NET Core with React.js with ES6](https://www.nuget.org/packages/ReactES6.Web/) because the default template uses TypeScript.

You can find more about how to use it in my previous article, [ASP.NET Core 2 React.js Template with ES6 (not TypeScript)](https://dev.to/dance2die/aspnet-core-2-reactjs-template-with-es6-not-typescript-f71) .😉.
What do you think is the relationship between exercise and goal-achieving?
Tags: discuss, fitness, exercise, goals
Published: 2018-04-08 19:25:41

---
title: What do you think is the relationship between exercise and goal-achieving?
published: true
description: 
tags: discuss, fitness, exercise, goals 
---
Do you think software engineers, who exercise regularly(even casually) are doing better on goal achieving? Exercise looks like is having some "cannot-be-ignored" health and mental benefits.
Is it important to learn Android testing as a beginner?
Tags: discuss, android, beginners, testing
Published: 2018-04-08 18:09:38

---
title: Is it important to learn Android testing as a beginner?
published: true
description: Should I learn Android testing as a beginner?
tags: discuss, android, beginner, testing
---
I am currently learning Android development. It seems everybody is talking why every dev should use unit tests and how it is important. But as a beginner I find it really difficult to understand with all new concepts. Should I learn about testing before getting job or should I focus more on Android core concepts and make more apps for practice?
Which process do you follow before code?
Tags: discuss
Published: 2018-04-08 13:14:44

---
title: Which process do you follow before code?
published: true
description: 
tags: discuss, 
---

What do you normally do before coding some hard algorithm? Write directly the tests? Write some diagram first to detect what to test? Which type of diagrams or notes do you use?

And, do you follow the same steps for more easy algorithms? Or do you miss some steps?
Tankr Online Game
Tags: frontend, projects
Published: 2021-02-14 12:10:21

---
title: Tankr Online Game
published: true
date: 2018-04-08 10:19:41 UTC
tags: Frontend,Projects
canonical_url: https://bogdancornianu.com/tankr-online-game/
---

Together with Zoltán Szeredi at the 2017 HackTM edition we built a clone of the “Tanks” game. We used [PhaserJS](https://phaser.io/) which is a great HTML5 game framework.  
You can play the game online and also see the source code on Github:  
[https://github.com/hacktm2017BoZo/Tankr](https://github.com/hacktm2017BoZo/Tankr)

[![Tankr online game](https://i2.wp.com/bogdancornianu.com/wp-content/uploads/2018/04/Tankr.png?resize=700%2C345&ssl=1)](https://i2.wp.com/bogdancornianu.com/wp-content/uploads/2018/04/Tankr.png?ssl=1)

The post [Tankr Online Game](https://bogdancornianu.com/tankr-online-game/) appeared first on [Bogdan Cornianu](https://bogdancornianu.com).
How can I improve this while loop code snippet?
Tags: discuss
Published: 2018-04-08 08:26:59

---
title: How can I improve this while loop code snippet?
published: true
tags: discuss
---

So, I have this code snippet.

```java
while (!Character.isWhitespace(this.source.charAt(this.currentCharIndex))) {
    char c = this.source.charAt(this.currentCharIndex);
    // ...
}
```

What it does is just basically loops through a string until it hits a white space character.

However, I find the code a bit messy. **How can I improve it?**

I can try this code snippet instead.

```java
char c = this.source.charAt(this.currentCharIndex);
while (!Character.isWhitespace(c)) {
    c = this.source.charAt(this.currentCharIndex);
}
```

It looks cleaner but `this.source.charAt(this.currentCharIndex)` seems redundant (the same as the previous snippet) so I need your opinion on how you would tackle this problem.

Thanks! :D
Agonesを調べてみた
Published: 2018-04-08 07:06:39

---
title: Agonesを調べてみた
published: true
description: 
tags: 
---

# Agonesとは何か
* Kubernetes上で動く、Dedicated Serverホスティングシステム
    * AWSのGameLiftのようなものをKubernetesで動かせるソフトウェア
* 開発主体はGoogleとUbisoft
* オープンソース、Apache License 2.0

# 現在の状態
* リリースされている最新バージョンはv0.1。現在v0.2の開発中
* アルファリリース状態で、Production Readyではない


# 実装
* AgonesサーバはGoで書かれており、ServerSDKはGoとC++のものが提供されている
* AgonesサーバとGame Serverの通信はTCP（gRPC）で行う
    * 準備完了を知らせるReady()、プロセスが生きていることを知らせるHealth()、プロセスが終了することを知らせるShutdown()がある
    * ゲームサーバとゲームクライアントとの通信に関する制約は特に無く、プロトコルはTCPでもUDPでもよさそう

# やってみた
* KubernetesでAgonesクラスタを起動するところ
    * https://github.com/GoogleCloudPlatform/agones/blob/master/docs/installing_agones.md
* AgonesでGameServerを起動するところ
    * https://github.com/GoogleCloudPlatform/agones/blob/master/docs/create_gameserver.md
* 感想
    * Kubernetesわからないのでよくわかってない
    * GameServerのスケーリング(プロセス数)の指定の仕方がわからない
    * Sidecarとは？
    * 終了したGameServerプロセスは終了しっぱなし？勝手に再起動するには？

# 参考サイト
* GitHub
    * [GoogleCloudPlatform/agones: Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes](https://github.com/GoogleCloudPlatform/agones)
* ブログ記事
    * [Google Cloud Platform Japan 公式ブログ: Agones ―― Kubernetes 上でのゲーム サーバー構築をサポートするオープンソース プロジェクトが始動](https://cloudplatform-jp.googleblog.com/2018/04/introducing-Agones-open-source-multiplayer-dedicated-game-server-hosting-built-on-Kubernetes.html)
Static Type checker. Which and Why do you use it ?
Tags: flowtype, typescript, javascript, discuss
Published: 2018-04-08 05:49:12

---
title: Static Type checker. Which and Why do you use it ?
published: true
description: 
tags: flowtype, typescript, javascript, discuss
---

I'm a JS developer and a React Beginner . I'm currently using [Flow](https://flow.org/) 

because of one reason, that I don't want to learn a new language and compile it again to JS

Which  TypeChecker you use and  Whats your reason ?