teleren/devto huggingface dataset:
Explain Blockchain Like I'm Five
Tags: explainlikeimfive, blockchain, beginners, security
Published: 2019-05-16 07:13:11

---
title: Explain Blockchain Like I'm Five 
published: true
description: So what is blockchain?
tags: #explainlikeimfive, #blockchain, #beginners, #security
---

So let's say that you are a very rich man and you want to hire a driver for your limousine. I think that everyone being in this position would check thoroughly the background of a candidate for this delicate and critical for his safety position. I am sure that the rich man would like to know when the candidate got his driver license or if the candidate has ever been caught driving drunk, how many road traffic code violations have done etc. The rich man asks the candidate for those pieces of information during the interview and the candidate responds that he has everything in a text or spreadsheet file in his computer and he is more than willing to share it with him. The big question is: Would the rich man believe the candidate or not ? The candidate claims that everything in this file is true but only he and the authorities can know for sure if it is true or if something is missing because it is created by himself. The solution for the rich man would be to contact the authorities (a third party) and learn the truth. There is no other solution which does not involve third parties that can guarantee that something (a block of data for example) is true and/or it has not been tampered by someone. 

And that's where blockchain comes in.
Blockchain in layman's term is a distributed database that guarantees with a cryptographic way the continuity and the immutability of the records written without the need of a trusted third party. Data is organized in timestamped blocks and each block has a unique hash which has been calculated for the specific data that this block holds. Each new block added in the blockchain checks the validity of the hash of the previous block and thus the data in a block cannot be tampered or deleted simply because the hash will change and as a result the new block will not be added to the chain. A public blockchain is available to everyone and thus everyone can see the content of its blocks.

So in the example above if each and every fact regarding the history of the candidate driver was written in the blockchain by the responsible party (authorities such as the Ministry of transportation, police etc), the rich man would be sure that it is true and it has not been tampered and he would actually have a mathematic proof of that because we know that it is computationally impossible to calculate the same hash for a different block of data. The rich man would be able to see the blockchain himself and by whom each fact in the driver's history has been written by. So, the rich man would be sure for the truth!
I developed a block editor made by Vue.js
Tags: vue, javascript
Published: 2019-05-16 03:54:00

Here is a demo page.

{% codepen https://codepen.io/takitakit/pen/RmpVKL %}


# Background

If I produce WordPress or CMS and provide it to my customer,
I find the following issues with the WYSIWYG editor:.

* It is difficult to use unless you get used to it.
* Even if you get used to it, there is a case that the markup may collapse.
* Difficult or cumbersome to limit format of markup output

As an alternative to the WYSIWYG editor, we have developed an editor that meets the following requirements:.

* Easy to use, easy to use even if you are not used to it
* Minimize markup editing
* Easily limit markup

You can find the source on [Github](https://github.com/takitakit/block-editor-vue) for more information.

# What This Editor Can Do

* To edit any combination of predetermined block elements and output a single markup as a whole.
* Exporting or importing tags from hidden elements (Assumes POST on management screen)

To improve usability, you can't edit HTML markup directly or paste styled text directly from Word.


# Usage

The types of block elements that can be used are:.

* Paragraph (Text + Image)
* Heading
* List.
* Table
* Columns (Nest non-column elements)
* HTML (Enter any HTML markup)

The markup output is somewhat specific for each block element.
For example, for a paragraph:.

```html
<div class="paragraph-wrap align-left">
    <div class="text">
        "<a href="https://github.com/takitakit/block-editor-vue" target="_blank">block-editor-vue</a>" is a block editor that allows you to stack any combination of block elements, such as paragraphs, headings, lists, and so on.<br>If you are using the CMS management screen, you can use this editor as a means of editing the body HTML of an article.
    </div>
</div>
```

The class name (paragraph-wrap) can be changed as an option so that it can be used in various cases.

## Other Features

* Limit the types of block elements available. [Demo](https://codepen.io/takitakit/pen/XwpeEj/")

* Name a preset with specific block elements, class names, and so on. [Demo](https://codepen.io/takitakit/pen/arNwGv/)
* Applying Text Styles Within Block Elements. [Demo](https://codepen.io/takitakit/pen/OYWzmg/)

If you read this article and have any comments or requests, please send me your comments.
100% Anonymous VPN: Does it really exist?
Tags: vpn, security, privacy
Published: 2019-05-16 06:30:27

---
title: 100% Anonymous VPN: Does it really exist?
published: true
description: You know that a VPN protects your privacy, but are you revealing your identity even when your VPN is on?
tags: vpn, security, privacy
---

What does online anonymity mean to you? Do you only want to keep your browsing private or do you need complete anonymity because you’re fighting for freedom of speech? You know that a VPN protects your privacy, but are you revealing your identity even when your VPN is on?

You have to take precautionary measures to keep your information and your identity private. However, it’s also true that it’s nearly impossible to achieve full anonymity without a VPN.

You can read up more at an [article about VPN anonimity] (https://nordvpn.com/blog/what-anonymous-vpn-mean/)
Build your next Golang audit trail system with Libra
Tags: go, opensource, showdev
Published: 2019-05-16 04:23:31

---
title: Build your next Golang audit trail system with Libra
published: true
description: Libra is a Go library to compare the object and spot the difference between two of them
tags: go, opensource, showdev
---

Hi everyone! :wave:

I am tinkering Libra ( https://github.com/haritsfahreza/libra ), the Go library to compare the object and spot the difference between two of them.

If you want to build an audit trail system in Go, you may consider Libra as your private detective :detective:

Please drop by and I really love to have your review and advice :bow:

Have a good day!
No need to install mongoose, bcrypt, jsonwebtoken and many more basic npm packages again
Tags: node, npm, mongodb, javascript
Published: 2019-05-16 06:01:59

Recently I developed an npm package "beatific" (https://www.npmjs.com/package/beatific)
which eradicates the need to install the following packages
 - mongoose
 - bcrypt/bcryptjs/bcrypt-nodejs
 - jsonwebtoken
 - morgan
 - helmet
 - compression

This package inherits the functionalities of each of the above package and wraps them into easy syntax.

And one more amazing functionality of this package is that it generates the dockerfile of your nodejs project automatically.

If you like this, do give its github repo a star (https://github.com/yashvardhan-kukreja/npm-beatific) and, PRs and suggestions are always welcome :)
Service worker registered yet?
Tags: angular, pwa, serviceworker
Published: 2019-05-16 05:59:56

## [TL;DR](#tldr)


Having a little app, trying to get angular's service worker registered, took longer than expected.

Using the normal `ng add @angular/pwa --project *project-name*` added all needed files. Yet, building / serving with `--prod` it doesn't register anything.

## Good. Lets google.

Many sites/pages/hours later, nothing really answered the issue, all there was is "use a custom register code" like

```ts
if ('serviceWorker' in navigator && environment.production) {
  navigator.serviceWorker.register('./ngsw-worker.js');
}
```

Well that worked, but still if this was the only way to add the worker, why did Angular's `ServiceWorkerModule.register('./ngsw-worker.js')` not work then?

## Lets debug.


At first I thought it was because of using `nrwl` and something messed up with the `angular.json`.

Created a second app in my workspace, added the pwa and well there it works.

## Now figuring out why my app just doesn't want to register it there ...


Added part by part to the newly app, everything worked until I added NgRx EffectModule. *Odd.* The Effects-Class was empty, just had some services injected.

Some more hours of searching later, why this could be a reason that it registers the normal way...

- Wrong Base Href? - Checked, No changes
- default router redirect '' -> 'page'  - Removed, still not working
- Updated to 8.0-rc3 - Still not working

Looking at the source-code of `ServiceWorkerModule` I saw that it uses `ApplicationRef.isStable()`-Observable to wait to register. But `isStable()` just stays `false`.

Luckily I also saw that the `.register`-Method also has an `options` argument. And inside that, you can set `registrationStrategy`. (*Which ~~isn't~~ wasn't listed in the docs, by the time I wrote this article.*)

Possible Strategy's:
- `registerWhenStable` (default)
- `registerWithDelay:*delay*`
- `registerImmediately`

<a name="tldr"></a> 

## Solution.

```ts
  ServiceWorkerModule.register('./ngsw-worker.js', {
    enabled: environment.production,
    registrationStrategy: 'registerImmediately'
  }),
```

Using either `registerWithDelay` or `registerImmediately` at least registers it without having a custom register-code. (So it should be future proof, using only the `ServiceWorkerModule.register`-call)
Sending docker container logs to a separate file
Tags: commandline, docker, quicktip
Published: 2019-05-16 07:55:33

---
title: Sending docker container logs to a separate file
published: true
tags: command line,docker,quick-tip
canonical_url: https://flaviabastos.ca/2019/05/16/sending-docker-container-logs-to-a-separate-file/
---

In a large web application, the backend logs can get quite verbose: requests created, sent, processed, received, etc. The list can grow large very quickly depending on how logs are implemented.

You can check the logs from a Docker container using `docker logs`, no need to exec into the container:

```
docker logs <container\_id>
```

You can find the _<container\_id>_ with `docker ps` and it’s not necessary to use the full ID. The first few characters is enough. So if the container id is `e1215bf8014c`, the command will look like:

```
docker logs e121
```

If you run `docker logs` you will probably see screens and more screens of logs. You can limit the logs to the last `n` lines with `--tail`:

```
docker logs --tail 500 <container\_id>
```

The command above will only display the last 500 lines. Much better.

But reading logs on the terminal is no fun so you might also want to direct the logs to a file that can be opened in the text editor, for example. To output the docker container logs to a file, run:

```
docker logs --tail 500 <container\_id> > mylogs.txt
```

> _The post [Sending docker container logs to a separate file](https://wp.me/pa0b0y-3Q) was originally published at _[flaviabastos.ca](https://flaviabastos.ca/)
Front-end
Published: 2019-05-16 03:47:24

sorry for my broken English just i wanna ask u guys i'm so confused about front End develop in fact i have a chance to study it for 7 month then start work but i hate all these stuff i mean this field is so developed and every month there is a new version of software or a language not like back end it depends on logic more but i don't like back end should i start to learn front end or not?
Surprising behavior with Rails I18n Lazy Lookups and Partials
Tags: help, rails, i18n
Published: 2019-05-16 02:12:53

---
title: Surprising behavior with Rails I18n Lazy Lookups and Partials
published: true
description:  Do any of y'all know of a way to preserve the virtual path used in Rails I18n lazy lookup while using partials with blocks?
tags: help, rails, i18n
---

Rails i18n supports [lazy lookup](https://guides.rubyonrails.org/i18n.html#lazy-lookup) so that if you have a locales file shaped like this:

```yml
en:
 newsletter_cta:
   title: "Stay Up To Date With The Latest Happenings"
```

You can reference the value in `newsletter_cta.title` via `t('.title')` when in `app/views/_newsletter_cta.html.erb`

In many Rails applications, I extract partials to encapsulate components so any HTML/CSS oriented team member doesn't have to learn how to write helper methods when writing components; and so we don't wind up with copy-pasted code that would necessitate massive pain when upgrading or shifting the underlying UI framework.

Here's an example of a bootstrap section:

```erb
# app/views/application/_section.html.erb
<section class="section-wrap">
  <div class="container">
    <%= yield %>
  </div>
</section>
```

Which I can then use in other views, like this:
```erb 
# app/views/_newsletter_cta.html.erb
<%= render "section" do %>
  <h2><%= t('newsletter_cta.title') %></h2>
  <%= render "cta-button", text: t('newsletter_cta.title') %> 
<% end %>
```

This works fine, so long as don't rely on lazy lookup and I hardcode the full lookup string for the translation.

However, as soon as I use lazy lookups the translation is not found. 

```erb 
# app/views/_newsletter_cta.html.erb 
<%= render "section" do %>
  <h2><%= t('.title') %></h2>
  <%= render "cta-button", text: t('.title') %> 
<% end %>
```


Tracing through to [the translate method in ActionView::Helpers::TranslationHelper](https://github.com/rails/rails/blob/b9ca94caea2ca6a6cc09abaffaad67b447134079/actionview/lib/action_view/helpers/translation_helper.rb#L87) we see that it relies on a method named [`scope_key_by_partial`](https://github.com/rails/rails/blob/b9ca94caea2ca6a6cc09abaffaad67b447134079/actionview/lib/action_view/helpers/translation_helper.rb#L126) which in turn, relies on an instance variable `@virtual_path`.

Do any of y'all know of a way to preserve the virtual path while using partials with blocks? Is there a gem somewhere that changes this behavior? I'm a bit surprised no one else has stumbled into this.
How I offboard myself when leaving a job (with gifs!)
Tags: offboarding, job, gifs
Published: 2019-05-15 17:49:48

---
title: How I offboard myself when leaving a job (with gifs!)
published: true
description: Knowing what and how to leave a job is a difficult skill. This is my personal checklist for leaving on good terms and with all my stuff.
tags: offboarding, job, gifs
---

I have left several jobs so far in my career.  Some were because I was moving and other times it was for new opportunities I wanted to pursue. I always try to leave on good terms and handoff everything I am currently doing.

This is my list of things I personally do before my last day (in addition to anything listed in an offboarding document or process)

- Remove personal files and browser bookmarks from laptop
![Old man moving the "My Computer" icon to the Trash on a Windows machine. The computer disappears when he completes it.](https://media.giphy.com/media/de5bARu0SsXiU/giphy.gif)

- Pack up and remove personal items from my desk
![Man flipping over a messy desk. Items fly off and the desktop is clean when the desk rights itself and he sits back down.](https://media.giphy.com/media/oCGjUWkj8vz9u/giphy.gif)

- Return extra office supplies back to the office supply cabinet
![(Broad City) Two women talking to each other. One has her coat open and is showing off office supplies. The other is saying "You took all his office supplies?"](https://media.giphy.com/media/gw3ElR1zQkBqoGl2/giphy.gif)

- Be at peace with the fact that the glitter will remain no matter what I do
![Two people lazily throwing glitter.](https://media.giphy.com/media/RkG1FF2PjlBvaN4rct/giphy.gif)

- Hand out business cards to those I want to keep in contact with
![Man handing another this business card and saying "Do contact me."](https://media.giphy.com/media/xUNd9PsdMzOOArBa1i/giphy.gif)

- Make sure all work in progress is checked in and pushed out to version control
![Woman saying "Check" and making a check motion with her hand.](https://media.giphy.com/media/l4EpblDY4msVtKAOk/giphy.gif)

- Organize my research notes and bookmarks for handoff
![Man waving his hands while papers fly and sort themselves into boxes.](https://media.giphy.com/media/m77wEsvF99FyU/giphy.gif)

- Recycle old notes and documentation (destruction completed as per company policy, check policy beforehand to determine if you need to shred anything)
![Seth Meyers shredding paper.](https://media.giphy.com/media/l0IyjK57IEerH0xMc/giphy.gif)

- Hand out remaining stickers, tokens, and rewards
![Woman giving another a gold star sticker.](https://media.giphy.com/media/3o7525CnwPAlwoG7qE/giphy.gif)

- Organize happy hour
![(The Office) Three men dancing in an office.](https://media.giphy.com/media/l0MYt5jPR6QX5pnqM/giphy.gif)

- Say Goodbye to everyone
![(The Good Place) Janet waving excitedly and saying "Bye guys!"](https://media.giphy.com/media/fWgQH01z4rjwrZckyM/giphy.gif)

Leaving a job can be stressful and exciting but that is no excuse for accidentally leaving your favorite Golden Girl figurines behind.
Throw All of your Email Subscriptions in the Garbage
Tags: productivity, email, subscriptions
Published: 2019-05-15 23:40:20

---
title: Throw All of your Email Subscriptions in the Garbage
published: true
description: Who cares about inbox zero? Just get rid of all the crap you don't even read.
tags: productivity, email, subscriptions
cover_image: https://thepracticaldev.s3.amazonaws.com/i/392zldjmmhtrdqx650ts.jpg
---

I do. not. care. about inbox zero. :) Too often, it becomes less about efficiently managing your inbox and more about rushing to have no emails for any reason. I prefer to make sure I'm adequately handling messages instead of emptying my box. But still, my number one tip for a clean inbox?

### Get rid of all of your subscriptions.

Yes. I mean ***all*** of them. Start over. You know for a fact you have too many. Just take an hour and do it. It's a huge step, but what you'll gain is learning which subscriptions you actually love and want to hold on to. If it's worth the work to go find it again, it's worth the space it takes up in your inbox.

For fun, here are a few things I love that  I currently subscribe to:

1. [The Minimalists](https://www.theminimalists.com/start/) - Life and minimalism
2. [Praxis Newsletter](https://discoverpraxis.com/newsletter/) - Professional advice
3. My local knit shop - One of my favorite places to go for fun

This post is short, but seriously, it's that simple. Unsubscribe from everything. Throw it all in the garbage. Once you've figured out what you're re-subscribing to, share them with us in the comments or [send me a tweet](https://twitter.com/ashleemboyer). :)

---

Did you know I have a newsletter? 📬

If you want to get notified when I publish new blog posts or make major project announcements, head over to [https://ashleemboyer.com/newsletter](https://ashleemboyer.com/newsletter).

---

*[Image](https://unsplash.com/photos/uGcDWKN91Fs) by [Joanna Kosinska](https://unsplash.com/@joannakosinska) on [Unsplash](https://unsplash.com).*
Learning Go Notes - Clean Architecture and Go, is it a match?
Tags: go, cleanachitecture
Published: 2019-05-15 23:33:01

These last days I was migrating a PHP project from symfony 2.8 to 3.4 and PHP from 5.6 to 7.2 and it was taking a lot of time to run the unit tests, I recently started to study go and I was postponing the study of clean/hexagonal achitecture for a while.

I still a bit unconfortable using go since I am pretty new, I felt that there was no very mature web framework to use with it to understand the language patterns, everyone saying to use the standard library, but no examples about how to do complex applications.

Since I didn't found a good example, I thinked a good Idea would be study another thing for a while and try go again later, and them I searched about hexagonal architecture and bang, I found these 2 presentations:

**GopherCon UK 2018: Kat Zien - How do you structure your Go apps?**
https://www.youtube.com/watch?v=VQym87o91f8

**Robert C Martin - Clean Architecture and Design**
https://www.youtube.com/watch?v=Nsjsiz2A9mg

And to me it seems like a match, the way that golang works with projects and dependencies, seems to work pretty well, I will try it later.
Dev hack: Viewing tricky-to-view images in the browser
Tags: html, javascript, webdev, beginners
Published: 2019-05-15 23:17:30

---
title: Dev hack: Viewing tricky-to-view images in the browser
published: true
description: How to view images in your browser that blend in with the background color.
tags: html,javascript,webdev,beginner
---

Have you ever been in a situation where you come across an image on the web, you choose to open it in a new tab to look at it in detail, but you don't see anything? This is probably because the image is black with transparent parts. Take an image like this:

![A transparent image with black emoticons.](https://thepracticaldev.s3.amazonaws.com/i/rrt34jh94ezrxp591x3w.png)

If you are on Chrome (not tested in other browsers), and you open the image in a new tab, you will not see much of anything because the image is black with a transparent background. This can become a bit frustrating when you need to zoom in on these images.

Luckily, now there's a solution! 😁 Open up your browser console on an image webpage, and enter the following snippet:

```javascript
function c(o){document.body.style.background="rgb("+o.rgb.map(Math.round).join(",")+")"}s=document.createElement("script"),s.src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js",document.body.appendChild(s),document.body.innerHTML+="<input class=\"jscolor {onFineChange:'c(this)'}\"style='position:absolute;right:0;top:0'value='0e0e0e'type='search'autocomplete='off'>";
```

Using this, you will get a handy-dandy color picker in the top-right of your screen that will live-update the background color of the page as you change it in the picker. This is to make it easier to view the images that blend in. Let's pull apart this program:

* `function c(o){document.body.style.background="rgb("+o.rgb.map(Math.round).join(",")+")"}` - A function to set the webpage background based on a `jscolor` object (more on that later).

* `s=document.createElement("script")` - Create a new `<script>` element.

* `s.src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js"` - Set the `src` of the `<script>` element to the library we want to load.

* `document.body.appendChild(s)` - Append the `<script>` element to the document, loading the resource.

* `document.body.innerHTML+="<input class=\"jscolor {onFineChange:'c(this)'}\"style='position:absolute;right:0;top:0'value='0e0e0e'type='search'autocomplete='off'>` - Add a custom `jscolor` input element to create the color picker. Set it up to call `c()` every time the color updates.

As seen in the verbose version, the snippet uses the library [`jscolor`](http://jscolor.com/) for the color picker.

I hope this small snippet helps you!
Pack the same elements into a list inside a list.
Tags: elm, challenge
Published: 2019-05-15 21:50:36

---
title: Pack the same elements into a list inside a list.
published: true
description: 
tags: elm, challenge
---

Again a challenge from [99 Elm problems](https://legacy.gitbook.com/book/johncrane/ninety-nine-elm-problems/details)

Convert a list to a list of lists where repeated elements of the source list are packed into sublists. Elements that are not repeated should be placed in a one element sublist.

```
pack [1,1,1,2,3,3,3,4,4,4,4,5,6,6] ==
    [ [1,1,1]
    , [2]
    , [3, 3, 3]
    , [4, 4, 4, 4]
    , [5]
    , [6, 6]
    ]
```