teleren/devto huggingface dataset:
Partial Forms on Rails
Tags: rails, beginners
Published: 2020-02-10 05:08:42

Hello to all who are reading this. I would like to say thank you for taking the time checking out this quick lesson on partials in Ruby on Rails.

Partial forms in rails are a quick way to reduce redundant forms or pages on you website, a simple example is the ability create, edit, and update a new record. Since most of the information it is simple to create a form with labels and textarea fields of the the different model attributes. To create a partial you simply create a file in the same class view folder with the name for your choosing prefixed with and underscore(_).

_page.htmle.erb

To use this on another page use the helper method render followed by the name for page in quotes without the underscore(_).

<%= render 'page'%>
 
This simple and effective tool allows you to create simplistic and more readable code without any extra stress.
2020 goals
Tags: 2020, newyear, personaldevelopment, career
Published: 2020-02-10 04:11:17

I would like to focus my energy on the following areas and goals.

###Family

- Help them with their goals.
- Plan one or two trips together.

###Academic

- Read between 16 and 20 books and share the important points.
- Evaluate the possibility to do a PhD in NeuroScience.
- Help new guys to start their careers as developers.
- Be prepare to be a TedX speaker.
- Find a mentor.

###Health

- Try to do sports three times a week.
- Adopt a vegetarian diet and test the benefits.
- Try to eat consciously.
- Try to not be over-obsessed with work.


###Spiritual

- Continue with yoga classes. Try to find a guru.
- Continue with meditation. Try to do a spiritual retirement.
- Share the benefits of yoga and meditation.

###Travel

- Discover new places and cultures.
- Try to travel once a month.

###Social

- Increment blogging activities. It would be great to write one article per month.

---
It's really good to have an idea of the goals you wanna achieve. There is an inner presence that takes care of your year's goal. 

I would like you guys to try to plan your year. Then, let the time do the magic. Once the year is ready to finish, check the progress and you will see the magic.

If you wanna try the technique, please let me know! It would be great to know more about you and your goals :)
Website Portfolio Showcase Carousel - Vanilla JS 
Tags: codepen, webdev, javascript, css
Published: 2020-02-10 03:02:37

---
title: Website Portfolio Showcase Carousel - Vanilla JS 
published: true
tags: codepen, webdev, javascript, css
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/jni1cs3rrvl0uplmlh4y.png
---

<p> Portfolio showcase carousel with card-like layout and hover css effects</p> 

<p>Javascript adds div elements with random images from unsplash's API as the background-image via inline style. Parent/child div and inline style used for transform:scale effect</p>

{% codepen https://codepen.io/samuelhowell/pen/RwPNoqv %}
Golang New JSON parser/interpreter
Tags: go, json, jsonparser, parse
Published: 2020-02-10 01:50:39

Hi gophers and other fellow life forms.

About 6 months ago we have started a new project that font-end side with `JS`/`Node.js`/`React` and back-end side  with `Golang`. I was working for the back-end side everything was O.K. But the project grows the `'encoding/json'` package get inefficient. For example we are not able to change a 'key' or change any value with something else. Thats because we switch to some custom packages for manipulating JSON. 

At this point. I figure out 'How about I wrote a packege for JSON manipulating'

And than I start working on it. But dealing with such a project was not easy.

First I had to find a way to validate my result. Manually writing unit tests was impossible for large data. Thats because I started to integrate Node.js to this project for test-case creation and validation. And it worked perfectly.

I use a continius integration platform for test automation. And wrote a detailed documentation on __[GoDoc](https://godoc.org/github.com/ecoshub/jin)__.

And It has a cool gopher logo you should see :)

Well today its finally ready for public release. 

Name of this package is __[JIN](https://github.com/ecoshub/jin)__

It is super easy to use and much more important its super fast.
I just want to share with this to you guys.

Let's look at with an example.

```go
	// this is the JSON we will work on
	data := []byte(`{"repo":{"name":"ecoshub/jin"},"others":["jin","dev.to"]}`)
```
we are going to try to access the 'dev.to' string in 'others' array.

```go
	// In order to Unmarshal a JSON.
	// first we have to define those structs properly.
	type Repository struct {
		Name string 		`json:"name"`
	}

	type Data struct {
		Repo   Repository 	`json:"repo"`
		Others []string 	`json:"others"`
	}
	// an empty data struct
	var newData Data

	// finally Unmarshaling.
	err := json.Unmarshal(data, &newData)

	// standard error implementation.
	if err != nil {
		fmt.Println("error:", err)
	}
	fmt.Prinln(newData.Others[1])

```
Or you can use this. with no struct defination.

```go
	// just one line of code.
	value, err := jin.Get(data, "others", "1")

	// standard error implementation.
	if err != nil {
		fmt.Println("error:", err)
	}
	fmt.Println(string(value))
```

Do not miss-understand me I am not the first person who figure out this simple and elegant definition. I am just trying to expand and improve JSON manipulation.

This package has over __90__ functions/methods for ease JSON manipulation, build and formating needs. Some useful functions that i like to mention.
 
-`Add()`, `AddKeyValue()`, `Set()`, `SetKey()` `Delete()`, `Insert()`, `IterateArray()`, `IterateKeyValue()` `Tree()`. 

There is a very detailed explanations and lots of examples in __[GoDoc](https://godoc.org/github.com/ecoshub/jin)__ .

Also I think you have to  check out benchmark results :)

This is the link of repository:
https://github.com/ecoshub/jin

Please do not hesitate to fork/clone pull-request.

Thank you so much for your time.

Have a good day.
February 8th: Week in Review
Tags: weeklyretro, career
Published: 2020-02-10 01:28:35


2nd week of February is done, hope everyone had a good time.

Things I learned/did this week:
- I got promoted to Senior Software Engineer 🎊🎊
- Started the [movie-search](https://github.com/Danondso) react project based on [Simon Holdorf's](https://dev.to/simonholdorf) post:
[9 Projects you can do to become a Frontend Master in 2020 ](https://dev.to/simonholdorf/9-projects-you-can-do-to-become-a-frontend-master-in-2020-n2h)
- Built out the artist profile for [basic-music-player](https://github.com/Danondso/basic-music-player), I'm super stoked on how it turned out.
![basic-music-player-artist-profile](https://dev-to-uploads.s3.amazonaws.com/i/6b4hae1rkjr8ad9ebgfx.gif)


Articles I've read: 
- Learned about functional react components at [programmingwithmosh](https://programmingwithmosh.com/react/react-functional-components/) react is blowin' my mind so far and I'm excited to delve into it more. 
- I wanted to get a clearer idea of JAMStack so I read about it at [jamstack.wtf](https://jamstack.wtf/)
- [evernoise](http://everynoise.com/) is a neat sight that maps music genres, from main stream to ultra niche. Highly recommend checking it out if you need some new music.  


I'm working on a series based off my notes from reading You Don't Know JS, so be on the lookout for them. 

If you did anything cool you want to share let me know in the comments. Be seein' ya 🤠 🐮
Hobby Project: Pull All Your Dev.to Articles
Tags: dlang, showdev
Published: 2020-02-10 01:16:03

This concludes the test drive for the api. I needed to make some final adjustments.

https://gitlab.com/jessephillips/devarticlator/-/compare/v0.0.8...v0.1.0

The purpose of this session was to navigate to the last page and store all users articles. And while this work was easy I started realizing how broken my filtering for new articles was. The returned articles are in order of publication, I knew this, the implications is that article ID has no guaranteed order. This is why I included the date pulled, I had just thought I found a shortcut.

-----

The unpublished articles create their own set of challenges. These articles are more likely to be changing and Dev provides a different slug than what the published article will be.

At this point I'm not solving this problem. Implications 

* unpublished articles are always written
* an unpublished article which gets published will result in a new article file

------

One of the more challenging parts of this was keeping the `isNewerArticle` function `pure` and `nothrow`. It would have been easy to just perform the string conversion on the spot, but since I marked the method `nothrow` this action was denied.

Remember the original statement I said was my code wasn't better for adding attributes. Well now I am paying for it and I think it is for the better.

Placing the conversation in the `isNewerArticle`function causes a delay in reporting an issue. I'm now required to validate and setup my data before beginning to process it.

```dlang
auto data = res.readJson().get!(Json[]);
            data.each!(x => x["published_timestamp"] = x["published_timestamp"].get!string.empty 
            ?  SysTime.init.toISOExtString : x["published_timestamp"].get!string);
```
-----

When writing the unittests for the range got a little bit out of hand. 

See nested functions actually come out as delegates, so I created an alias to a lambda so the compiler can determine context does not require a delegate. But like most writings, I had forgotten static nested functions aren't delegates. 

```dlang
alias fakeArticles = (uint page) @safe {
        return () @trusted {
        static iteration = 0;
        if(iteration++ < 2)
        return generate!fakeArticleMe
            .map!(x => cast(immutable(ArticleMe))x.deserializeJson!(ArticleMe))
            .take(3)
            .array;
        return generate!fakeArticleMe
            .map!(x => cast(immutable(ArticleMe))x.deserializeJson!(ArticleMe))
            .take(0)
            .array;
        }();
    };
```

I also used some unsafe calls so I wrapped the body in a trusted lambda. 

-----

I've included a readme now that a have a reasonably usable application for pulling articles. I've also registered with D's code registry. 

https://code.dlang.org/packages/devarticlator

-----

My unittests still don't [cover the unpublished articles](https://gitlab.com/jessephillips/devarticlator/issues/1).
The Lean Startup, hands on
Tags: agile, lean, startup, productivity
Published: 2020-02-10 00:54:42

---
title: The Lean Startup, hands on
published: true
description: Applying The Lean Startup methods to solve my own problem of having a simple Digital Bullet Journal
tags: agile, lean, startup, productivity
series: LeanStartup
---

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/iz9bi110917ww75swotk.jpg)

[*The Lean Startup*](http://theleanstartup.com/principles) methodology seems pretty simple at first sight. All you have to do, is follow the never ending **Build-Measure-Learn** loop and you'll be fine. But reality rarely matches our theoretical expectations. So here I will try to demystify this methodology by applying it to solve my own problem of having a simple Digital Bullet Journal.

## Enter the loop

I will start my *Lean Startup* journey by building something. Here many would expect us to start building a **Minimum Viable Product (MVP)**, but that is not necessary what I need right now.

What I will **Build** is a *search query*. I will search google for existing solutions to my problem. I will dig down into products being offered, and also into workarounds that people develop to achieve the same goal.

This *search query* will allow me to **Measure**, indirectly, if there is a potential market for the product I'm looking to build. The premise being that, if products and workarounds exist, it would indicate that people need it.

From my brief search I was able to **Learn** that there are not many products that solve this problem, and that people rely on working around with other products to achieve the goal of having a Digital Bullet Journal.

And that's it, I have completed my first **Build-Measure-Learn** loop.

## Loop-the-loop

Having learned that people need this product, and more importantly that there are no simple solutions available, is time to go through the loop once again. This time I will **Build** a **Proof of Concept (PoC)**.

The reason why I want to build a **PoC** is to prove to my self that this is in fact feasible. Also, I would like to have something simple that I can show others to get their feedback.

Having created this **PoC** I then proceeded to host it using Zeit so that I can share it with others, but at no cost for myself (bootstrapping). As I mentioned before, I want to gather feedback about this idea. In other words, I want to **Measure** and **Learn** if I'm in the right direction or if I need to adapt my approach (pivot).

## Try it out

So here it is: [DiBuJo](https://dibujo.now.sh/)

In its current form its a simple *create-react-app* with a basic *wysiwyg* using *draftjs*. It will store your journal entries in the *localStorage*. And it will allow you to create and edit entries.

Give it a go, and let me know what you think of it in the comments section!

Looking forward to going through more loops with you and apply this simple but powerful methodology.
Is there a point to use Docker Swarm on a single computer?
Tags: help, docker
Published: 2020-02-10 00:47:37

By now I understand the purpose of Docker itself and I've been using it for local development for quite a bit

The course I'm following introduces Docker Swarm by using it locally on a single machine, by making use of Virtual Machines (I think)

So that got me thinking, learning purposes aside, is there a benefit to use Docker Swarm on a single machine?

Thank you
How you can learn Docker from the beginning. Covers docker-compose, volumes, databases, in the Cloud and much more
Tags: docker, devops, webdev, beginners
Published: 2020-02-10 00:43:32

---
title: How you can learn Docker from the beginning. Covers docker-compose, volumes, databases, in the Cloud and much more
published: true
description: Docker is a core skill you need today as a developer to make your apps run in many places, on your computer, in the Cloud, and even on IoT devices. Learn how with this series
tags: docker, devops, webdev, beginners
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zho8qnb228qz3pgveznd.jpg
---

Follow me on [Twitter](https://twitter.com/chris_noring), happy to take your suggestions on topics or improvements /Chris

- [Sign up for a free Azure account](https://azure.microsoft.com/en-us/free/?wt.mc_id=devto-blog-chnoring)
To use containers in the Cloud like a private registry you will need a free Azure account
- [5 part series on Docker](https://dev.to/softchris/5-part-docker-series-beginner-to-master-3m1b), this series aims to provide you with a solid foundation in Docker and covers basic concepts, volumes, networks, docker compose and much more
- [Dockerfile great practices for beginners](https://dev.to/azure/improve-your-dockerfile-best-practices-5ll) This is a guide that will ensure your Docker Image will be as small as possible but also ensure it's performant and you understand why you should use certain commands.
- [Improve your Docker workflow with this VS Code extension](https://dev.to/azure/improve-your-docker-workflow-with-this-vs-code-extension-j60)
VS Code can really help you with your Docker workflow with this extension, build run, author, deploy, lot's of great commands
- This two-part series
[Part I, Creating your Microservices with Docker](https://dev.to/azure/learn-how-you-can-build-a-serverless-graphql-api-on-top-of-a-microservice-architecture-233g)
[Part II, Bring your container to the Cloud](https://dev.to/azure/learn-how-you-can-build-a-serverless-graphql-api-on-top-of-a-microservice-architecture-part-ii-deploy-it-to-the-cloud-26b6)
show how you can use Docker to build Microservices with Docker Compose as part of building and Cloud Hosted API
- [Want to keep using Docker in the Cloud](https://dev.to/azure/all-your-containers-are-belong-to-usdeploying-to-microsoft-azure-7dm)? This shows how you can build your containers and bring them with you to the Cloud
- [My crash course and learning journey with Docker](https://dev.to/azure/a-crash-course-to-the-most-important-docker-concepts-and-their-commands-4eio), I describe how I as a frontend developer barely understood what I was doing to finally understanding why I needed Docker and took the needed time to learn it and leverage its features
🇫🇷 Introduction à TDD en Swift (Partie 3) - Une bonne documentation
Tags: swift, tdd, ios
Published: 2020-03-26 14:45:42

---
title: 🇫🇷 Introduction à TDD en Swift (Partie 3) - Une bonne documentation
published: true
date: 2020-02-10 00:00:00 UTC
tags: swift, tdd, ios
canonical_url: https://academie.ryfacto.fr/advanced-ios-craft/intro-tdd-swift-3-une-bonne-documentation.html
cover_image: https://academie.ryfacto.fr/images/2020/02/intro-tdd-3.jpeg
---

Cet article fait partie de la série _"Introduction à TDD en Swift"_

- [Introduction à TDD en Swift (Partie 1) - 7 étapes essentielles](https://academie.ryfacto.fr/advanced-ios-craft/intro-tdd-swift-1-7-etapes)
- [Introduction à TDD en Swift (Partie 2) - Vive le typage et la généralisation](https://academie.ryfacto.fr/advanced-ios-craft/intro-tdd-swift-2-typage-et-generalisation)
- **Introduction à TDD en Swift (Partie 3) - Une bonne documentation**

Dans le [précédent article](https://academie.ryfacto.fr/advanced-ios-craft/intro-tdd-swift-2-typage-et-generalisation) de cette série tu as appris les bienfaits de la pratique de TDD :

- les tests sont fiables et nous permettent de ne rien casser,
- les tests nous poussent à raisoner plus profondément, à avoir un code plus robuste,
- les tests sont plus importants que le code de production.

Nous allons continuer aujourd’hui le kata [FizzBuzz](http://kata-log.rocks/fizz-buzz-kata) en implémentant plusieurs nouveaux tests en TDD.

Au programme :

- pourquoi une suite de tests doit constituer la meilleure documentation possible,
- je vais déroger au cycle RED-GREEN-REFACTOR (_crime crime !_ 😂),
- tu vas avoir un petit aperçu du property-based testing (_wat?_),
- et enfin on va utiliser le résultat d’un test pour écrire un test (_waaaat?_).

Alors, prêt(e) ?

[Lire la suite...](https://academie.ryfacto.fr/advanced-ios-craft/intro-tdd-swift-3-une-bonne-documentation.html "Introduction à TDD en Swift (Partie 3) - Une bonne documentation")
Minimum Candies - Peaks and Vallies[Python]
Tags: algorithms, python, interview, arrays
Published: 2020-05-21 15:53:20

---
title: Minimum Candies - Peaks and Vallies[Python]
published: true
date: 2020-02-10 00:00:00 UTC
tags: algorithms, python, interview, arrays
series: Coding Challenge
canonical_url: https://avinsharma.com/min-candies/
---

Here’s the question on [leetcode](https://leetcode.com/problems/candy/).

So we are given an array of ratings something like `[1, 3, 2, 1, 2, 7, 5]` and we need to handout as little candies as we can. So in my head(without any algorithm) the way I solved this was, well in 2 ways:

1. 

Going from left to right and changing the candies as required. It went like this:

```python
['1']
[1, '2']
[1, 2, '1']
[1, 2, 1, '1'] -> [1, 2, '2', 1] ->[1, '3', 2, 1]
[1, 3, 2, 1, '2']
[1, 3, 2, 1, 2, '3']
[1, 3, 2, 1, 2, 3, '1']
Sum = 1 + 3 + 2 + 1 + 2 + 3 + 1 = 13
```

The problem which comes out pretty fast is that based on the rating you might increase the number of candies for a particular index but you might have to correct all the previous indexes as we see in the third line in the above example.

This is probably going to take O(N^2) Time

2. Starting from the smallest indexes and going outwards. This will take O(N) time.

## Peaks and Valleys

The concept is to figure out when are we increasing/decreasing or finding out local minima and maxima. If we plot the above array we get a chart that looks like a mountain, hence the name peaks and valleys.

So finding these local minimums and expanding outwards feels a little involved.

Another way to solve this would be to go from left to right and update the number of candies for all the increasing ratings and similarly go right to left and do the same. We have to be careful about the peaks, where two rising sequences meet, we have to select the larger number of candies so that the peak is greater than both the sides.

```python
def candy(ratings):
    candies = [1 for _ in ratings]
	
	for i in range(1, len(ratings)):
		if ratings[i] > ratings[i - 1]:
			candies[i] = max(candies[i], candies[i-1] + 1)
	
	for i in range(len(ratings) - 2, -1, -1):
		if ratings[i] > ratings[i + 1]:
			candies[i] = max(candies[i], candies[i+1] + 1)
	
	return sum(candies)
```
Global Themes, Variants, And Modes With Styled-Components
Published: 2020-04-10 15:03:30

---
title: Global Themes, Variants, And Modes With Styled-Components
published: true
date: 2020-02-10 00:00:00 UTC
tags: 
canonical_url: https://stephencharlesweiss.comblog/2020-03-01/styled-components-global-theme-mode-variant/
---

If I were to list my strengths, web design wouldn’t top the list. None the less, I like learning about it and know that I’ll continue to improve over time by chipping away.

One thing I’ve been struggling with since adding a dark mode to my site (I look forward to making this a much more _pleasant_ experience soon), was how the mode was intended to interact with the global theme. And then what happens if you want variants for components?

I put together a [CodeSandBox](https://codesandbox.io/s/adoring-shannon-0yt60?fontsize=14&hidenavigation=1&theme=dark) to play around with the concepts.

Because it’s such a simple single page, I can see how all of the pieces come together and interact. It’s also made clear why my coworker, Justin Connor, put together a library called `styled-variants`!

Dealing with variants can _quickly_ become a hassle - particularly if you’re duplicating the logic between modes.

The full code is below.

```javascript
import React from "react";
import "./styles.css";
import styled, { ThemeProvider } from "styled-components";

const theme = {
  light: {
    bg: "powderblue",
    fs: "72px",
    maxWidth: 1000
  },
  dark: {
    bg: "red",
    color: "white",
    fs: "72px",
    maxWidth: 1000
  }
};

const buttonVariant = {
  light: {
    primary: {
      boxShadowColor: "teal"
    },
    secondary: {
      boxShadowColor: "grey"
    }
  },
  dark: {
    primary: {
      boxShadowColor: "orange"
    },
    secondary: {
      boxShadowColor: "orange"
    }
  }
};

const Title = styled.h1`
  background-color: ${({ theme, mode }) => theme[mode].bg};
  font-size: ${props => props.theme[props.mode].fs};
  color: ${({ theme, mode }) => (mode === "dark" ? theme[mode].color : "")};
`;

const Button = styled.button`
  box-shadow: 0.25rem 0.25rem
    ${({ theme, mode, variant }) => theme[mode][variant].boxShadowColor};
`;

const Wrapper = styled.div`
  background-color: ${({ theme, mode }) => theme[mode].bg};
  padding: 1rem;
`;

function App() {
  const [mode, setMode] = React.useState("light");
  function handleClick() {
    const nextMode = mode === "light" ? "dark" : "light";
    return setMode(nextMode);
  }

  return (
    <ThemeProvider theme={theme}>
      <Wrapper className="App" mode={mode}>
        <Title mode={mode}>Hello CodeSandbox</Title>
        <h2>The current mode is: {mode}</h2>
        <Button
          mode={mode}
          variant={"primary"}
          theme={buttonVariant}
          onClick={handleClick}
        >
          Toggle Mode
        </Button>
      </Wrapper>
    </ThemeProvider>
  );
}

export default App;
```
Inner Join with Multiple Conditions In Laravel
Published: 2020-02-12 13:22:20

---
title: Inner Join with Multiple Conditions In Laravel
published: true
date: 2020-02-10 00:00:00 UTC
tags: 
canonical_url: 
---

This tutorial will give you example of inner join condition in laravel i explained simply about inner join in laravel eloquent i explained simply step by step laravel 6 eloquent join tables you will learn laravel inner join multiple on So lets follow few step to create example of laravel inner jo