teleren/devto huggingface dataset:
So you want to stand up your own instance of DEV? (help thread)
Tags: meta
Published: 2018-09-11 19:00:04

---
title: So you want to stand up your own instance of DEV? (help thread)
published: true
description: We have a large community already contributing back to the project, so we're excited about the potential to make the underlying platform reusable. 
tags: meta
---

Ever since [dev.to went open source](https://dev.to/ben/devto-is-now-open-source-5n1), we've had people interested in working with this codebase to build _dev.to for music_, _dev.to for book clubs_, _dev.to for entrepreneurship_ etc.

We have a large community already contributing back to the project, so we're excited about the potential to make the underlying platform reusable. This goal is not necessarily part of our own business, but it is a use case we want to support for the broader community. However, it will take some work before we get to this point.

Here is a post I made a several months ago, well before we actually went open source, which muses on this general idea:

{% link https://dev.to/ben/how-devto-could-topple-facebook-2nj3 %}

## Work to be done

The phrase "dev.to" is currently mentioned in 172 different files throughout the codebase. Obviously, a generalized version of the app can't have "dev.to" hardcoded. This is just one example of a step that stands in the way of generalized re-use. The "about" page is also currently hardcoded, as are lots of other elements.

We believe that we can work together to generalize these features little-by-little so that we eventually have a very robust social platform that solo developers can make use of and configure for their needs.

This is not something we can put front-and-center on our own roadmap, but we can actively work with contributors that are excited to push ahead on this goal.

This thread is for any questions you might have. Basically, it is my open inbox on the subject. I'll try to respond to anyone with questions along the way about what work can be done and how. Any pull requests that improve the code and also move us towards this goal have a good chance of being merged.

Happy coding!
Floating Spaceship
Tags: css, beginners, float, animate
Published: 2018-09-11 18:55:42

---
title: Floating Spaceship
published: true
description: Simple CSS Animation - FLOAT!
tags: 
- css
- beginner
- float
- animate
---

### I saw something floating in one of the websites,
and bazinga! Today shall be the day I conquer CSS animation. Starting with a space ship. 🚀 

We are going to explore `keyframes` and `animation` and `transform` and `translateY`.


There are a few types of animation-timing-function:
``` javascript
ease: Slow start, then fast, then ends slowly	
ease-in: Slow start	
ease-out: Slow end	
ease-in-out: Slow start and a slow end
```

Know more at [w3schools](https://www.w3schools.com/cssref/css3_pr_animation-timing-function.asp).

### The basic idea in `HTML` and `CSS`,


![notes](https://thepracticaldev.s3.amazonaws.com/i/kp5kv1h3l06pe89d1vw0.jpg)

{% codepen https://codepen.io/toomuchome/pen/eLMEKg %}


[DEMO IN A WEB BROWSER](https://linxea.github.io/css-animation/float/)

The difference is too subtle for my eyes. Same same but different. Okthxbye.

### Follow me at [TWITTER](https://twitter.com/linxea_)
[ASKDEV] How to approach people online for asking career related advice?
Tags: discuss, career
Published: 2018-09-11 17:43:24

---
title: [ASKDEV] How to approach people online for asking career related advice?
published: true
description: Asking advice on asking advice.
tags: discuss, career
---

Hey folks, do you have any good advice on approaching developers online for asking advice about career. Thanks in advance.
What's your favorite interview question?
Tags: discuss, career
Published: 2018-09-11 17:30:10

---
title: What's your favorite interview question?
published: true
description: I'm looking for suggestions for technical interview questions for university candidates.
tags: discuss, career
---

Hey all, I'm a developer at [Big Tech Company] that graduated from university a few years ago, and I've recently just signed up to be a technical interviewer for university recruits! I'm pretty excited about it, but we don't have an internal repository of questions.

So both for my knowledge and maybe for a bit of dev.to fun, what's your favorite whiteboard interview question? It might be the most interesting question you've ever asked/been asked, or one that you think reveals a lot about a developer's abilities and problem solving skills. I know that typically, interviews can be a stressful thing for a lot of people (and I definitely feel that too), but I also think they can be fun, engaging puzzles. Personally, I prefer more open-ended design questions over regurgitative implementation of basic data structures/algorithms.
What's the difference between visual studio and vs code?
Tags: anonymous, help
Published: 2018-09-11 16:53:44

---
title: What's the difference between visual studio and vs code?
published: true
tags: anonymous, help
---
_This is an anonymous post sent in by a member who does not want their name disclosed. Please be thoughtful with your responses, as these are usually tough posts to write. Email sloan@dev.to if you'd like to leave an anonymous comment._

- What can I do on visual studio that I can't do on vs code? That's presumably what I'd be paying for, right?
- Is visual studio cross-platform?
What is a MVC pattern?
Tags: mvc, oop, php
Published: 2018-09-11 16:19:46

---
title: What is a MVC pattern?
published: true
description: 
tags: #MVC #OOP #PHP 
---
#MVC - Model view controller


Model view controller(mvc) is the design pattern nowadays used in the production.
**Model** - It contains the code to manage the databases. For example you can see sql requests like INSERT INTO tasks(id,title,description,creation_date,edition_date)
       values('55','"$_POST['title']"','"$_POST['task']"','"$_POST['date']"','"$_POST['edit_date']"')").
**View** - From the name itself it implies that it is the view part normally contains HTML codes. Sometimes it has PHP variables and conditions. For example if we want to display a post of a user.

**Controller** - Controller has all the decision making codes or else logical parts goes here. It is the intermediate between model and view. For instance : If an user requests for an page the controller invokes the method from the model and gives back it to the view.

For beginners I have created a directory structure of mvc which you can either git clone or download the zip file and you can extract into the directory where you are going to create your mvc application

##To clone the structure use the git command : 
 
    git clone https://github.com/ASHOK6266/myOwnStructure_mvc.git 

I have also added database file to the structure which is a Singleton pattern

Once you clone the structure you will see the database file in Models/Application/db.php
Database connection is the Singleton pattern which restricts the class instantiation again and again.
Moreover the singleton pattern makes your application faster.
Don't forget to add your dbname,username,password in the db.php file

**STEP 0:**
I created database named myOwnStructure_mvc and todolist table with id,title and description.
**STEP 1:**
Models/Application/App.php 
I created class Tasks and method get_task();
The method get_task() will retrieve all the posts from the database.
**STEP 2:**
Controllers/Application/AppController.php
I created class AppController and method show_tasks ;
The method show_tasks will invoke the model (i.e method get_task) from the  Models/Application/App.php     
Don't forget to include model file here include('../../Models/Application/App.php');
**STEP 3:**
Views/Application/App.php
I just called the controller methods here i.e show tasks.
Normally no logic and security should be in views.
I have also commented inside each file . You can learn from it. I have just given basic documentation. You can start building the application todolist.
If you wish to build application other than todo list. You can just replace the codes. 

###ADDITIONAL INFORMATION
Yes!!!!! We are done with the basics but there are lot to learn. 
The Index file in the project is the entry point of the application. To make it as entry point you have configure your server.
.htaccess is the configuration file for web server running on web applications.
Macro with current function name - __func__ vs __FUNCTION__
Tags: c, preprocessor, visual
Published: 2018-09-11 20:56:03

---
title: Macro with current function name - __func__ vs __FUNCTION__
published: true
tags: c++,preprocessor,visual
canonical_url: http://asawicki.info/news_1689_macro_with_current_function_name_-_func_vs_function.html
---

Today, while programming in C++, I wanted to write an assert-like macro that would throw an exception when given condition is not satisfied. I wanted to include as much information as possible in the message string. I know that condition expression, which is argument of my macro, can be turned into a string by using `#` preprocessor operator.

Next, I searched for a way to also obtain name of current function. At first, I found ` __func__ `, as described [here](https://en.cppreference.com/w/cpp/preprocessor/replace) (C++11) and [here](https://en.cppreference.com/w/c/language/function_definition) (C99). Unfortunately, following code fails to compile:

```
#define CHECK(cond) if(!(cond)) { \
    throw std::runtime_error("ERROR: Condition " #cond " in function " __func__);

void ProcessData()
{
    CHECK(itemCount > 0); // Compilation error!
    // (...)
}
```

This is because this identifier is actually an implicit local variable `static const char __func__ [] = "..."`.

Then I recalled that Visual Studio defines ` __FUNCTION__ ` macro, as custom Microsoft extension. See documentation [here](https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2017). This one works as I expected - it can be concatenated with other strings, because it's a string literal. Following macro definition fixes the problem:

```
#define CHECK(cond) if(!(cond)) \
    { throw std::runtime_error("ERROR: Condition " #cond " in function " __FUNCTION__); }
```

When `itemCount` is 0, exception is thrown and `ex.what()` returns following string:

> ERROR: Condition itemCount > 0 in function ProcessData

Well... For any experienced C++ developer, it should be no surprise that C++ standard committee comes up with solutions that are far from being useful in practice :)
Hugo #1 - Intro to Static Site Generators
Tags: hugo, staticsitegenerators
Published: 2018-09-11 15:59:42

---
title: Hugo #1 - Intro to Static Site Generators
published: true
description: 
tags: hugo, static-site-generators
canonical_url: https://greekdeveloper.com/2018/static-site-generators/
cover_image: https://greekdeveloper.com/2018/static-site-generators/featured.png
series: Hugo
---


A static site generator (SSG) is an application that converts simple text files (with minimal markup) to static sites using predifend templates (Themes). They provide a middle ground between fully fledged Content Managment Systems (like wordpress or drupal) and statically build sites.


### Pros

- No server-side infrastructure except a simple http server (no database, no server-side application).
- Simple deployment procedure (just copy the generated files). 
- Every deployment is a full deployment (no differences between local and remote site)
- Easily to track content and theme via source code versioning system
- Content consistency (every page looks the same due to template usage)

### Cons

- The application is required in order to alter content (ie. cannot publish frpm mobile)
- No advanced content management or authorization model
- There is a learning curve for doing more complex tasks (but this is true for every other option)

### Use case

SSGs are a fitting option for personal or small teams, blog-style sites where any commenting is either disabled or off-loaded to another tool (ie facebook comments) - If the team member are familiar with text editing, markdown and git (like developers are) even better.

### Operation & Setup

The typical steps to setup an SSG are: 

1. Download SSG binaries or script
1. Create a new folder (project)
1. Download a theme
1. Configure site parametes (title, url, theme, etc)
1. Create content (simple ascii files, using markdown)
1. Build static files
1. Deploy static files

### Which one?

There are multiple SSGs to select from, but the 3 most used are: 

- [Jekyll](https://jekyllrb.com/) is the most used (partailly due to being used by github pages), but setting up RoR on a windows machine could be intimidating..
- [Hugo](https://gohugo.io/) is build in "Go" but ships as a single executable and is a nice option
- [Hexo](https://hexo.io/) is build in node.

My personal preference is Hugo

######[Origin post at greek developer](https://greekdeveloper.com/2018/static-site-generators/)
Three ways to check for palindromes in JavaScript
Tags: javascript, algorithms, recursion, programming
Published: 2018-09-11 15:54:31

---
title: Three ways to check for palindromes in JavaScript
published: true
description: Three Ways to Check for Palindromes in JavaScript with performance measurement
tags: javascript,algorithms,recursion,programming
---
A palindrome is a word or a phrase that is the same whether you read it backward or forwards, for example, the word **'level'**.

I'm going to create three different functions that are doing the same job - palindrome check for a passed string. I will mesure time of function execution to see which one of this function gives the best performance using [performance.now()] (https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) Web API method.

#### Create an array
```javascript
isPalindrome = (string) => {
  string = string.toLocaleLowerCase();
  return Array.from(string).toString() === Array.from(string).reverse().toString()
}

//0.52 ms
```
Array object has a lot of useful methods - one of them is [reverse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse), but first, we need to create an Array from a string. After reverse, the first array element becomes the last, and the last array element becomes the first. We can't do check now, because condition will always be false as they're objects with different locations in memory. toString() method will return a string from our arrays.

#### Recursion
```javascript
isPalindrome = (string) => {
  let strLen = string.length;
  string = string.toLocaleLowerCase();

  if (strLen === 0 || strLen === 1) {
    return true;
  }
  if (string[0] === string[strLen - 1]) {
    return isPalindrome(string.slice(1, strLen - 1) );
  }  
  return false;
};

//0.30 ms
```
Recursion is a process when a function calls itself to solve a problem. In our code, function is called until string completes (empty string or one char left), or if condition falls. First check for first and last char in the string, then if they are same do the same thing for a substring with first and last char removed, and so on...

#### for - loop
```javascript
isPalindrome = (string) => {
  let strLen = Math.floor(string.length / 2);
  string = string.toLocaleLowerCase();

  for (let i = 0; i < strLen; i++) {
    if (string[i] !== string[strLen - i - 1]) {
      return false;
    }
  }
  return true;
}

//0.20 ms
```
for loop starts with the check for first char of the string and last char of the string. If it's equal, continue iterating through the string until the string reaches the center. 

I like the first approach as it's clean and simple, but from a performance view, it gives us the worst result, where simple for loop is more than twice time faster.
We believe in open-source, so why can't everyone code?
Tags: discuss, healthydebate
Published: 2018-09-11 15:02:00

---
title: We believe in open-source, so why can't everyone code?
published: true
description: There is a cancerous attitude in today's environment that needs to be fixed.
tags: discuss, healthydebate, 
---

This crossed our team's slack channel this morning.  Nothing really was said about it, but I felt it needed to be addressed.

[Internet Trolls Make Fun Of This Victoria’s Secret Model For Saying She Can Code, Get Shut Down With Perfect Reply](https://www.boredpanda.com/victoria-secret-model-programmer-lyndsey-scott/)

The short of it is, people couldn't believe that a model can code.  This should make everyone a little sick to your stomach.  That's right.

We need to have a talk, developers.  

Here we have an accomplished individual who is highly regarded on StackOverflow, has done video tutorials for kids along with Bill Gates and Mark Zuckerberg on Code.org, according to BoredPanda.

Who, also _happens_ to be a model.  If anything, the lesson here is she is not only a fashion model, but she is also a model for developers all over the world.

Our idea, our image, of what a developer is, should be open-source. It should be undefined, it should not be strictly-typed.  This is a problem the industry faces as a whole and we need to constantly call it out until it's no longer an issue.

We, as a society, thrive on strength by diversity in gender, race, and creed.

We are brothers and sisters forged in code.  If you have trouble accepting that, you need to refactor your beliefs.
I'm having some "not this again" feelings with Parcel, how should I be feeling about this tool?
Tags: javascript, discuss, webdev
Published: 2018-09-11 14:46:44

---
title: I'm having some "not this again" feelings with Parcel, how should I be feeling about this tool?
published: true
description: 
tags: javascript, discuss, webdev
---

It seems like yesterday Webpack emerged as the most viable option for bundling JavaScript. I still have a lot of tooling fatigue, especially since Rails really bought into Webpack.

Parcel does seem pretty great, but I feel like I'm still having a hard time with so much bleeding edge stuff in JS world.

How are you feeling about this tooling landscape, I'd love to just chat this out a bit.
CD DVD drives
Tags: external, cd, drive, technology
Published: 2018-09-11 14:23:01

---
title: CD DVD drives
published: true
description: 
tags: external, cd, drive, technology
---
The user of the stationary personal computer hardly thinks about the possibility of purchasing an external DVD-drive. There are several reasons for this. First, the standard internal drive, hooked through the interface IDE or SATA, usually has a higher speed of operation. Secondly, to attach to a "real" PC a mobile device makes sense only if the external drive is one, and the computers - a few. Thirdly, even with equal characteristics, the external drive will cost significantly more.

Read more: https://www.bestadvisers.co.uk/best-external-cddvd-drives

The question is, then who can use the external drives? The answer lies on the surface - the owners of laptops and netbooks. The thing is that branded DVD drives, with which the laptop is completed (or not completed at all) by the manufacturer, do not always suit users. They can be slow, noisy or simply buggy. And to repair this element is by no means easier than replacing it. And both will cost you a tidy sum, often directly proportional to the cost of the laptop itself. Therefore, the purchase of an external DVD-drive in some cases is a necessity, and not a way to stand out against the background of others. Although stylish design, of course, attracts attention.
Hot reloading preact with parcel, the missing doc
Tags: javascript, parceljs, beginners, preact
Published: 2018-09-11 14:10:27

---
title: Hot reloading preact with parcel, the missing doc
published: true
description: 
tags: javascript, parceljs, beginners, preact
cover_image: https://cdn-images-1.medium.com/max/1000/1*5XpP2cn1NC36TrgtqdBP3A.png
---

Today I was setting up a [preact](https://preactjs.com/) app with [parcel](https://parceljs.org) as the bundler. Before I could even start building the app, I suddenly hit a snag. Whenever I made a change to my components, my changes were being appended to the html doc instead of being replaced.

![gif](https://thepracticaldev.s3.amazonaws.com/i/gs5jnkudm77j9jb6t7xy.gif)

It turns out parcel is not the issue, preact is. I went to their [docs](https://preactjs.com/guide/differences-to-react#what-s-different-) as any developer would. I found out their their render by default appends to the node specified. The preact render function accepts a third argument which is supposed to be the node to be replaced.

So to fix the appending problem, I needed to provide the third agrument.
```react
import { h, render } from "preact";

const Happy = () => <div>Happy</div>;
const App = () => (
  <div>
    <Happy />
  </div>
);
const node = document.getElementById("root");

render(<App />, node, node.lastChild);

```
Now it behaves as expected. Maybe parcel should update their docs to include this. I wanted to make a pull request but their docs are not on github.

![](https://thepracticaldev.s3.amazonaws.com/i/fw7bq21g5zsl5lznb0ky.gif)
What is polymorphism?
Tags: webdev, beginners, learning, concepts
Published: 2018-09-11 13:41:34

---
title: What is polymorphism?
published: true
description: Polymorphism, similar to inheritance, is one of those programming concepts that takes time to understand but can be hard to explain. See if this explanation helps you understand the concept a little better.
tags: #webdev, #beginners, #learning, #concepts
---

This is another one of those obscure terms that developers tend to use a lot. [Similar to inheritance](https://flippedcoding.com/2018/09/04/what-is-inheritance/), it's one of those concepts that is both easy to understand but hard to explain concisely.

If you've been trying to find a definition of polymorphism that makes sense, I hope that this will help you.

In a nut shell, polymorphism means that you can use the same interface for different underlying data types. A simple example of polymorphism in action is basic math. You can add an integer and a float together and you won't have any problems due to the mismatched data types.

The most notable way you'll probably see polymorphism is in classes. This concept ties back into inheritance because you are dealing with derived classes that can overwrite the superclass's properties and methods. When a derived class has overwritten a superclass method or property, then the code will refer to the derived class for that method or property.

Here's a graphic of what that looks like:

![graphical representation of polymorphism](https://thepracticaldev.s3.amazonaws.com/i/4ut8wqsjbls1e72x3efo.JPG)

In this case, Dinner is the super class and Thai, Italian, and Peruvian are derived classes. As you can see, each Recipe method in the derived classes are different. So for example, when you declare an object using the Dinner class and you make a new instance of a Peruvian object, you can use the Recipe() method and not worry about what code will be executed. It will automatically defer to the code for the Recipe() method defined in the Peruvian class.

That's what polymorphism is. A method from a derived class can overwrite the method for a super class. So you can define an object with a super class and then instantiate it with a derived class. Then when you access the method, the correct code block will run every time.

<hr>

Hey! You should follow me on Twitter because reasons: https://twitter.com/FlippedCoding