teleren/devto huggingface dataset:
Linux Virtual File System (Talk To Linux kernel)
Published: 2018-05-01 08:35:19

---
title: Linux Virtual File System (Talk To Linux kernel)
published: true
description: 
---

1 /proc File System
2 Writing to Proc Files
3 Persisting /proc Files Changes
4 Common /proc Entries
5 Listing /proc Directory
6 /proc Useful Examples
7 sysfs Virtual File System
8 tmpfs Virtual File System

https://likegeeks.com/linux-virtual-file-system/

Hope you like it.
Regards,
“Build vs. Buy,” what is your take?
Tags: discuss, devops, tools, softwareengineering
Published: 2018-05-01 05:25:00

---
title: “Build vs. Buy,” what is your take?
published: true
tags: discuss, DevOps, tools, software engineering
---

“Build vs. Buy,” these choices seem to be constant in the lives of many DevOps Architects. End of the day, it all comes down to your business priorities and company vision. 

For many companies, it makes sense to leverage software/tech that other companies have already created since they’ve invested thought, time and resources into making something that’s capable, resilient and performant. Buying tech/tool is almost always cheaper than developing an equivalent tool yourself.
3 gods puzzle solution in Haskell
Published: 2018-03-04 00:00:00

---
title: 3 gods puzzle solution in Haskell
date: 20180304T00:00Z
---

# The Puzzle

Here's the prompt from [Wikipedia][wikipedia]:

> Three gods A, B, and C are called, in no particular order, True, False, and Random. True always speaks truly, False always speaks falsely, but whether Random speaks truly or falsely is a completely random matter. Your task is to determine the identities of A, B, and C by asking three yes-no questions; each question must be put to exactly one god. The gods understand English, but will answer all questions in their own language, in which the words for yes and no are da and ja, in some order. You do not know which word means which.

# My solution

The puzzle can be simplified by eliminating redundancies masquerading as complications:

- It doesn't matter that the gods speak a different language because you can interpret "da" as "yes" by asking the god to negate their response if "da" means "no".
- It doesn't matter that one god lies because you can ask the god to negate their response if they are False.

It's clear that you can't ask each god a question because since one responds randomly, you'll only get 2 bits of information (which is only enough to enumerate 4 outcomes, and there are 6 permutations of gods). Therefore, you have to spend a question to find a non-random god to ask the remaining questions.

```
Ask A: Is B Random?
  Yes -> Ask C: Is A Random?
    Yes -> Ask C: Is C True?
      Yes -> RFT
      No -> RTF
    No -> Ask C: Is C True?
      Yes -> FRT
      No -> TRF
  No -> Ask B: Is A Random?
    Yes -> Ask B: Is B True?
      Yes -> RTF
      No -> RFT
    No -> Ask B: Is B True?
      Yes -> FTR
      No -> TFR
```

This code performs 10 sample runs with a random permutation each time (which only gives probabilistic evidence that it's correct).

{% embed https://gist.github.com/chrismwendt/a48cf10fd90d2092b0760a6df6d75438 %}

[wikipedia]: https://en.wikipedia.org/wiki/The_Hardest_Logic_Puzzle_Ever
My First Post 
Published: 2018-05-01 00:52:49

---
title: My First Post 
published: true
description: First post 
tags: 
---
Hi folks, my name is Ricardo, I'm kinda new to this world. In the last year and a half i'm trying a career change, from Chemical engineer to Frontend developer. First was like a curiosity but then but then became more serious and here am I. 

Thanks for maintaining this website and for sharing your knowdlege.
OpenOffice docs and Python
Tags: python, openoffice, libreoffice
Published: 2018-05-04 13:25:56

---
title: OpenOffice docs and Python
published: true
tags: python,python,openoffice,libreoffice
canonical_url: 
---

# Writing ODT by Python

When creating my little Python utility I realized, that writing data to txt via print (console) will not be enough. To make my [pinmix](https://github.com/lukaszkuczynski/pinmix) little more useful I wanted to create the way of clear presentation of a textual data. The first thought was to create a HTML with contents, using classes and divs. But, I usually use Word-like tools to edit and modify my documents. They have this nice option of posting comments and so on. And overall this is more straightforward way of managing text documents, right? So how to create OpenOffice doc with Python? It is so easy using `odfpy` module.

# Solution

So this is basically how I did that using Python. You are just to import some libraries and voila, happy editing. Having separate styles defined you can then do the batch-updates of all of the similar text parts. It sounds like fast document adaptation, fitting all your needs.
```python
from odf.opendocument import OpenDocumentText
from odf.style import Style, TextProperties
from odf.text import H, P, Span

class DocFactory:

    def __init__(self, filename):
        self.filename = filename
        self.quotStyle = Style(name="Quotations")
        self.marginaliaStyle = Style(name="Marginalia")
        self.doc = OpenDocumentText()

    def add_p1_text(self, txt):
        self.doc.text.addElement(P(text=txt))

    def add_p2_text(self, txt):
        self.doc.text.addElement(P(text=txt, stylename=self.quotStyle))

    def add_p3_text(self, txt):
        self.doc.text.addElement(P(text=txt, stylename=self.marginaliaStyle))

    def save(self):
        self.doc.save(self.filename)
```
# Conclusion

Once again I understood, having Python in your toolset you are always just few lines away from advanced solutions.
Explain Angular 5 like I'm five
Tags: explainlikeimfive, angular
Published: 2018-04-30 23:35:52

---
title: Explain Angular 5 like I'm five
published: true
description: 
tags: #explainlikeimfive #angular
---

Can someone please explain angular like I'm five? I'm coming from react, so its been really confusing! Thanks!
Wait for a Script to Load in Javascript
Tags: javascript, browser, analytics
Published: 2018-04-30 22:59:21

---
title: Wait for a Script to Load in Javascript
published: true
description: Ever needed to wait for a script to load before doing something with it? Here's a quick and easy way to make that happen. Perfect for 3rd party scripts you have no control over like Google Analytics, Segment, Intercom, etc.
tags: javascript, browser, analytics
canonical_url: https://timber.io/snippets/asynchronously-load-a-script-in-the-browser-with-javascript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/rk1muigt7pv39cmek6ky.png
---

Ever needed to wait for a script to load before doing something with it? Here's a quick and easy way to make that happen. Perfect for 3rd party scripts you have no control over like Google Analytics, Segment, Intercom, etc.

All you need is this little class:

```js
export default class ScriptLoader {
  constructor (options) {
    const { src, global, protocol = document.location.protocol } = options
    this.src = src
    this.global = global
    this.protocol = protocol
    this.isLoaded = false
  }

  loadScript () {
    return new Promise((resolve, reject) => {
      // Create script element and set attributes
      const script = document.createElement('script')
      script.type = 'text/javascript'
      script.async = true
      script.src = `${this.protocol}//${this.src}`

      // Append the script to the DOM
      const el = document.getElementsByTagName('script')[0]
      el.parentNode.insertBefore(script, el)

      // Resolve the promise once the script is loaded
      script.addEventListener('load', () => {
        this.isLoaded = true
        resolve(script)
      })

      // Catch any errors while loading the script
      script.addEventListener('error', () => {
        reject(new Error(`${this.src} failed to load.`))
      })
    })
  }

  load () {
    return new Promise(async (resolve, reject) => {
      if (!this.isLoaded) {
        try {
          await this.loadScript()
          resolve(window[this.global])
        } catch (e) {
          reject(e)
        }
      } else {
        resolve(window[this.global])
      }
    })
  }
}
```

### Example Usage

```js
const loader = new Loader({
    src: 'cdn.segment.com/analytics.js',
    global: 'Segment',
})

// scriptToLoad will now be a reference to `window.Segment`
const scriptToLoad = await loader.load()
```
Tech Events this Week - 4/30
Tags: discuss, career, eventsinyourcity
Published: 2018-04-30 20:41:23

---
title: Tech Events this Week - 4/30
published: true
description: Let's crowdsource tech events going on in different areas!
tags: discuss, career, eventsinyourcity
---

Each week for my students, I create a newsletter that lists the tech events going on in DC that I've heard about. I thought it would be really cool to expand that to a bigger community and crowdsource it for other people to contribute.

I am going to put some comments below with different areas, feel free to reply with your events on those comments. If you have an event that isn't in one of those areas, feel free to first write a comment with the area, then another one threaded onto it with your event!

This week, I posted on a Monday, but in the future, I will be posting on Fridays so that people have time to put things on their calendars!
How engineers can stand out from the applicant pool
Tags: career, devtips, discuss
Published: 2018-04-30 19:23:37

---
title: How engineers can stand out from the applicant pool
published: true
description: Technical founders share stories and advice about how software engineers can stand out from the applicant pool.
tags: #career, #devtips, #discuss
---
![standing out](https://thepracticaldev.s3.amazonaws.com/i/k6yokrl36fhsee601m60.jpg)

> ##What have you done in the past, or seen other engineers do, to stand out from the applicant pool?

I asked six technical founders this same question, and thought I'd [share their answers](https://www.keyvalues.com/blog/how-engineers-can-stand-out-from-the-applicant-pool) with the DEV community in case anyone here would find them interesting/useful/helpful. 

If you have your *own* answer to this question, by all means, share it with us!
How do you maintain side projects?
Tags: discuss, sideprojects
Published: 2018-04-30 18:13:24

---
title: How do you maintain side projects?
published: true
description: What strategy do you use to maintain side projects?
tags: #discuss #sideprojects
---

I wrote a [twitter bot](https://twitter.com/bcdevexbot) two years ago. It was a side project to experiment with python. It happily runs along on my raspberry pi.  

However, once in a while it needs my attention. Usually, because the API it calls has changed.  When this happens it takes me awhile to get my environment set back up. My IDE needs an update, the libraries it depends on need updating etc. 

So, how do you maintain your side projects?  Do you schedule a time to update it?  Do you care if the project uses current dependencies?  Do you launch the app into the world and then ignore it? How do you know when your app is broken? I am curious to know what other developers do.
Who moonlights as a software developer?
Tags: discuss
Published: 2018-04-30 17:51:12

---
title: Who moonlights as a software developer?
published: true
description: 
tags: discuss
---

I have moonlighted for many years as a software developer. Somehow, I've had a constant stream of work coming in for the past 5 years without having to do much work to keep these clients.

Do any of you guys moonlight as well?
Be specialized...but also know everything else just in case...
Tags: career, programming
Published: 2018-04-30 17:46:16

---
title: Be specialized...but also know everything else just in case...
published: true
description: Career musings from some guy
tags: career, programming, 
---

No one ever tells you that the things you study in programming school (assuming you go to one) are, more than likely, not going to be the things you work on. And by work on, I don’t just mean at a particular job, I mean your career in general. It’s safe to say that most developers naturally gravitate (or are gravitated) towards an area of specialization. (You also have your wunderkinds who can do everything under the sun, but that’s another discussion) Specialization, in my limited experience, is both a good and bad thing.

First, the bad.

It pigeonholes you and that’s not good when the chips are down and you need something. I’ve definitely had my share of job hunts where the phrase “There are just aren’t any BI jobs right now” has started to make me consider another line of work.
 
And on top of the aforementioned limitation, there’s a strange conception among non-IT folks that results in a paradoxical situation; even though you’re specialized, even though you’ve been encouraged, pushed even, to specialize, you’re still expected to know everything about anything that ever flipped a bit.

Network routing? That’s you right?
 
Server architecture? That’s you guys right? 

Hey I have an application that someone’s eighth grader wrote for me in Excel and I installed it and it fried my machine and now I need all my files for a meeting with the CEO five minutes ago. You’re in charge of that right?

You get the point.

And now for the good: if you can get past the pigeonholes, paradoxes, and primitives (data types, of course), stuff starts to get good.You start to see your contribution even when others don’t.You start to turn red X’s into green checkmarks and get to wear the hero badge for the day (or week depending on how big the X was). You start to really hone your craft and begin to understand things that seemed incomprehensible before.
 
And that, for me, is one of the most empowering feelings in the world. Being able to look at the tasks you have completed, see their value and therefore your own, and start to really asses what you are capable of. Start to really understand what you as an individual can accomplish.

It’s probably a lot more than you think. I know it was for me.
My first step in learning Generative Art
Tags: beginners, art, graffiti, showdev
Published: 2018-04-30 17:26:02

---
title: My first step in learning Generative Art
published: true
description: I started learning Generative Art today and founｄ it fascinating.
tags: beginners,art,graffiti,showdev
---

Even though I'm absolutely a newbie of generative art (I started it just today!), I found it quite fascinating. So I'm telling my passion here.

## What's Generative Art?

Let's see the quotation from Wikipedia.

> Generative art refers to art that in whole or in part has been created with the use of an autonomous system. 
>
> "Generative art" is often used to refer to algorithmic art (computer generated artwork that is algorithmically determined). 
> https://en.wikipedia.org/wiki/Generative_art

When I know generative art, I felt that it could be a chance to sophisticate my poor aesthetic sense with my programming skill.

If you'd like to try it right now, there's an interactive online editor. Visit https://alpha.editor.p5js.org/, then copy & paste my code into the editor on the page and see what will be happening.

---

## Artworks

It's embarrassing to call them "artworks"... But let me introduce them to tell what I have experienced.

### "Interfering objects"

This is my first generative art. Doesn't it smell mathematics?

![image](https://user-images.githubusercontent.com/1811616/39439337-37e7728c-4ce2-11e8-88aa-fd29456b2343.png)

Although there might be some unfamiliar functions, what creates the picture is familiar JavaScript code, which uses [p5.js](https://p5js.org/). 

```javascript
function setup() {
  createCanvas(400, 400);
  background(80)
  noStroke();
  frameRate(6);
}

function draw() {
  for (var i = 0; i < 400; i++) {
    var r = random(0,200);
    stroke(r * 1);
    line(0, i, r, r);
    line(400, i, 50 + r, 100+r);
  }	
}
```

### "Light path in the dark"


![light](https://user-images.githubusercontent.com/1811616/39439343-3c6cdf5e-4ce2-11e8-9196-1b0df5dbf894.gif)

```javascript
function setup() {
  createCanvas(720, 400);
  background(80)
  noStroke();
}

function draw() {
  fill(color(random(20),random(200),random(200), 1));	
  bezier(random(500, 550), random(500, 550), 0, 0, 40, 40, 50, 90);
  bezier(random(100, 200), random(100, 350), 0, 0, 40, 40, 50, 90);
}
```

---

Okay, I know my artworks above are not amazing stuff. But I'll keep training and keep publishing so that I become a person who is good at generative art.

Besides, I'm happy if dev.to would get more artists with programming background!
Capture error and data in async-await without try-catch
Tags: javascript, webdev, backend, frontend
Published: 2018-04-30 14:21:09

---
title: Capture error and data in async-await without try-catch
published: true
description: 
tags: javascript,webdev,backend,frontend
---

One of the things that took the Javascript community by storm was the introduction of async-await. It was simple and looked a lot better than the then-catch of Promises and also more readable and debuggable than the callback hell. But one thing that bothered me was the usage of try-catch. At first I thought it isn't a problem but as fate would have it I was working on chained API calls and the problem cropped up where each API call has specific error message that had to be printed. I realized soon that I was creating a try-catch hell.

Let's consider this Promise that resolves or rejects after 2 seconds based on a parameter `rejectPromise`

```js
// api.js

const fetchData = async (duration, rejectPromise) => (
  new Promise((resolve, reject) => {
    setTimeout(() => {
      if (rejectPromise) {
        reject({
          error: 'Error Encountered',
          status: 'error'
        })
      }
      resolve({
        version: 1,
        hello: 'world',
      });
    }, duration);
  })
);

module.exports = {
  fetchData,
};
```

So my typical usage of async-await is gonna be like this.
```js
const { fetchData } = require('./api');

const callApi = async () => {
  try {
    const value = await fetchData(2000, false);
    console.info(value);
  } catch (error) {
    console.error(error);
  }
}

callApi();

/* 
 OUTPUT: 
 { version: 1, hello: 'world' } (rejectPromise=false)

 { error: 'Error Encountered', status: 'error' } (rejectPromise=true)

 */
```

As you can see when the `rejectPromise` parameter is `false` the await resolves to `{ version: 1, hello: 'world' }` and when it's `true` it rejects the promise and catch is called and the error is `{ error: 'Error Encountered', status: 'error' }`.

That's the typical implementation of async-await. Now we will leverage the promise functions then-catch to make the process simpler. Let's write a wrapper that does this.

```js
// wrapper.js

const wrapper = promise => (
  promise
    .then(data => ({ data, error: null }))
    .catch(error => ({ error, data: null }))
);

module.exports = wrapper;
```

We can see that the wrapper takes a promise as an input and returns the resolved/rejected values through then-catch. So let's go and modify the original code we wrote in try-catch to utilize the wrapper.

```js
const { fetchData } = require('./api');
const wrapper = require('./wrapper');

const callApi = async () => {
  const { error, data } = await wrapper(fetchData(2000, false));
  if (!error) {
    console.info(data);
    return;
  }
  console.error(error);
}

callApi();

/* 
 OUTPUT: 
 { version: 1, hello: 'world' } (rejectPromise=false)

 { error: 'Error Encountered', status: 'error' } (rejectPromise=true)

 */
```

Voila the same output but the this way makes it better to understand the code.
Eslint trivial pitfall.
Tags: todayilearned, javascript, eslint
Published: 2018-02-12 15:55:05

---
title: Eslint trivial pitfall.
published: true
description: This is my first article as a TIL.
tags: TIL, Javascript, Eslint
---

Hi! I'm hiro and I'm front-end developer but I'm really into server-side development by using Node.js recently by the way.  
So, This is my first article. I'm gonna keep posting artile as a daily TIL to Dev.to regularly.
I don't know if it might be difficult though, it's good challenge for me to keep on posting it.

it's time to finish self-introduction! Let's get started today's topic!

## Eslint trivial pithall.
I'm working two job, one is main job by using React.js partially (but It's not small range of area, it's getting expanded day by day). second is [Togetter](https://togetter.com/) and using ReactNative. Common thing is using React ecosystem and modern environment.  
Eslint is standard of linting library, isn't it? but I didn't even realize trivial pitfall.

When you specify your eslint, you might write this code to `package.json` inside of `npm scripts`.
```
"scripts": {
  "lint": "eslint src/js/* ",
}
```

I think this is correct. but what if you wanna dig deeper into making your directory hierarchy like below?

```
src/  
  js/  
    components/
      SomeComponents/
        index.jsx
        style.js
    index.js
```

First of all, you might write below code.

```
"scripts": {
  "lint": "eslint src/js/**/*.jsx src/js/**/*.js ",
}
```

This doesn't work well. but if you write `eslint src/js/**/**/*.jsx src/js/**/**/*.js`, it will work but if you dig deeper into making directory, you need to add more path location or add wild card like `/**/`.
And additionally, when you specify `eslint src/js/*`, it will be checked only `*.js` file. what if you wanna check even more `*.jsx` ?

Super Easy Solution.
you just need to add like below.

```
"scripts": {
  "lint": "eslint src/js/* --ext .js --ext .jsx ",
}
```

This will work as you expected! I've been fitted into a pitfall like this problem. I did't just realize eslint configuration though, but It's kind of tricky pithall.

Have a good your programming day!
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2018-04-30 15:52:39

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---

#1. _You. Are. Speed._

You can prevent VS Code from getting sluggish by removing all your extensions. But what if you want to have your cake and eat it to? Enable them _just in your workspace._

{% link https://dev.to/rpalo/keep-vs-code-from-becoming-an-ide-570l %}

#2. Communication 101

A communication guide useful for both developers and non-developers -- lots of useful dialogue examples to help clear up some of the most common misunderstandings, miscommunications, and missed opportunities.

{% link https://dev.to/kttravers/how-to-work-with-developers---a-guide-for-non-developers-35hk %}

#3. Ever get a PR for your resume?

If you upload it to GitHub (or any other repo service), you could! This post shares a few reasons why you might want to consider a git based resume.

{% link https://dev.to/acro5piano/5-reasons-why-git-based-resume-is-awesome-127 %}

#4. Junior Role: at least one year of experience

An issue many juniors face during their job search is not having enough experience. The community shares their advice!

{% link https://dev.to/tiffanywismer/how-do-i-get-experience-when-i-have-no-experience-2dp8 %}

#5. Gmail Enhancements

A breakdown of all the new gmail features -- nudges, high priority notifications, smart replies, and more!

{% link https://dev.to/mrahmadawais/new-gmail-is-pretty-dope-devthoughts-387e %}

#6. Dreadful Anti-patterns

In an effort to increase product development velocity, Niko started learning about continuous integration and discovered that many of their existing methods were anti-patterns. 

{% link https://dev.to/nikoheikkila/the-impractical-continuous-delivery-4gel %}

#7. Trials and Tribulations

Initially discouraged, Tamir tries Rust for a second time, by way of Rust tools, and has completely embraced the language. 

{% link https://dev.to/tmr232/adventures-in-rust-56fc %}


_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_