teleren/devto huggingface dataset:
What does your operating system say about you? Spoiler - probably nothing
Tags: linux, os, operatingsystem, jokes
Published: 2020-08-19 19:28:42

On my first day in my first job I made a joke that didn't go down well with the CEO. Way less terrifying than it sounds!

We were setting up our desks. Desks of our own, not hot desk, which sounds like a tall story from a dusty hard drive at this point to be honest. But yes, actual, we were setting up actual desktop computers, and installing Ubuntu.

The CEO must have tried to joke about how Apple machinery was far better. I , of course, though this was the perfect time to jump in with a laboured analogy!

Each operating system is a guide through vast, unexplored forests. What would each of them be like?

Linux, first of our tour leaders, is of course as multifaceted as the swiss army knife it is packing. In general though, most Linux flavours give you a torch, a machete and a hasty "best of luck" before pushing you out of a helicopter. Ubuntu, often the "entry" flavour, is helpful, occasionally. Through official signage of course, but chiefly through a vast network of previous tourists. They leave behind tips and even whole guide books at times. Sure, they might be short! Or straight up unintelligible to people who aren't used to intense hiking! At least they exist.

Windows has gone for a much more tourist friendly approach. There are paths galore, helpful signage, and plenty of people milling around on these paths to help you on your way. What it lacks is reminders that this is, in fact, still new terrain. There's little acknowledgement that forests can still be dangerous places if you step off the path. If you choose to do so, there will be few people to guide you.

MacOS, for the joke's sake, of course came last. I called it akin to bulldozing the entire forest for the sake of a strip mall and beautiful angles. Sure, you can go off the path, but where's the thrill when it's more of the same boring tarmac?

Surprise surprise, didn't go down well.

It cuts to the heart of the heart of the way many people see computers. It is a little understanding of the appeal of each approach. It also belies a lot of elitism. Elitism I clung to as a early coder, coding on a beat up X220 thinkpad. It must've cost less than the software on the fancy Macbook Pros everyone else seemed to have.

Gatekeeping in tech is a real problem, and I hope I don't end up replicating crappy systems whilst attempting to tear them down. Today I upgraded my laptop from 18.04 to 20.04 of Ubuntu, which was a mild struggle, but also a triumph.

Progress!

We shouldn't lionise struggling for tech's own sake over a smooth user experience. We shouldn't vilify ease and simple set up, and make it seem as though struggle is the only way to get into technology.
Let's build for Ruby and Rails developers - Part 6
Tags: rails, ruby, tutorial
Published: 2020-08-26 14:55:21

---
title: Let's build for Ruby and Rails developers - Part 6
published: true
date: 2020-08-19 19:23:00 UTC
tags: rails, ruby, tutorial
canonical_url: https://web-crunch.com/posts/lets-build-for-ruby-and-rails-developers-part-6
---

#### An Initial pass at the job form UI

Welcome to part 6 of my Let's build for Ruby and Rails developers series. This part will focus on getting started with the user interface component of the app.

{% youtube lD6HVdS_dYU %}

### Design

As a designer at heart, I take pride in getting busy with design earlier. Doing this helps me imagine how data could display and if anything is missing. Your mileage may vary with this approach and that's okay.

I ended up creating a logo that I think we'll roll with for now. Of course, it's red like most Ruby and Rails fans expect.

Here's a quick take on a basic logo + wordmark

![rails-devs logo and wordmark](https://web-crunch.s3.us-east-2.amazonaws.com/blog/logo.jpg)

We'll use this look and feel to establish part of the job form UI in this part of the series and continue on as we progress. Thanks to Tailwind this process is pretty fast but can result in a bit of back and forth before finding a sweet spot. It's probably not the most exciting content to watch but as I stated in my initial part one that this series will be a little more open-ended.

### Coming up next

In the next part, I think I'll be continuing to get the UI in a decent state before we start tackling the new job form which will be made with Vue.js. I hope you'll stay tuned. There is so much to come.

#### The series so far

- [Part 1](https://dev.to/justalever/let-s-build-for-ruby-and-rails-developers-2g1)
- [Part 2](https://dev.to/justalever/let-s-build-for-ruby-and-rails-developers-part-2-3310)
- [Part 3](https://web-crunch.com/admin/posts/lets-build-for-ruby-and-rails-developers-part-3/)
- [Part 4](https://web-crunch.com/admin/posts/lets-build-for-ruby-and-rails-developers-part-4/)
- [Part 5](https://web-crunch.com/admin/posts/lets-build-for-ruby-and-rails-developers-part-5/)
- Part 6 (You are here)
Do you know how a CPU works?
Published: 2020-08-19 19:22:48

I know a lot about how computer chips are made and electronics. I lived with a person obsessed and I personally adore Richard Feynman.

Hardware is a bit too... shocking for me but I love to program things. My goal for next year is to learn C++, robotics, and advanced computer graphics. I think that should have been what my first year of my CS studies was dedicated towards but too late now.

Halfway through that first year was CS 102 or whatever (when you learn Big O). I knew I was one of the only math lovers in the class because the other women didn't like it. Except one woman and I matched up with her to do a pair programming assignment. She did it all in about ten minutes before my eyes, on her super giant laptop. Dazzling. Now, turn it in for us and explain to me what the hell you did. She also dropped out for dumb reasons, by the way. What is a good reason, though, if you are a whiz. People perhaps can't be bribed over prioritizing personal relationships. Big Same.

I was feeling a little dense by that point in the studies because the first part was doing horrible "if" statements and the second part was re-making basic libraries in Java. Then, one day, the teacher came up on the topic of CPU architecture. Me, a fanatic of Leo Laporte and friends, nodded along. But then I looked up from my laptop, at the instructor, and realized lots of people in their second semester of computer science could do the syllabus assignments better than me while they didn't even understand the physics of computing systems.

Now I am working on a demo portfolio but I have faith in myself that no matter what a mess it is, it will not run so hot your hands burn and your battery dies. Or the API costs aren't accidentally driven up into the hundreds of thousands of dollars by my own bot.
Welcome Thread - v87
Tags: welcome
Published: 2020-08-19 19:07:36

---
title: Welcome Thread - v87
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
---

![taco hello](https://media.giphy.com/media/l2JHZ0dIcyFo5UQGQ/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Middleware: Verify token.
Tags: 100daysofcode, javascript
Published: 2020-08-19 19:01:46

Today was all about separation of concerns. I had to refactor the get users function to simply get users and not verify any tokens. Hence i created middleware that would handle token verification on a request made to get users. 
I moved the middleware code to auth.js. 
*Code in auth.js*
```javascript
const verifyToken = (req, res, next) => {
  let token = req.headers['x-access-token']

  if(!token){
    return res.status(401).send('no token provided')
  }
  jwt.verify(token, secret, (err, userData) => {
    if(err) {
      return res.status(403).send('Failed to authenticate token.')
    }
    if(userData){
      return next()
    }
    return res.sendStatus(500)
  })
}

module.exports = {
  verifyToken
}
```
I passed the middleware to the route handler.
```javascript
router.route('/users')
  .get(auth.verifyToken, userController.getUsers);
```
And called it a day!

_ Day 34._
Daily Challenge #283 - Simple Missing Sum
Tags: challenge
Published: 2020-08-19 18:48:10

---
title: Daily Challenge #283 - Simple Missing Sum
published: true
series: Daily Challenge
description: Calculate the smallest number that is not possible from an array of positive integers.
tags: challenge
//cover_image: https://direct_url_to_image.jpg
---
In this challenge, we will calculate the minimum number that is not a possible sum from a list of positive integers.

###Examples
`solve([1,2,8,7])` = 4 
we can get 1, 2, 3 (from 1+2), but we cannot get 4. 4 is the smallest number not retrievable from the list. 

`solve([4,1,2,3,12])` = 11
We can get 1, 2, 3, 4, 4+1=5, 4+2=6, 4+3=7, 4+3+1=8, 4+3+2=9, 4+3+2+1=10. But we can't get to 11. 

`solve([2,3,2,3,4,2,12,3])` = 1. We cannot get 1.


###Tests
`solve([4,2,8,3,1])`
`solve([4,2,7,3,1])`
`solve([1,2,8,7])`
`solve([4,2,12,3])`

Good luck!

***
_This [challenge](https://www.codewars.com/kata/5a941f3a4a6b34edf900006f) comes from KenKamau on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
How to keep your Intro short, unique, and creative at the same time
Tags: github, showdev, beginners, webdev
Published: 2020-08-19 18:35:47

:point_right: http://github.com/calvinqc

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

-----

Feel free to share yours in the comment!
Day 1 of 100DaysOfCode
Tags: 100daysofcode, javascript, github, freecodecamp
Published: 2020-08-19 18:34:26

Hey! Today I decided to start the 100DaysOfCode challenge. My target for today was to familiarize myself more with GitHub. Also, I wanted to do some JavaScript tasks on FreeCodeCamp. 

I'm going to share daily updates on my dev.to site and also on Twitter. I believe the best way to learn is by teaching. So, when I get a little bit more familiar with coding I'll also write guides for others. 

## What I did today:

### 1. Hello World guide of GitHub
https://guides.github.com/activities/hello-world/
####What I learned from it:
* Created an open-source repository
* Started and managed a new branch
* Changed a file and committed those changes to GitHub
* Opened and merged a Pull Request

### 2. GitHub Learning Lab
https://lab.github.com/githubtraining/introduction-to-github
####What I learned from it:
* Learned about issues, pull requests, and what a repository is
* Learned about branching and creating commits
* Viewed and responded to pull request reviews
* Enabled GitHub Pages

### 3. FreeCodeCamp basic JavaScript
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/
####What I learned from it:
* What are switch statements and where to use them
* Using functions in JavaScript

 

#### Time spent learning:
Task 'Learning GitHub'. Elapsed time: 41 min 26 s
Task 'Learning GitHub'. Elapsed time: 17 min 28 s
Task 'JavaScript on FCC'. Elapsed time: 20 min 50 s

#### Total Time: 1h 19min 44s
Tracked by using my [TaskTimer](https://www.arttupyykonen.com/tasktimer/) script. 

 

## Where you can learn too

If you want to learn more about Git check out these resources:
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
https://www.theodinproject.com/courses/web-development-101/lessons/introduction-to-git

For GitHub check out the guides linked above. 

And for JavaScript use these resources:
https://eloquentjavascript.net/
https://www.freecodecamp.org/learn/

Hope you enjoyed this post, and see you all tomorrow!
TypeError: storage._handleFile is not a function
Tags: node, javascript, react
Published: 2020-08-19 18:27:56

require('dotenv')
const multer = require('multer')
const sftpMulter = require('multer-sftp')
const ftpMulter = require('multer-ftp')
const path = require('path')
const crypto = require('crypto')

const storageTypes = {
    localStorage: multer.diskStorage({
        destination: (request, file, cb)=>{           
            cb(null, path.resolve(__dirname, '..', '/uploads'))
        },
        filename: (request, file, cb)=>{            
            crypto.randomBytes(4, (err, hash)=>{
            if(err) {
                cb(err, 'tente novamente')
            }
            const nomeEmpresa = request.body.empresa.slice(0, 5).normalize('NFD')
            .replace(/:|,|;|`|´|\?|%|\+|\=|\^|~|\[|\]|\||{|}|@|!|\$|&|\*|#|\s|[\u0300-\u036f]/gi, "")
            
            const arquivoOriginalNome  = file.originalname.slice(file.originalname.length - 5, file.originalname.length).normalize('NFD')
            .replace(/:|,|;|`|´|\?|%|\+|\=|\^|~|\[|\]|\||{|}|@|!|\$|&|\*|#|\s|[\u0300-\u036f]/gi, "")
            
            const fileName = `${nomeEmpresa}_${hash.toString('HEX')}_${arquivoOriginalNome}`
            cb(null, fileName)
            })
        },
    }),
 
    ftpStorage: multer({ storage: sftpMulter({
        sftp: {
            host: process.env.REACT_APP_BASE_HOST_FTP,
            secure: false,
            port: process.env.REACT_APP_BASE_PORT_FTP,
            user: process.env.REACT_APP_BASE_USER_FTP,
            pass: process.env.REACT_APP_BASE_PWD_FTP,  
            debugMode: true
        },
        destination: (request, file, cb)=> {
            console.log(file, request.body)
          cb(null, '/fastdating')
        },
        filename: (request, file, cb)=> {
            crypto.randomBytes(4, (err, hash)=>{
                if(err) {
                    Console.error(err)
                    cb(err, 'tente novamente')
                }
                const nomeEmpresa = request.body.empresa.slice(0, 5).normalize('NFD')
                .replace(/:|,|;|`|´|\?|%|\+|\=|\^|~|\[|\]|\||{|}|@|!|\$|&|\*|#|\s|[\u0300-\u036f]/gi, "")
                
                const arquivoOriginalNome  = file.originalname.slice(file.originalname.length - 5,       file.originalname.length).normalize('NFD')
                .replace(/:|,|;|`|´|\?|%|\+|\=|\^|~|\[|\]|\||{|}|@|!|\$|&|\*|#|\s|[\u0300-\u036f]/gi, "")
                
                const fileName = `${nomeEmpresa}_${hash.toString('HEX')}_${arquivoOriginalNome}`
                cb(null, fileName)
            })
        }
        }) 
    })
} 
 
module.exports = {
    /* saida: (request)=>console.log('entrando...', request), */
    storage: storageTypes.ftpStorage,
    limits: {
        fileSize: 4 * 1024 * 1024,
    },
    fileFilter: (request, file, cb) => {
        const allowedMimes = [ 'application/pdf' ]
        if (allowedMimes.includes(file.mimetype.toLowerCase())) {
            cb(null, true)
        }
        if (!(allowedMimes.includes(file.mimetype.toLowerCase()))) {
            cb(new Error('Só pdf '))
        }else{
           new Error()
        }
    },
 
}
Setup Mocha 8, Chai 4 and Babel 7 for JavaScript TDD
Tags: tdd, javascript, babel, mocha
Published: 2020-08-19 18:18:03

Let's see how to setup Mocha 8, Chai 4 and Babel 7 to test a ES6 string problem.

> Given some strings of different lengths, if the number of vowels are more than 30% of the string length then insert 'summer' for each continuous set (group) of vowels.

Examples:

```
'' => ''
'a' => 'summer'
'ntv' => 'ntv'
'bla' => 'blsummer'
'blah' => 'blah'
'blaahah' => 'blsummerhsummerh'
'hear' => 'hsummerr'
'blAhE' => 'blsummerhsummer'
```

### Solution:

#### index.js

```javascript
const newStr = 'summer';
const regx = /[aeiou]+/ig;
// const regx = /(a|e|i|o|u)+/ig;
// const vowels = 'aeiou';

// const isVowel = (c) => vowels.indexOf(c.toLowerCase()) > -1;

const vowelCount = (word) => {
    // const vCount = [...word].reduce((count, letter) => count + (isVowel(letter)? 1:0), 0);
    // const re = /(a|e|i|o|u){1}/ig;
    const re = /[a|e|i|o|u]{1}/ig;
    return word.match(regx) ? word.match(re).length / word.length > 0.3 : false
};

const replaceVowels = (word) => word.replace(regx, newStr);

const changeStr = (word) => vowelCount(word) ? replaceVowels(word) : word;

export default changeStr;
```
#### test\index.spec.js

```javascript
import { expect } from 'chai';
import changeStr from '../index';

describe('#changeStr', () => {
  it('should not change empty string', () => {
    expect(changeStr('')).to.equal('');
  });

  it('should not change words with no vowels', () => {
    expect(changeStr('ntv')).to.equal('ntv');
  });

  it('should change a vowel', () => {
    expect(changeStr('a')).to.equal('summer');
  });

  it('should change consonents and a vowel', () => {
    expect(changeStr('bla')).to.equal('blsummer');
  });

  it('should not change less than 30 percent vowels', () => {
    expect(changeStr('blah')).to.equal('blah');
  });

  it('should change continuous vowels once', () => {
    expect(changeStr('hear')).to.equal('hsummerr');
  });

  it('should change multiple sets of vowels', () => {
    expect(changeStr('blaahah')).to.equal('blsummerhsummerh');
  });

  it('should change capital vowels', () => {
    expect(changeStr('blAhE')).to.equal('blsummerhsummer');
  });

  it('should error on undefined input', () => {
    expect(() => changeStr()).to.throw();
  });
});
```

#### .babelrc
```
{
    "presets": ["@babel/preset-env"]
}
```

#### .mocharc.yml
```
require: '@babel/register'
```

#### .package.json
```
{
  "name": "tdd",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "license": "MIT",
  "devDependencies": {
    "@babel/cli": "^7.10.5",
    "@babel/core": "^7.11.1",
    "@babel/preset-env": "^7.11.0",
    "@babel/register": "^7.10.5",
    "chai": "^4.2.0",
    "mocha": "^8.1.1"
  }
}
```
Replacing placeholders in Ruby on Rails
Tags: rails, seo, regex, metaprogramming
Published: 2020-08-19 18:10:10

---
title: Replacing placeholders in Ruby on Rails
published: true
description: Using ruby metaprogramming to replace placeholders
tags: rails, seo, regex, metaprogramming
//cover_image: https://direct_url_to_image.jpg
---

Many times we need to include dynamic data in our text. There are many ways to do this, just by having `gsub` method.

I'd like to share my favorite approach for placeholders replacing.

Let's assume we have `Article` class and we want it to generate a dynamic title that can be used for the SEO purpose.

The "Article" has `name:string` and `reviews_count:integer` attributes.
We need to generate a dynamic title: `[name] - [reviews_count] reviews`. The title pattern can be customized in our back-office.

`article.title_patern = '[name] - [reviews_count] reviews'`

Let's use the Ruby on Rails metaprogramming techniques to implement this functionality:

```ruby
class Article < ApplicationRecord
  def title
    title_pattern.gsub(/\[(.*?)\]/) { |key| dynamic_value(key) }.strip
  end

  private

  DYNAMIC_CMDS = %w[
    name
    reviews_count
  ].freeze

  def dynamic_value(key)
    cmd = key[/\[(.*?)\]/, 1]
    DYNAMIC_CMDS.include?(cmd) ? send(cmd) : ''
  end
end
```

Now, we can do:

```ruby
article = Article.new(name: 'Amazing Ruby', reviews_count: 123)
article.title # "Amazing Ruby - 123 reviews"
```

Let's review the code together.

```ruby
def title
  title_pattern.gsub(/\[(.*?)\]/) { |key| dynamic_value(key) }
end
```
We are using `gsub` with a block pattern that helps us to use logic to decide how to replace something. We are searching for any words in square brackets `[ANYTHING]`. Of course, you can define your own pattern, for example: `{{NAME}}` or `%NAME%`. Just change the Regex accordingly.

In our case, the `title_patern` is `[name] - [reviews_count] reviews`. So the `gsub` will search for each key in brackets. We have two keys: 
1. `[name]`
2. `[reviews_count]`

for each key, will call `dynamic_value` method.

I'm using ruby [send](https://apidock.com/ruby/v2_6_3/Object/send). There are various options dynamically call the method or attribute in ruby. But `send` method has the best [performance](https://frontdeveloper.pl/2015/05/dynamic-class-method-calling-ruby/).

__Note__: dynamic methods can be dangerous. Especially, `send` can invoke private methods. This is the reason, `DYNAMIC_CMDS` check is required to keep your code safe.
My lockdown in review 
Tags: life, watercooler
Published: 2020-08-19 18:04:32


* Started working from home;
* Furloughed;
* Learnt new programming skills;
* Programmed most days;
* Was made redundant and found a new job. 

> **That pretty much sums up my whole lockdown.** 

When I was initially furloughed, which was pretty much at the start of lockdown, I was utterly disappointed, mortified and just generally felt awful. From speaking with friends who have been in similar situations, I feel as though not all companies understand how the process makes you feel. You feel as though it is a reflection on you as a developer and a person and that no amount or lack of reassurance from a company will dissipate that.

After this, I went into the mindset that I was going to code every day, to use this unprecedented time to develop my knowledge and skills so I was a somewhat stronger developer when I returned to work. I can say for the most part, that I kept to this mindset. I can't say that every day I programmed from dusk until dawn, but I put in between 25-40 hours a week into my development.

This blog post (if you can call it that - it's my first ever attempt at writing one, so please forgive the poorly formatted document) isn't going to go into all of the technical aspects, more of a birds-eye overview. 

I had a feeling from the outset that I wasn't going to be going back to previous work, but even if I was or wasn't I owed it to myself to develop my skillset. I had a list of technologies that I wanted to develop my understanding of. Truth be told, I didn't get through half of them, although I did manage to expand my knowledge in ASP.NET Web API, .Net Identity, JavaScript, TypeScript, React, React Hooks, Vue, PostGres, Jest, MobX and MediatR. I've completed some great courses and read some fantastic books along the way. In fact, my new website tomfletcher.tech is built on most of that stack (no judgement, I'm still working on the design). I've used a combination of resources, from Udemy, TeamTreehouse, YT to blogs and books - side note - Digital Ocean is a fantastic learning resource. 

The inevitable happened and I was unfortunately made redundant. As a result of using my time productively, I managed to find a new job relatively quickly at a company who is very development orientated and is the epitome of a great working environment.

I suppose this post is trying to highlight, whenever you have the opportunity to **invest in yourself**, do it.
Google Ads Sertifika
Tags: googlecloud
Published: 2020-08-19 18:01:41

Google Ads Sertifikası sahibi olmak istiyorsanız https://sertifikasoruvecevaplari.com sitesine göz atabilirsiniz.

Tüm google ads sertifikalarının soru ve cevaplarını bulabilirsiniz. 
https://sertifikasoruvecevaplari.com/google-ads-arama-agi-sertifikasi-sinav-soru-ve-cevaplari-2020-guncel