teleren/devto huggingface dataset:
GAE - An opinionated post
Tags: gae, cloud, web, python
Published: 2018-08-25 14:57:11

---
title: GAE - An opinionated post
published: true
tags: gae,cloud,web,python
canonical_url: https://chkrishnatej.com/blog/gae-opinionated-post
cover_image: https://res.cloudinary.com/chkrishnatej-cloud/image/upload/v1535204653/posts/gae/gae-logo.png
---

I have been looking to build a web-app and host it. My options were

- To take a server and deploy it using IaaS like Azure, AWS or GCP
- Deploy it using PaaS like Heroku

Honestly speaking, I didn't know any other PaaS for deploying Python apps except for Heroku. Before investing my time and knowledge of understanding the service, I was looking for if any other alternatives exist.

My idea is to understand the different choices I have. Learn the pros and cons, before taking it up (Never test the depth of a river with both feet)

My checks before taking the choice are:

- Simplicity
- Focus more on code than deployment

The choice was **Google App Engine**. Even though it was launched almost at the same time of Heroku, it didn't go well in the beginning. It was known for being notoriously hard and it did suck.

But now, things have changed. It has become a mature product with an excellent CLI. It really stands to what it claims, _just focus on your code_ and Google takes the responsibility of deploying it with minimal setup from the developer.

It supports both Python 2.7 and 3.x. Has excellent documentation to get you started. You can build web applications and mobile backends.

Now Google App Engine (GAE) is a part of Google Cloud Platform (GCP). The pricing of the GAE is simple enough and more economical than it's counterparts(It would be a whole another post if we talk about cloud pricing). It has got free daily quotas, which is more than enough to tinker to build your personal applications and test them. And of course its scalable, I have a complete belief in the capabilities of Google regarding the scalability.

And there are many other services offered by GCP such as storage solutions, machine learning solutions and much more. All of them fit together beautifully.

So far, it has been a great fit for me for building my pet projects and haven't found cons so far as long as I am inside Google environment. I believe Google would be a force to reckon with in the cloud space with its rich cloud ecosystem and a very affordable pricing strategy.

Please comment about your experiences with GAE below.
Center an element with CSS Grid
Tags: css
Published: 2018-08-22 13:00:32

---
title: Center an element with CSS Grid
published: true
description: Here it is, two lines of CSS to center an element within its parent.
tags: css
---
It's not uncommon to go a week without a developer complaining on Twitter about how hard it is to center an element using CSS.

Here it is, two lines of CSS to center an element within its parent.

```css
.parent {
  display: grid;
  place-items: center;
}
```

It's beautiful.
C Programming!
Tags: beginners, c, help
Published: 2018-08-22 12:06:45

---
title: C Programming!
published: true
description: 
tags: #beginner #c #help
---

What are some of the cool projects a beginner can work on to learn C?
I've only been a *nix user for my job but I'm interested in low level details of how things work w the kernel. 

EDIT: Thanks for your responses! But to be clear, I need some context. A non-trivial project that will make use of special C features like pointers, structs and direct memory manipulation; because I've never worked on those before!
Spring Boot Starter Parent Usage in Maven
Tags: springboot, java, maven, apachemaven
Published: 2018-08-22 11:05:03

---
title: Spring Boot Starter Parent Usage in Maven
published: true
description: Make your pom a little bit shorter.
tags: spring-boot,java,maven,apache-maven
---
I quite often see Spring Boot projects which are using the
`spring-boot-starter-parent` as follows:
```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
    <relativePath/>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>
```
So far so good. Notices something? I have to mention that you can do it
a little bit shorter like this:
```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
    <relativePath/>
  </parent>

  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>
```
The properties defined in the first example are already defined in the `spring-boot-starter-parent` pom file which means you do not need to define them another time cause you inherit them via the parent.
Gutenberg: "The new editor is coming ... continued attempts to make it not be are more than a little pointless"
Tags: wordpress, opensource, php
Published: 2018-08-22 09:15:15

---
title: Gutenberg: "The new editor is coming ... continued attempts to make it not be are more than a little pointless"
published: true
description: A quote from a member of the Wordpress team
tags: wordpress, opensource, php
---

I got banned from the Wordpress forums (and for a fair reason, I broke the rules by mentioning [ClassicPress](https://www.classicpress.net) in response to a review - and I also got a little bit ranty in a review I wrote of Gutenberg, sorry guys :s) and while I was chatting with the Wordpress forum team on their Slack channel about it I got the most definitive statement about Gutenberg that I've had to date:

![Gutenberg](https://thepracticaldev.s3.amazonaws.com/i/q9hrbzjh9cgkjj9mb0hj.png)

### "As far as Gutenberg goes, I can explain this very simply: **Making it "optional" was never on the table** to begin with. This is the new editor. The callout in 4.9.8 was informing users of this fact and showing them the new editor. It was not asking for your opinion on what should be, it was giving you a preview of what will be. The new editor is coming, it will be in 5.0, and so continued attempts to make it not be are more than a little pointless. The Classic Editor plugin exists if you need more time to adjust your workflow or find an alternative to WordPress, and that was mentioned in the callout as well. So my advice would be to best deal with it, because the new editor has been in development for nearly 2 years, and it is coming soon. **There's no chance of it not coming soon, nor of it remaining a plugin**. You're well too late to be voicing that opinion when the thing is nearly a year overdue. Just my 2 cents."

So there you have it!
[Feature request] Filter doctoc by number of lines in a file 
Tags: doctoc, javascript
Published: 2018-08-22 07:36:26

---
title: [Feature request] Filter doctoc by number of lines in a file 
published: true
description: Don't add a ToC to files that are less than 30 lines by default.
tags: doctoc, Javascript
---
It would be great if there are any Javascript devs who want to fix issues in this repo such as this one that I just filed! https://github.com/thlorenz/doctoc/issues/152.

> Filter doctoc, by default, to not add a ToC to files that are below 30 lines (20 lines would fit on a page on most screens); scrolling 10 lines is just about as easy as clicking on a link, then add a flag to change this number of lines.
Display calendar with python
Tags: python, calendar
Published: 2018-08-22 06:56:51

---
title: Display calendar with python
published: true
description: Display calendar with python
tags: #python, #calendar
---

> Python has a built-in function, 'calendar' to work with date related tasks. 
> You will learn to display the calendar of a given date with below example.

```python

import calendar

yy = 2018
mm = 8

print(calendar.month(yy, mm))
```



In the program top, we import the calendar module. The built-in function month() inside the module takes in the year and the month and displays the calendar for that month of the year.



##Output:
```
    August 2018
Mo Tu We Th Fr Sa Su
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
```
Symmetric Encryption Key Storage
Tags: discuss, cryptography
Published: 2018-08-22 06:49:17

---
title: Symmetric Encryption Key Storage
published: true
description: 
tags: discuss, cryptography
---

I was wondering ... if say you're using something like AES(symmetric based), while you can use it to protect data, encrypting it. How do you protect the key used to encrypt the data? Where should you store it? How should you retrieve it?
★ The Laracon US videos have been released
Tags: laravel, php
Published: 2020-01-02 23:03:47

---
title: ★ The Laracon US videos have been released
published: true
date: 2018-08-22 06:44:44 UTC
tags: laravel, php
canonical_url: https://freek.dev/1124-the-laracon-us-videos-have-been-released
---

[Laracon US](http://laracon.us/) was held in July 2018 at the Museum of Science and Industry in Chicago. I had the pleasure of speaking at the conference. You can watch my talk on [v7 of our medialibrary](https://github.com/spatie/laravel-medialibrary) below.

<iframe width="560" height="315" src="https://www.youtube.com/embed/3eyftAR5ilo" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Though there isn't a playlist to hold them yet, you can view recordings of all other talks on [the StreamACon channel on YouTube](https://www.youtube.com/channel/UCMs9GHjzlfmZrfnU-Z3iLwg). Be sure to check out the amazing talks by [Jason McCreary](https://www.youtube.com/watch?v=dccDqpmKVFM) [TJ Miller](https://www.youtube.com/watch?v=K0xid2vS7Oo), [Samantha Geitz](https://www.youtube.com/watch?v=AxlqFgY0BGY) and [Caleb Porzio](https://www.youtube.com/watch?v=uQO4Xh1gMpY).
What Are Some Open Source projects Which Were Useful but now no longer maintained?
Tags: askdev, discuss, opensource
Published: 2018-08-22 06:02:08

---
title: What Are Some Open Source projects Which Were Useful but now no longer maintained?
published: true
description: Some Open Source projects Which Were Useful but now no longer maintained
tags: askdev , discuss, opensource
---

There were some awesome projects Developed in last few years but some them which were very Useful now left unmaintained by Developers.

One Of Them is **Hyde Static Site Generator** , _Evil twin of Jekyll_

Do You Know Such Projects?
Who Knows, Some Awesome Developers might find it interesting and start a new chapter of it!
Create and deploy a personal web page with React (Part I)
Tags: javascript, es6, react
Published: 2018-08-21 22:28:23

---
title: Create and deploy a personal web page with React (Part I)
published: true
description: Creating a personal app in 20 minutes using React and Github pages. 
tags: javascript, ES6, React
---

##Prerequisites

You need in your computer installed
* NodeJS (version >6.10 is good)
* Npm (version > 5.12 is fine)

You also need:
* A GitHub account
* A command-line Git client

##Project creation
After checking everything is correctly installed. We can start our project with next command
`npx create-react-app my-app`
Then we will install the gh-pages package as a "dev-dependency" of the app
`cd my-app`
`npm install gh-pages --save-dev`
__Properties__
We will add some properties to package.json. At the top level, add a homepage property:
```
//...
"homepage": "http://gitname.github.io/my-app"
```
__[gitname]__ → Your github username
__[my-app]__ → Your project path, in this example my-app
Also, let's add some custom scripts for gh-pages deployment, in the "scripts" : { … } section of our package.json
```
...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
```
__Link to repository__
Under our project path let's create a git repo:
`git init`
This will create an empty .git file. Now we have to add a remote repository url to our repo:
`git remote add origin https://github.com/gitname/my-app.git`
##Deployment
Let's now generate a production build of your app, and deploy it to GitHub Pages.
`npm run deploy`

![Console]
(https://thepracticaldev.s3.amazonaws.com/i/e01jiocljuwdewuplso2.png)

Your app should now be accessible at the URL you specified.

__What happened here?__

When we execute the run command, the library pushes all built files to gh-pages branch and github automatically takes this branch and creates the domain and publish our code.

* _(Optional) Push sources to master_
I recommend to push source files to master branch to keep sources able to be changes anytime from anywhere.
```
git add .
git commit -m "First source code commit"
git push origin master
```

Next steps: How to add content

This is the first result for my project.

![](https://thepracticaldev.s3.amazonaws.com/i/s9p82u891vfbnhujccl0.png)

If you check this page now, it's quite different. How did I created everything you can see? Check next post's for more.
What Your Javascript Does When You're Not Around
Tags: devlive, javascript
Published: 2018-08-21 21:24:25

---
title: What Your Javascript Does When You're Not Around
published: true
description: 
tags: devlive, javascript
---
As client-side app frameworks like React keep growing more popular, we’re shipping more and more application logic out to users’ browsers. But we don’t always know much about what happens to it after we send it out to the client. This talk will take you on a fast-paced tour of all the strange cases we’ve seen in browsers in the wild, from overseas proxy sites to rogue browser extensions to console-hacking customers with a sense of humor. Finally, we’ll talk about how to cut the noise and focus on minimum viable instrumentation to have visibility into the things that really matter to your users’ experience.

Some knowledge of modern browser javascript development practices is helpful.

*This DEV Live Stream was recorded on August 16, 2018*
Join the next Live Stream. See all upcoming events [here](https://dev.to/events).
PSA - Posting your preferences and phishing.
Tags: security, phishing
Published: 2018-08-21 20:29:06

---
title: PSA - Posting your preferences and phishing.
published: true
description: Wherein I received a targeted phishing email.
tags: #security #phishing
---

**Today I received this email.**

![fake email](https://thepracticaldev.s3.amazonaws.com/i/wri9vbas4zfk14zjh2w1.png)

The remarkable thing about this email is that I never signed up for a GitLab account. Not even to mention the obvious red flag that it was not sent from the gitlab domain. It could be mistaken for a self-hosted solution, except that I never signed up for it, much less changed a password. My guess it is ultimately an attempt to steal source code.

So I decided to learn something about this attacker. I never went to the links in the email. But I looked up the domain, which was registered by an international registrar called Domain Control. I looked up the server IP, which is a Digital Ocean server located in Germany. This mainly tells me what kinds of services the attacker is familiar with.

I decided this was probably a malicious dev who is mining data from other dev communities I happen to participate in. I do not recall disclosing which source control I used (not GitLab currently), so it was probably just a safe bet to use for attacking multiple people. Maybe it was just the service the attacker is most familiar with and already had emails in their own inbox upon which to base the above forgery. Because it is pretty close to GitLabs own email format, which is pictured below.

![real email](https://thepracticaldev.s3.amazonaws.com/i/jazgcfemeaatieh8wu24.png)

## The point

The obvious point is to never trust email links, except when you are expecting an email. (As in, you just went on their site and triggered a password reset.) If you receive an unsolicited email that looks ok, still don't trust it. Especially if it is informing you that you need to do something on an account you do really have, still do not click on the links in the email. Instead, open the browser and go directly to the website itself. If there is a legitimate account problem, you can log in and check that yourself.

But the more relevant point is to be careful and aware of what you share about yourself. It can be used against you. It can be used to target you for attacks. It can be used to manipulate you into a critical mistake, such as a convincing phishing email leading to your source code being stolen. Share carefully.

_Parting note: This is the reason that data privacy is an important issue today. Social media providers typically use the data you have shared on their service to target you for ads. But simply collecting and correlating this data to you creates a gold mine for bad actors. If this seemingly inane data falls into nefarious hands, it could be used in exactly the same manner (to target and manipulate you), except with the goal of attacking/stealing/destroying instead of advertising._
Advice for creating a Portfolio Website With Little Experience?
Tags: help, portfolio, new, web
Published: 2018-08-21 20:19:55

---
title: Advice for creating a Portfolio Website With Little Experience?
published: true
tags: help, portfolio, new, web
---

I have only been in the tech industry for a little over a year now, working as a web developer which I love. I'm hoping to create a personal web site to show off all of my work, previous jobs, and experience. The only issue: I don't have too much of any of those.

Does anyone have any advice for someone new to the industry, trying to create a portfolio website? What are some do's/don'ts? Should I link some of my github projects?

Although I am still somewhere in the novice to intermediate skill range, I feel extremely capable of handling any development challenges thrown my way, as I have been facing a constant stream of them since I first got employed (as an intern, now a full time developer.)

I am hoping to use the portfolio website to sort of "legitimize" myself for potential future employers, but more so - potential clients for freelance work.

Any guidance would be greatly appreciated!
Elm 0.19 brings better collections
Tags: elm
Published: 2018-08-21 19:39:22

---
title: Elm 0.19 brings better collections
published: true
description: On the surface nothing has changed. Below the surface however, almost everything has.
tags: elm
---

You're probably aware of this already but Elm 0.19 has just been released. When you read through the release notes and the documentation of the core library, you might to think that nothing has changed with regards to the built-in collection types: `List`, `Array`, `Dict` and `Set`.

You'd be wrong.

While it is true that the API remains entirely the same, there are huge changes under the covers which results in more performance, and a bug-free `Array` implementation. Let's take a closer look.

## List

`List` is the data structure which have changed the least. In fact, the underlying data structure hasn't changed at all. The only thing which have changed is the implementation of `List.foldr` which is now faster by about 30%.

This alone might not seem to be that big of a deal, but considering `map`, `filter` and `append` are all implemented on top of `foldr`, this means that `List` is quite a bit faster across the board.

If you want to know more about the actual implementation, you can take a look at this [PR](https://github.com/elm/core/pull/872).

## Dict and Set

`Dict` has actually been re-written from scratch while retaining the original API. The benefits of this new implementation is mostly that of performance. We're talking 170% faster inserts and about 30% faster removals.

`Set` is just a thin wrapper around `Dict`, and so `Set` benefits from the new implementation as well.

More info in the [PR](https://github.com/elm/core/pull/959) and these development updates: [#1](https://groups.google.com/forum/#!topic/elm-dev/--fK-wMoDig), [#2](https://groups.google.com/forum/#!topic/elm-dev/T-PHQNrkNss).

## Array

Like `Dict`, `Array` has been totally re-written. The original code was in Javascript, and suffered from grave bugs that could cause runtime crashes and mutations. The new implementation is in mostly Elm, and all known bugs are fixed.

From a performance stand point, the implementation is faster in some cases, while slower in others. More information in this [development update](https://groups.google.com/forum/#!topic/elm-dev/TPUKXVXr1Hs). 

## Summary

The API might be the same, however, a huge amount of work has been done to make these data structures better than ever before.

There is a similar story for the `Random` module, which has been re-implemented by Max Goldstein to be faster and more, you know, random. You can learn more by checking out this [PR](https://github.com/elm/core/pull/778).
NodeJS - Unit Tests - testing without hitting database. Confusings.
Tags: help, node, jest, testing
Published: 2018-08-21 18:04:59

---
title: NodeJS - Unit Tests - testing without hitting database. Confusings.
published: true
tags: help, nodejs, jest, testing
---

I'm trying to learn TDD approach. I have no troubles with a simple code where I do not need to mock or stub any external methods or dependencies, but where it comes to write tests for some code that based on database I'm getting feel a little bit confused.

It's clear to me, that the unit tests should tests a small piece of code that do not depends on other services and so on. 

Lets assume that I want to unit test a creating user feature.

I know that in TDD I should start by writing failing test - but I don't know how it should look like. ;)

So, here is the example, simplified service:

```
class UserService {
  
  // typeORM repository
  constructor(userRepository: Repository<User>) {}

  async createAccount(user) {
   
   // Saves user to database and return created entity object
   return await this.userRepository.save(user);
  } 

}
```


By now I'm able to spy on method and check if is called properly, with correct params etc. (I'm using Jest)

```
it('Should create a user.', async () => {
    
  const USER = {
   email: 'test@user.com',
   username: 'user',
   password: 'user',   
  };

  const SPY = jest.fn(() => USER);
  jest
    .spyOn(userService, 'createAccount')
    .mockImplementation(() => SPY(USER));

  await userService.createAccount(USER);
  expect(SPY).toHaveBeenCalledTimes(1);
  expect(SPY).toHaveBeenCalledWith(USER);

});

```

And here comes my main question. How should the failing tests looks like? I mean if I stub createAccount method like I did above, it will always pass. Even if the method is empty. It's only requires method declaration. Should I mock repository methods that returns what typeORM is supposed to returns? e.g.:

``` 
const REPOSITORY_MOCK = jest.fn(() => ({
    save: jest.fn().mockImplementation((user) => user),
}));

```

I think that I missed something. :/

Or Am I try to over complicate it and I should only testing if the method is calling properly? And the whole database related stuff should be test by integration tests where I'm able to work on database?


I'm looking forward any kind of help. Thank you in advance. 

Cheers, Kuba.