teleren/devto huggingface dataset:
Tips for doing code reviews, keeping code consistent & refactoring
Tags: todayilearned, programming, beginners
Published: 2019-12-11 13:00:20

*TL;DR notes from articles I read today.*

### [How to do good code reviews](http://bit.ly/2P6McVd)

- Set measurable goals and capture metrics, but do not set too many. Good code must work as intended, have high readability, and perform optimally. 
- Ask deep questions and confirm your understanding at each step, until your knowledge of the code is as good as the developer’s. 
- Address everything you may think relevant, not just what you were told.
- Look for code that is repeated, non-modular, or flouting standard conventions.
- Avoid reviewing code for more than 60 minutes or more than 400 lines at a time. Increase the frequency of reviews so you can take time to identify the best solutions.

*[Full post here](http://bit.ly/2P6McVd), 6 mins read*

---

### [Why consistency is one of the top indicators of good code](http://bit.ly/2t14M8B)

- Consistency can be defined as both conformity and uniformity.
- Consistency in code allows you to make accurate assumptions and predictions about its behaviour and implementation.
- Small continuous improvements in the approach of doing things can introduce a great inconsistency in the overall code over time. Try to ensure complete adoption of the new approach, phasing out the old one entirely. 
- Where both approaches must remain, at least preserve consistency within verticals or modules.
- Name things consistently (so that similar objects sound similar and dissimilar ones sound different) and let the name reveal context, behavior, and intent.

*[Full post here](http://bit.ly/2t14M8B), 6 mins read*

---

### [Finding the time to refactor](http://bit.ly/2sbC70b)

- Think of programming as writing code - that works, is easily readable and easy for other developers to modify and extend in the future.
- In test-driven development, get used to thinking of a 'red-green-refactor' cycle. The green state ensures code passes tests, but the refactor ensures it stays clear and maintainable. 
- Make refactoring integral to every work schedule. Take a few minutes to clean up code, as soon as tests pass, with better names and extracting private methods and classes, etc.
- Whenever adding a feature or fixing a bug, if you have to modify any piece of code that was hard to understand, refactor it right there and then.
- When you try to introduce something new and the existing design does not work, refactor the design so the new addition is easier to make.

> ‘Make the change easy, then make the easy change.’ - Kent Beck 

*[Full post here](http://bit.ly/2sbC70b), 4 mins read*

--- 

*[Get these notes directly in your inbox every weekday by signing up for my newsletter, in.snippets().](https://mailchi.mp/appsmith/insnippets?utm_source=devto&utm_medium=post08&utm_campaign=is)*
Which talk would *you* want to see at Kafka Summit
Tags: kafka, writing, techtalks
Published: 2019-12-11 12:46:40

I did talk about using Kafka with GraphQL at GraphQL summit. Now I would like to go speak at Kafka Summit as well. You can help by telling which of the three proposals I had in mind, you would like to see most. Also [you should submit as well](https://dev.to/rmoff/why-you-should-submit-a-talk-to-kafka-summit-2jf7).

Here they are:


##Expose your Kafka using GraphQL

GraphQL is a relatively new way to describe API's and offers subscriptions. Subscriptions are a way to send a stream of updates to the client. Often they are implemented using web sockets, which makes it hard to scale.

I will explain a solution by using a demo application, which is a bank simulation. Also I will share some benchmarks to prove the scalability. This will be done mainly using Clojure, but I also implemented the GraphQL endpoint in Java, Kotlin, and some other languages.

The demo project also contains a load test, which can be used on all the implementations in order to compare them.


##From Avro to GraphQL, blazingly fast

Rust is called a system programming language but it's getting more and more use-full as the ecosystem grows. As it's strongly and strictly typed it should be possible to derive both the internal needed data structured to handle binary data based on Avro schema's and to derive a GraphQL schema which can be used by frontend applications.

I will share the results of this journey, with at least some demo, and if all goes well a docker image that can be used to easily interact with Kafka using GraphQL.


##Using the Confluent Schema Registry with Rust

In this talk I will go into some of the challenges I faced making a Rust library that is as much as possible similar to the Java serializers. There are a couple of challenges here.
There is no default way of adding serializers with consumers and producers. Another thing is that there is no classpath in Rust to dynamically create specific class instances. Also it turned out the Avro library for Rust didn't support all complex types well.
That being said there are some advantages to using Rust. Like the memory safety, fast startup times, and being able to build very tiny Docker images.
Pattern of the Week:AbstractFactory
Published: 2019-12-11 12:32:54

Type: Creational

Purpose: Provides a way to encapsulate a group of individual factories that have a common theme

Related Patterns: 
•	Factory
•	Prototype (configure factory dynamically)
•	Singleton (1 Abstract Factory)

We have a requirement where we need to create control library and the same library supports multiple platforms but the client code should not be changed if we import from one operating system to the other. The solution is 

The client uses the GuiFactory to get the required factory of the supported operating system and calls the same Show Method. Now depending on the platform we change the factory but the client implementation remains the same. If support for new operating system is to be added we need the new factory and the exact implementation of the buttons and without changing the existing code we can support the new platform

```java
/* GUIFactory example -- */

interface GUIFactory {
    public Button createButton();
}


class WinFactory implements GUIFactory {
    public Button createButton() {
        return new WinButton();
    }
}


class OSXFactory implements GUIFactory {
    public Button createButton() {
        return new OSXButton();
    }
}

 

interface Button {
    public void paint();
}


class WinButton implements Button {
    public void paint() {
        System.out.println("I'm a WinButton");
    }
}


class OSXButton implements Button {
    public void paint() {
        System.out.println("I'm an OSXButton");
    }
}


class Application {
    public Application(GUIFactory factory){
        Button button = factory.createButton();
        button.paint();
    }
}

public class ApplicationRunner {
    public static void main(String[] args) {
        new Application(createOsSpecificFactory());
    }

    public static GUIFactory createOsSpecificFactory() {
        int sys = readFromConfigFile("OS_TYPE");
        if (sys == 0) {
            return new WinFactory();
        } else {
            return new OSXFactory();
        }
    }

}
```

(Code example courtesy of http://en.wikipedia.org/wiki/Abstract_factory_pattern)
Why *you* should submit a talk to Kafka Summit
Tags: speaking, devrel, conferences
Published: 2019-12-11 12:23:07

_This is a manual unroll of my [Twitter thread](https://twitter.com/rmoff/status/1204701951797141504)_

---

The [Kafka Summit London call for papers](https://kafka-summit.org/kafka-summit-london-2020/speakers/) (CfP) is open until this weekend. 

I speak to loads of people doing really interesting things with Kafka but who don't think they've got anything to talk about.

But guess what: just because you're not running Kafka at mega-scale on Kubernetes in the cloud with service meshes whilst standing on one leg and reciting poetry, doesn't mean you've not got a good story to tell.

Whilst people love to hear what the cool kids are doing at the cutting edge, but then they have to go back to their offices and do some real work. And if that involves Kafka, they will *totally* benefit from hearing your story about what you're doing with Kafka.

They'll benefit from understanding *why* you're using it how you're using it, how you're designing your data models, building your services, the mistakes you've made, the things you'd do differently, how you managed implementing a new technology, how you got organisational buy-in…all that ""dull"" (and I put that in BIG air quotes) stuff that we OTHER PEOPLE will _also_ have to deal with. That's one of the whole purposes of conferences - to SHARE knowledge and experience.

Rewind the clock to before you started your Kafka implementation - what conference talk would *you* like to have heard beforehand? Well *you* are now in a great position to deliver *that* talk :-)

If you're even _considering_ submitting, hit me up on [Twitter](https://twitter.com/rmoff/) or email and we can help you figure out what your abstract could look like.
Gorilla Chat - Decentralized text chat using Blockstack!
Tags: gorillachat, blockstack, decentralized, webdev
Published: 2019-12-11 12:21:29

We're excited to unveil Gorilla Chat!

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/q2sf16w3lrlpa2f7mko8.PNG)

Make group chats or 1-on-1 conversations, entirely over the decentralized web using Blockstack!
We're currently early in development though, so don't expect anything too crazy!

Anyway, come check it out at https://gorilla.chat!


Stay in the know:
https://twitter.com/JunglePlexus
https://www.instagram.com/jungleplexus/
https://www.reddit.com/user/JunglePlexus
https://www.facebook.com/Gorilla-Chat-100106268159987/
https://www.youtube.com/channel/UC7EYSCceyazmeLNPXj9DxFA
"Angular[/RxJS] can waste your time" series. Pitfall #7 - forkJoin vs zip 
Tags: rxjs, angular, webdev
Published: 2019-12-11 12:18:20

---
title: "Angular[/RxJS] can waste your time" series. Pitfall #7 - forkJoin vs zip 
published: true
description: Beware forkJoin vs zip RxJS operators differences. Watch to be prepared.
tags: rxjs, angular, webdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pm2qsgtg2zwc1at5q47u.png
---

So you use RxJS [zip](https://rxjs.dev/api/operators/zip) function to combine multiple observables.
But zip can have a pitfall. Which one?

Watch the video *"forkJoin vs zip RxJS operators differences"* to find out!

{% youtube H9N1JxHWOvw %}

This video series will become a part of my future video-course with advanced techniques of mastering Angular/RxJS. Want to get a notification when it is done? Leave your email here (and get free video-course): http://eepurl.com/gHF0av
React TypeError property of 'label' undefined when order of removal changes in multidropdownlist
Tags: react, dropdownlist
Published: 2019-12-11 12:02:13

I have a multiple dropdown list select. Say if i select items 1 and 3, then remove 1 and 3 in that order there is no issue, but if I remove items in some reverse order then I get : TypeError property of 'label' undefined?
React Router not Working in Production
Tags: help, react, node
Published: 2019-12-11 11:35:25

Hi all,

I have had this issue for a couple of weeks now and I have run out of ideas on what to try.

I have built a website using create-react-app for a friend. I have used react router for the links through out the website.

When I put the website live on a server, I'm not able to type the URL in the browser. If I do so, I get a Not Found error. It also happens if I'm on page on the website and I refresh it.

I have been told I need to add backend with nodejs and more specifically Express backend to the project so I can direct the pages to the index.html which I did but I still can't get it to work.

![help](https://media0.giphy.com/media/P8X4lemg5Iphe/giphy.gif)

Any suggestions?

Thanks
Be Your Own Boss 
Published: 2019-12-11 11:34:19

Yes, just the quote has stated regarding to time is the scare resource, so therefore, we must make every effort to enrich our lives while we can during a brief time of living. We must be our own boss that can manage and use time to bring huge quantity of wealth that enrich our being in good health, which enable us to live a lifestyle of abundant freedom from financial down draining - worry to death and freedom of time to spend with family members, relatives, and friends - going wherever and whenever we wish, do you think is this what we all have been searching or yearning for since birth?
Database Design 
Published: 2019-12-11 11:04:01

Database Design
profile Pcykab Abiola
Design a database that will contain these three entities: 1. Patient 2. Doctor 3. Prescription State the characteristics(attributes) of each of these entities and relate the three entities showing the cardinality of the relationship i.e. one-to-one many-to-many etc. Note: for the above, you must draw an ER diagram. 2. translate the above into a functional database using Ms-Access. 3. perform the following SQL queries on your database: i) select the patients that are been treated by a particular doctor ii) select the drugs prescribed to any particular patient in your database. iii) select patients that have the same kind of a particular ailment. Create the above as a term paper
Singularity
Tags: azure, react, serverless
Published: 2019-12-11 11:03:59


I am lazy as ×××× ( fill in whatever that suits u 😉) so I have never considered writing about anything ...It too much for me but hay u have to start somewhere, hence I have decided to break the dragon eggs and let my inner dragon out ...

This is part 1 of a series of articles or it could be the first and last one who knows !  

Prologue:

Apart for being lazy I have never contributed to open source projects as I was spending most of my free time doing photography and watching TV. I don't have to tell you that it hurts when u do  interviews so I decided to create showcase project with all fancy techno stuff that I want to learn and/or want to use.
After 6-8 weeks, I managed to create decent prod ready application ( client and server less backend ) and that's what I am going to write about.

My initial plan was to create cross platform responsive app with serverless architecture preferably with CQRS/Event Sourcing (yeah baby) and functional language like F#. 

I currently work in the hospitality industry so it's as natural for me to pick the same domain for the sake of familiarity. 

Here is my initial tech stack :

FE :
React & some fancy component library to force design language i.e. Ionic /Material UI etc.
BE:
Everything Azure 

For BE I could send 130 euro per month as it comes with MSDN subscription .

For FE : I choose React as it's my personal choice than anything else. I love it for its simplicity .  

Component libraries : This was really a difficult choice to make. I tried a couple of libraries like MatrtialUI, React Bootstrap , Ant Design etc. My basic requirement was to have one library that has decent scheduler component , data driven components and built for desktop web app. After couple of days of painful evaluation, I came to the conclusion that none of these libraries provide what I wanted . 
But I have to start with something so I picked react-uwp due to its native win 10 fluent design. It provides nice themes and sidebar for electron desktop app and decent basic controls. I was happy about my choice and I made good progress in one week.  
I would write tomorrow (hopefully ☺️) about what I had learnt in that first week..

Ciao !
Find SHA1 keys quickly from jks and apk
Published: 2019-12-11 11:02:44

---
title: Find SHA1 keys quickly from jks and apk
published: true
description: It's frustrating to find SHA1 key every single time. This article is a reminder for me how to do it.
tags: 
---



xubuntu

Specs are
- xubuntu 19.04
- fresh android studio
- fresh flutter installation

For this command to run we need keytool.

All the guides on the internet will ask you to go to jdk/bin.
However, Now android studio includes jdk as part of the installation.

So we can edit our `.zshrc` file and add JDK etc to the path.

Mine has platform tools, tools,flutter and studio's jdk added.

open zshrc
`nano .zshrc`

Paste these and change those paths as per your installation

```
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/home/prasadsunny1/.oh-my-zsh"
export ANDROID_HOME="/home/prasadsunny1/Documents/sdks/android"
export PATH="/home/prasadsunny1/Documents/sdks/flutter/bin":$PATH
export PATH="/home/prasadsunny1/Documents/android-studio/jre/bin":$PATH

path=("${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools" $path)

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"


```

run this command 
`keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android`

you should get an output like this
```
➜  ~ keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Alias name: androiddebugkey
Creation date: 10 Dec, 2019
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: C=US, O=Android, CN=Android Debug
Issuer: C=US, O=Android, CN=Android Debug
Serial number: 1
Valid from: Tue Dec 10 23:52:27 IST 2019 until: Thu Dec 02 23:52:27 IST 2049
Certificate fingerprints:
	 MD5:  xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
	 SHA1: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
	 SHA256: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
Signature algorithm name: SHA1withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 1

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /home/prasadsunny1/.android/debug.keystore -destkeystore /home/prasadsunny1/.android/debug.keystore -deststoretype pkcs12".

```

Here in the middle, you have your SHA1 key.



#Find SHA1 from your apk

- extract apk and get META_INF/**.RSA
- find keytool inside androidstudio installation and open powershell there
- run `keytool -printcert -file name.RSA`

That's all, Thaks for reading

Follow me on twitter http://twitter.com/prasadsunny1
Proxy API calls to your server during Angular development
Tags: angular, development, javascript, typescript
Published: 2019-12-18 16:16:19

---
title: Proxy API calls to your server during Angular development
published: true
date: 2019-12-11 11:00:00 UTC
tags: angular, development, javascript, typescript
canonical_url: https://roelofjanelsinga.com/articles/proxy-api-calls-to-your-server-during-angular-development
---

!["Angular logo"](https://thepracticaldev.s3.amazonaws.com/i/n3j4ly1d6p2xdn8l6xgc.jpg)

# Proxy API calls to your server during Angular development
When you're developing an Angular application, you'll most likely use "ng serve" to display your application. When you're trying to request data through API calls to "/api/some/resource" you get a 404 response. But why? Well Angular sends the API request to http://localhost:4200/api/some/resource. Because you're not specifying a domain in your services, just a path, Angular will send the request to the current domain, which is fine for development, but will break in development.

This is where the built-in proxy comes into play. When you're using "ng serve", you're serving the application at http://localhost:4200. This means the services will call the API at http://localhost:4200/api/some/resource, however, your API server doesn't exist at that URL and returns a 404 for everything. Your API server is served at something like http://localhost:8000/api/some/resource. By creating this proxy, the development server accepts the requests at port 4200 and sends them to port 8000 behind the scenes. So now you get your data instead of a 404.

## The code for this to work

This is the config you would be using for the situation I painted here:

```json
{
  "/api": {
    "target": "http://localhost:8000",
    "secure": false
  }
}
```

This config should be placed in a new file called: "proxy.conf.json" and you should place this in the src folder of your Angular project. Next, you need to point to this file in "angular.json". Open the file and search for the "serve" section. Here you can add a "proxyConfig" key to the options. You should end up with something similar to this:

```json
"serve": {
    "builder": "...",
    "options": {
        "proxyConfig": "src/proxy.conf.json"
    }
}
```
Review: Mathematics for Machine Learning @ Coursera. Linear Algebra; Multivariate Calculus; PCA.
Tags: maths, machinelearning, pca, calculus
Published: 2019-12-11 10:54:37

I recently was doing the [Mathematics for Machine Learning specialization](https://www.coursera.org/specializations/mathematics-machine-learning) on Coursera, which consists of 3 courses. I was always trying to get deeper into Calculus, Algebra, but I was never satisfied with the quality of different materials I stumbled upon in the past and never really went with my studies far. But then this series of courses happened and I was never more motivated to learn those concepts. I enjoyed it so much. It lies a quite solid mathematical foundation under concepts of Machine Learning. Every bit of the course is applied instantly into practical settings and there are plenty of exercises in Python. I didn't know Python much before, but I programmed in C++ and a bit in JS. I studied it in the meantime. W/o that my interest in Machine Learning was merely learning some high-level functions w/o any knowledge about underlying math and statistics involved. I'm glad I got a deeper grasp of the inner workings and I want to recommend this series of courses to everyone who starts studying Machine Learning.

Cheers.
How to Host a Ghost Blog for Free!
Tags: discuss
Published: 2019-12-11 10:09:45

Hi there guys,

I've been going around a lot to try to host a ghost blog for free. Documentation and tutorials on Google are scarce but I finally got to read this blog post 👇🏻

https://blog.scope.ink/how-to-host-a-ghost-2-0-blog-for-free/

It clearly explains how to host for free a Ghost blog. I've started my own blog using Gatsby and it also explains how to create the integration with Gatsby in an easy and simple way, so I'd like to share it with you!💜

Do you guys know any other way I can follow to host a Ghost blog and Ghost Admin for free? Let's discuss it here!
Ruby's .times in JavaScript
Tags: javascript, ruby, loops, objectprototype
Published: 2019-12-11 09:58:33

---
title: Ruby's .times in JavaScript
published: true
description: Ruby's 'times' loop in JavaScript
tags: JavaScript, Ruby, loops, Object.prototype
---

Never modify JavaScript's standard built-in objects. That's what they [say](https://stackoverflow.com/questions/14034180/why-is-extending-native-objects-a-bad-practice#answer-14034242).

But just for fun, let's see how Ruby's [.times](https://ruby-doc.org/core-2.2.2/Integer.html#times-method) would look like in JavaScript.

Here's how we do it:
```
String.prototype.times = function (n) {
    for (var i = 0; i < parseInt(this); i++) {
        n();
    }
}
```

```
var myFunc = function () { console.log('Hello World') }
"2".times(myFunc)
```

Output:

```
"Hello World"
"Hello World"
```

nickciolpan
29 May 2018