teleren/devto huggingface dataset:
Boiling Frogs
Tags: pragmatic, programmer, bigpicture
Published: 2019-10-25 06:35:20

---
title: Boiling Frogs
published: true
description: Part of my series of short discussions of topics raised in The Pragmatic Programmer, 20th Anniversary edition
tags: pragmatic,programmer,bigpicture
series: pragmatic-programmer
---

In a [previous post](https://dev.to/fluffynuts/be-a-catalyst-for-change-3ag1), I discussed the concept of being a catalyst for change in your codebase and organisation, based out of the story about [Stone Soup](https://www.michaelppowers.com/prosperity/stonesoup.html).

One of the observations made about that story is that the soldiers deceive the villagers little by little until the process of making the soup is completed. The act of deception or gradual change is invoked in the interests of everyone who takes part: the final result is a meal that _everyone_ enjoys because everyone is sharing and participating.

The question to ask yourself when you're working on gradual changes in your own environment and codebases is this: "What is the big picture?". You need to always be questioning if the incremental advances you make are taking you in the right direction, otherwise you risk becoming like the fabled story of the boiled frog: it's said that you can place a frog in cold water and slowly raise the temperature to boiling and the frog won't notice because of the gradual change, eventually being cooked.

We're all like that frog in that sense: it's easy to take our eye off the ball and let things slide, just a little, just this once -- every time. 

We see this when we're under time pressure and there's "no time to write tests". Except we _will_ have time to fix the bugs that come back afterwards. We see this when there's "no time to refactor", but we _will_ have time to sit down and try to understand the giant ball of mud we made last week because we have to extend it this week.

We see this when we let small discriminations happen in the office: "We can't get mad at Stan for being forward with the ladies, because he's from a different generation". Until Stan has to have a chat with HR because no-one reigned him in when it was just "joking" with people who tolerated him. Also, tolerating these micro-transgressions doesn't help Stan: one day, when he has a real point to make, no-one takes him seriously because he's just the "creepy uncle in the basement office".

## _How we do the little things is how we do everything_ 
Pay attention to the small tasks in your day. Always do them to the best of your ability. Always question if there's a better way. Always strive to be the person your dog thinks you are.
TPP Topic 36: Blackboards
Tags: thepragmaticprogrammer, book, programming, education
Published: 2019-11-10 14:45:34

---
categories:
- The Pragmatic Programmer
published: true
tags:
- The Pragmatic Programmer
- book
- programming
- education
title: 'TPP Topic 36: Blackboards'
---

> This post originally appeared on [steadbytes.com](https://steadbytes.com/blog/the-pragmatic-programmer-20th/topic-36-exercises/) 
<div></div>
> See the [first post](https://dev.to/steadbytes/the-pragmatic-programmer-20th-anniversary-edition-series-1e2l) in The Pragmatic Programmer 20th Anniversary Edition series for an introduction.

## Exercise 24

> Would a blackboard-style system be appropriate for the following applications? Why, or why not?
>
> Image processing. You’d like to have a number of parallel processes grab chunks of an image, process them, and put the completed chunk back.
>
> Group calendaring. You’ve got people scattered across the globe, in different time zones, and speaking different languages, trying to schedule a meeting.
>
> Network monitoring tool. The system gathers performance statistics and collects trouble reports, which agents use to look for trouble in the system

1. No. Processing chunks of an image in parallel doesn't have complex interactions and/or feedback between processes; an image produces a fixed set of tasks, where the completion of one task doesn't inform the completion of another task. A simple queue would suffice in this case.
2. Yes. There are multiple people (processes) operating at different times without direct interaction. However the decisions made by each person feedback into further decisions made by others. For example, one person can put up a time where they're definitely not available which may inform which times other people say they _are_ available.
3. Yes. The performance statistics and problem reports are gathered both independently and non-deterministically (things happen when they happen). Furthermore, a single statistic or problem report may not be an issue but some combination of statistics of given value and problem reports may signal trouble. Many such combinations are possible and separate agents (human or machine) can search the blackboard for a specific issue.
How I knew I am a back-end guy...
Tags: php, beginners, webdev
Published: 2019-11-10 14:41:07

Hello, this is my very first ever dev post. As the title says, i'm learning about myself as a junior dev. I know i am so bad at writing, and if you feel bored you can go to the next post, no hard feelings.
So i recently applied for my first job as a developer. I was and still am very anxious about dev work, and i feel like having a job where they throw at you projects and assignments is a good way to learn in general. So before they employ me they gave me a small project to do. It was a school platform. I had never any serious project even though i can say i have been active for a few months. 
The point is, I learned a lot from it. Most importantly i learned that i am way better at back-end than front-end. I was frustrated with choosing colors, typography and all that graphic stuff. It was so frastrating. And yet on the back-end i was busting, well not everything but i was happy about the little i did. Currently i use php on the server but hope to learn python and try that out too. 
This has taught me a lot. Now i know i gotta focus on my back-end more than my front-end. Am not quiting the front-end because i think being a full stack is really cool.
Being a self taught beginner is the most intimidating thing i have faced in my life. I have a lot of ups and downs but moved through it and thank God i never thought about quiting and i love that about myself.
Thanks for reading my first site, i know it has been heck long.
Blessings~~
What do you think the BEST feature is that dev.to could add?
Tags: discuss, watercooler
Published: 2019-11-10 14:25:04

# A feature I'd like to see
I think an optional spellcheck/grammar setting would be amazing. Pre-release of a blog it'll go into a special mode where certain people can read your blog and fix any spelling/grammar mistakes you may have made.

This would really help non-native English speakers get their point across and also help them in learning the language at the same time. I've seen too many brilliant blogs not getting the traction they deserve just because their English isn't the best.

Maybe add badges or some kind of incentive to get people to actually bother!


# Your thoughts
I'd love to hear people's thoughts on this and also hear some features you'd love to see on the website!
How to not leap in time using Python
Tags: python
Published: 2019-11-10 14:14:31

---
title: How to not leap in time using Python
published: true
description: If your application needs to measure elapsed time, you need a timer that will give the right answer even if the user changes the time on the system clock
tags: python
cover_image: https://thepracticaldev.s3.amazonaws.com/i/r3p8e2gp6vln2l2kl6vk.jpg
---

If you want to display the time to a user of your application, you query the time of day. However, if your application needs to measure elapsed time, you need a timer that will give the right answer even **if the user changes the time on the system clock**.

The system clock which tells the time of day is referred to as a real-time clock or a wall clock. The time on such a clock will jump when changed. Relying on the wall-clock to find out how much time has passed since a previous event is a bug waiting to happen.

For example, suppose your application carries out an operation in response to some event, but it only executes that operation once an hour, it does nothing in between. Maybe the operation is some kind of clean-up task. Suppose the user made a typo and set the wrong month on the system clock before your application started; he might then fix that later when your application already working. Suppose the date is now a month earlier than when your application started, it will be a month until your application thinks that it should carry out its clean-up operations again!

To safely measure elapsed time in an application, you need a clock that measures time continuously, without any jumps when a user sets the system time. This kind of clock is called a **monotonic clock**. Python 3.3 introduced the `time.monotonic()` function to provide a basic monotonic clock. Before python 3.3 there’s a PyPI module called [monotonic](https://pypi.org/project/monotonic/) that provides similar functionality.


```python
import time

start = time.monotonic()
time.sleep(0.2)
end = time.monotonic()

print("start: {:>9.2f}".format(start))
print("end: {:>9.2f}".format(end))
print("span: {:>9.2f}".format(end - start))
```

```python
start:   4601.77
end:   4601.97
span:      0.20
```

To measure performance, it is important to have monotonic timers with high accuracy. Such a timer Python provides in `time.perf_counter()`:


```python
import time

start = time.perf_counter()
i = 0
while i < 100000:
    i = i + 1

elapsed_time = time.perf_counter() - start
print("Elapsed time: {}".format(elapsed_time))
```

```python
Elapsed time: 0.012327131999882113
```

From Python 3.8 `time.clock()` function [will be deleted](https://github.com/python/cpython/pull/13270) and `time.perf_counter()` will be used.

------

**Thank you for reading!**

Any questions? Leave your comment below to start fantastic discussions!

Check out [my blog](https://luminousmen.com/) or come to say hi 👋 on [Twitter](https://twitter.com/luminousmen) or subscribe to [my telegram channel](https://t.me/iamluminousmen).
Plan your best!
Practice makes perfect
Tags: practice, todayilearned, javascript, ideas
Published: 2019-11-10 13:57:22

Here is a collection of app ideas that might seem like a great project when you scramble your brains to come up with something to test your concepts. 

https://www.florin-pop.com/blog/2019/03/15-plus-app-ideas-to-build-to-level-up-your-coding-skills/

@florinpop1705 thanks for preparing this list. Super helpful!
CORS mechanism in short
Tags: cors, javascript
Published: 2019-11-10 13:55:11


### tl;dr

To allow cross-domain requests:
- server needs to respond with correct [HTTP headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers) for original endpoints(+ handle OPTIONS request on the same endpoints for [some types of request](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Functional_overview))
- client app/website only needs to take care of setting CORS mode of request if required by the request library/API like it is with [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) (mode parameter)

## Why do we need CORS mechanism

Browsers block cross-origin resource access for security reasons. HTTP requests carry authentication/authorization information with them — think cookies, which are stored per-domain and auto-included in the request.

## What is it

Set of instructions that declare acceptable resource access from remote origin(s), a sort of whitelist mechanism. Instructions are sent to the browser using specific HTTP headers. Some resources(API endpoint, file...) that need to be accessed cross-domain from a browser, need additional HTTP headers to signal the browser it's safe to fetch.

## When to use it

Usually it's when you serve your website or an app from one domain and have other supporting services you need to talk to on other port or domain — by default browser blocks many of such requests. Full list of affected request types is on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#What_requests_use_CORS)

## Browser side

When doing a cross-domain request, browsers look for specific HTTP response headers to deduce if it's safe to return the response data to the source that initiated the request. Domain of origin and HTTP method used must be explicitly allowed through HTTP response headers for request not to be cancelled.
Some request types will cause 2 actual HTTP requests being issued by the browser, first being preflight request(OPTIONS) that serves as light pre-check for resource access. In both cases, browser will look out for CORS headers allowing the access.

**Note**: For issuing cross-domain requests from Javascript code, you may need to set the mode of the request to CORS type like with [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)

## Server side

Server should respond with appropriate headers for every resource which should be available cross-domain from a browser. Beware that some browser requests will also expect appropriate response for a preflight request at identical resource location. Headers used:
- Access-Control-Allow-Origin
- Access-Control-Allow-Methods
- Access-Control-Allow-Credentials
- Access-Control-Allow-Headers
- Access-Control-Expose-Headers
- Access-Control-Max-Age

Full explanations on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers)
Authenticate GraphQL Queries With JsonWebTokens(JWT) in Orm-NodeJS environment using Typescript.
Tags: node, typescript, apollo, graphql
Published: 2019-11-10 13:37:11

Hello Everyone, Today I am writing an article to authenticate Graphql queries with JWT tokens. To achieve this, first I am going to setup server in which user able to do Registration/Login. After successful login, we make a query which need authentication.

> So the technology stack I am going to use is :: Nodejs, Expressjs, Typeorm, Typegraphql, graphql, jsonwebtoken,ApolloServerExpress and much more.

[GitHub Link](https://github.com/vinodchauhan7/Authenticate-graphql-queries-with-jwt)

###Authenticate Graphql Query
```javascript
@Query(() => String)
@UseMiddleware(isAuth)
async Me(@Ctx() { payload }: MyContext) {
    return `Your user id : ${payload!.userId}`;
}
```

####Implement isAuth.ts middleware
```javascript
import { MiddlewareFn } from "type-graphql";
import { verify } from "jsonwebtoken";
import { MyContext } from "./MyContext";

//format like bearer 21321n2bmbbj

export const isAuth: MiddlewareFn<MyContext> = ({ context }, next) => {
  const authorization = context.req.headers["authorization"];

  if (!authorization) {
    throw new Error("Not authenticated");
  }

  try {
    const token = authorization.split(" ")[1];
    const payload = verify(token, "MySecretKey");
    console.log(payload);
    context.payload = payload as any;
  } catch (err) {
    console.log(err);
    throw new Error("Not authenticated");
  }
  return next();
};

```

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/9t7wtd7gws0zy8rm9kib.png)

However, if anyone wants to understand everythin from basics then please follow :
#[My Medium Article](https://medium.com/@vinodc45/authenticate-graphql-queries-with-jsonwebtokens-jwt-in-orm-nodejs-environment-using-typescript-eaab53eb6d24)
Kipping duplicated data between collection synced with mongodb-data-sync
Tags: mongodb, node, dependencies, javascript
Published: 2019-11-10 13:23:46

**MongoDB** is undoubtedly a popular document database. It has become a top database choice for many web apps, especially those powered by NodeJS. The scalability, efficiency, and speed are only some of its benefits. However, for high read performance, denormalization is crucial and it can be painful doing so with MongoDB.

##Why you should in some cases Denormalizate the data
Denormalization has many advantages, the most notable being the improvements it brings to the read performance of the database. Another advantage of Denormalization is the simplicity of read queries (by removing the necessity of joins). If you’ve used MongoDB before, you probably already know the only JOIN method it provides is LEFT_OUTER_JOIN, unlike relational databases that provide many other JOIN methods. This forces writing APPJOINs that query the database multiple times and slowing down the performance. To overcome this issue many programmers use Denormalization. 

Denormalization also makes it possible to index all fields and enables faster searching and sorting of the database.
However, it has its own downsides such as handling duplicate data, and having consistency across collections. When you denormalize MongoDB, you should expect to have less consistent results when compared to a normalized schema.
##The Solution
A possible solution to this is to create jobs to sync data so it becomes stable. Another is to update all the collections. But this is stressful and makes denormalization discouraging. With [mongodb-data-sync](https://www.npmjs.com/package/mongodb-data-sync), it is easier as you can set it up once, and not have to worry about consistency anymore. 

As an application grows, more relationships show up that affect the logic. Looking at this from the angle of denormalizing the database, [mongodb-data-sync](https://www.npmjs.com/package/mongodb-data-sync) lets you simply declare these dependencies. It takes up the task of syncing the data without you having to worry about the complexities. All this with the assurance that speed is not negatively affected and the data remains consistent.

Often times, every tool that makes it easier to build software adds an overhead that can negatively affect the product over time. You don’t need to worry about that in this case as most of the checks before synchronization are done in memory. Also, [mongodb-data-sync](https://www.npmjs.com/package/mongodb-data-sync) makes use of MongoDB’s change streams which lets applications and libraries access real-time database changes.
Installing Mongodb-data-sync

There are two parts to [mongodb-data-sync](https://www.npmjs.com/package/mongodb-data-sync): the engine and the SDK. To get the library working, you need to install these parts and set them up:

npm install mongodb-data-sync -g will install the engine
npm install mongodb-data-sync --save will install the SDK

You can check the npm page to learn more about how you can use the library in your projects and handle your mongodb dependencies gracefully.
What do Devs use to keep useful snippets of code and guides?
Tags: discuss
Published: 2019-11-10 13:09:02

Howdy Dev’s!

Just wanted to kick start a discussion on this. I am using Dash on my Mac as it gives me all the guides I need plus annotation on the guides and the ability to save snippets with tags.

Let’s go! What do you use and why? ✌🏼
What do you native speaker of English listen at work?
Tags: watercooler
Published: 2019-11-10 12:33:55

At work, I'm used to listening to some music. Not all day, of course, only when I need focus or energy.

I usually avoid Italian music, since I can get distracted by the lyrics - yes, I'm Italian. Since most of the music production is in English, I don't have problems in finding the right music for me.

But... what about you? Do you have the same problem? What to do listen at work?
I do code a wee bit :)
Tags: github, dataviz, scorecard, devtools
Published: 2019-11-10 12:33:08

---
title: I do code a wee bit :)
published: true
description: my github profile scorecard
tags: #github #dataViz #scorecard #devTools
cover_image: https://thepracticaldev.s3.amazonaws.com/i/2zmqrene194nysevbxhn.png
---

Next time recruiters ask me what I've been up to lately, I'll just send them my sourcerer.io scorecard :) https://sourcerer.io/randomfractals

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/1wdlawrkoa3ole1k188b.png)

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

see this post for more info on those github profile viz tools: 

{% link https://dev.to/jcabot/3-tools-to-showcase-your-github-profile-59im %}
Accessories
Tags: codepen
Published: 2019-11-10 12:02:37

---
title: Accessories
published: true
tags: codepen
---

<p>Design by Givi Dautashvili: <a href="https://dribbble.com/shots/6350564-Accessories" target="_blank">https://dribbble.com/shots/6350564-Accessories</a></p>

{% codepen https://codepen.io/evgeny_t/pen/VwwXEbJ %}
Is This a real Job?
Published: 2019-11-10 10:50:01


Is this a real job? 

This question subconsciously forms in the minds of 98%, especially young graduates seeking to get the best offer there is.

But is there a practical way to determine if these jobs are real?

with the flashy websites and all, how do I know this isn’t a well thought of scheme?

This fraudulent act is on a rising increase and people are being lured into paying 

money sometimes to apply for a job other times to acquire a job and often times it gets very late before they realize it’s a scam.

It was for this cause itarj.com was built.

with this website you can guarantee if it’s a fake job or a real one; saving your money, data, energy and you from fraudulent scammers.

log on to itarj.com to get started.

Do well to share this good news with your friends and foes. lol
Easiest and fastest way to run Docker image on GCE
Tags: gce, gcp, docker
Published: 2019-11-10 10:37:23

---
title: Easiest and fastest way to run Docker image on GCE
published: true
description: 
tags: gce, gcp, docker
---

![Shipping container fast](https://thepracticaldev.s3.amazonaws.com/i/cdvzwzicpg9h6ukf9gnz.jpg)

Because I'm in Developer Relations team, it is often the case where I want to run some Docker image exposed to public for tentative demo purpose, in such as codelab, workshop or hackathon events.

In those cases, I recommend to use [Google Compute Engine](https://cloud.google.com/compute/) because it has the feature to [run Docker images on booting GCE instances](https://cloud.google.com/compute/docs/containers/deploying-containers).
Using the feature, you can run and make some service public in 2 commands. One is for firewall setting, the other is GCE instance creation.

For example, when you'd like to run [Jaeger all-in-one image](https://www.jaegertracing.io/docs/1.14/getting-started/) and make it public Jaeger endpoint, you can run the following commands:

```console
$ gcloud compute firewall-rules create jaeger-rules \
    --allow udp:5775,udp:6831,udp:6832,tcp:5778,tcp:16686,tcp:14268,tcp:9411 \
    --direction ingress \
    --priority 1000 \
    --target-tags jaeger

$ gcloud compute instances create-with-container jaeger-vm \
    --container-image jaegertracing/all-in-one:1.14 \
    --boot-disk-size 30GB \
    --tags jaeger
```

Photo credit by https://www.marineinsight.com/guidelines/speed-of-a-ship-at-sea/
Kubernetes
Tags: jokes
Published: 2019-11-10 10:24:47

True story...

{% twitter 1158764816426840064 %}

Kubernetes is hard and definitely not for everyone.
Even managed Kubernetes environments (e.g. Google Kubernetes Engine, Amazon Elastic Kubernetes Service, Azure Kubernetes Service or DigitalOcean Kubernetes) don't make it easier to handle.

Anyway, KubeCon San Diego starts next weeks! I hope anyone who's attending will have a great time!