teleren/devto huggingface dataset:
What problems did active_support concerns solve?
Tags: ruby, rails
Published: 2020-07-02 15:15:00

---
title: What problems did active_support concerns solve?
published: true
description: 
tags: Ruby, Rails
---
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/65670e41o57mxgrj2zq0.jpg)

In the Rails project some of the most commonly used methods are extracted and generally placed in the corresponding concerns directory. generally different concern files are stored in these directories. a file is a module for example:

```ruby
module UserPlan
  extend ActiveSupport::Concern
  included do 
    belongs_to :plan
  end
  class_method do 
    def	cached_all_plan 
      #bala bala
    end
  end
end
```

Note that the module `extend ActiveSupport::Concern` is used in this module. we will explore its benefits and why this module exists.

Let's start with the following example:

```ruby
module Foo
  def self.included(base)
    base.class_eval do
      def self.method1
        ...
      end
    end
  end
end

module Bar
  def self.included(base)
    base.method1
  end
end

class Host
  include Foo # The Foo module was introduced because the Bar module depends on it
  include Bar # Bar reference is to call its method1 method
end
```

If you want to use the `method1` method in the `Host` class, you must refer to the `Bar` module but the `Bar` module depends on the `Foo` module. 

Did you find any problems? the `Host` class does not care about the `Foo` module but in order to call the `method1` method when the `Bar` is included. you have to Introduce the `Foo` module.

There is an improved code along the above logic:

```ruby
module Bar
  include Foo
  def self.included(base)
    base.method1
  end
end
class Host
  include Bar
end
```

The `Host` only cares about the reference of `Bar` so the `Foo` module is put in the `Bar`. It seems that there is no problem but when you implement the running code, you will find that the code cannot run. 

In the included hook method of the `Bar` module the base object points to the `Host` and the include `Foo` in `Bar` will put `method1` on the instance object of `Bar`. when the instance object of the Host calls `method1`, it will throw a method not found exception

How to do it?

```ruby	
require 'active_support/concern'
module Foo
  extend ActiveSupport::Concern
  included do
    def self.method1
      ...
    end
  end
end

module Bar
  extend ActiveSupport::Concern
  include Foo

  included do
    self.method1
  end
end

class Host
  include Bar 
end
```

By referring to `ActiveSupport::Concern` to solve the problem of interdependence between modules and modules.

The comparison found that the code is much simpler and the call is also very convenient. the readability of the code has also become very good and very clear. now `ActiveSupport::Concern` is quite widely used and many good gems will be used. after all It was put in the **ActiveSupport** Gem.



Hope it can help you :)
Day 5: Loops
Tags: python
Published: 2020-07-02 21:45:09

### Salutations! 

Welcome to another day of exploration and my endeavours with the 30 days of code challenge, Day 5. **Loops** are the centre of todays attention. 

**Loops** are a fundamental part of coding, which feature in almost all programming languages, so understanding them is paramount. 

Python contains two different types of loops, the **for** loops and the **while** loop. **For** loops can iterate over a sequence of numbers using the range function. **While** loops repeat as long as a certain boolean condition is met.

Todays challenge involved using a loop to iterate over a variable 10 times and multiply it by the iteration number. i decided to do this in both styles of loop.

Here is my code for the **for** loop:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wikxywwmil8myp7tsx79.png)
And here is the output:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vm0ilwvu8h8fv7sppg9p.png)

Here is my code for the **while** loop:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xsp7wh26gefxhj4nx01d.png)
and here is the output:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5nydr3kear4fxudl7tw1.png)
MaixDuino 上使用 MaixPy 讀取類比輸入
Tags: maixduino, maixpy, micropython, adc
Published: 2020-07-03 09:33:22

MaixDuino 是透過 ESP32 讀取 ADC, 可參考官方的[範例檔](https://github.com/sipeed/MaixPy_scripts/blob/master/network/demo_esp32_read_adc.py)。不過目前測試似乎有問題, 都會得到以下錯誤：

```
[MaixPy]: esp32 read adc failed!
```

根據[論壇的說明](https://github.com/sipeed/MaixPy/issues/148), 這似乎是 ESP32 上的韌體有問題, 以後再測試看看。

如果使用[特定版本的 MaixPy 及 ESP32 韌體](https://github.com/sipeed/MaixPy/files/3514633/fixed_adc_fw.tar.gz), 就可正常運作。請使用 kflash 工具燒錄下載後解開的 mainxpy.bin:

![](https://i.imgur.com/SdC7axj.png)

接著再使用 flash_download_tools 將下載解開的 NINA_W102-1.3.1.bin 燒錄到 MaixDuino 上的 ESP32：

![](https://i.imgur.com/ugDAFjl.png)

請記得 ESP32 是另一個序列埠。完成後, 就可以使用以下程式測試 ADC (MaixDuino 上的 K210 晶片和 ESP32 之間使用 SPI 傳輸資料, 相關接腳可參考電路圖)：

```python
import network
import utime
from Maix import GPIO
from fpioa_manager import *

#iomap at MaixDuino
fm.register(25,fm.fpioa.GPIOHS10)#cs
fm.register(8,fm.fpioa.GPIOHS11)#rst
fm.register(9,fm.fpioa.GPIOHS12)#rdy
fm.register(28,fm.fpioa.GPIOHS13)#mosi
fm.register(26,fm.fpioa.GPIOHS14)#miso
fm.register(27,fm.fpioa.GPIOHS15)#sclk

nic = network.ESP32_SPI(cs=fm.fpioa.GPIOHS10,rst=fm.fpioa.GPIOHS11,rdy=fm.fpioa.GPIOHS12,
mosi=fm.fpioa.GPIOHS13,miso=fm.fpioa.GPIOHS14,sclk=fm.fpioa.GPIOHS15)

adc = nic.adc()
print(adc)
```

adc() 會以 tuple 形式傳回 6 個 ADC 接腳的值：

```python
>>> %Run -c $EDITOR_CONTENT
ESP32_SPI init over
(839, 1169, 192, 16, 0, 0)
```
[React] Improve your portfolio for FAANG
Published: 2020-07-03 16:47:07

If anyone is interested in improving their portfolio and standing out to FAANG (and other large companies), we could use some new members in our open-source React, GitHub organization!

Email me your GitHub ID (or post here) and I'll send you an invite.

Docs:
https://default.services

GitHub:
https://github.com/default-services

Email:
support@default.services
I Created a Responsive Portfolio Website Using HTML, CSS, Bootstrap, and JavaScript
Tags: html, css, webdev, javascript
Published: 2020-07-03 22:30:43

I already had a portfolio but it was created by others. But now have created my portfolio from scratch using HTML, CSS, Bootstrap, and JavaScript.
   

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

Tell me, what amazes you? What should I change?

Here is the link to the portfolio:https://mjmaurya.github.io
                                   OR
                                   https://manojcse.netlify.app

Your feedback will be very important to me. It will help to enhance my development skill.
Top 3 Things to Drop From Resumes - Discuss Additional!
Tags: discuss, career
Published: 2020-07-03 23:41:24

---
title: Top 3 Things to Drop From Resumes - Discuss Additional!
published: true
description: As always, I'm helping people put together resumes and get re-employed during this whole pandemic induced depression we're barreling into. In light of that I've noticed a bunch of stuff on resumes that aren't really needed anymore.
tags: #discussion #career
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/wamv0b49az8ejk8bqxi7.png
---
As always, I'm helping people put together resumes and get re-employed during this whole pandemic induced depression we're barreling into. In light of that I've noticed a bunch of stuff on resumes that aren't really needed anymore.

The physical address is not really needed anymore these days. I've noticed it's often on the resumes still. No need, take it off, and I'd even argue it perpetuates several unneeded tropes and paradigms about geographic location.

The other thing, unless there is a specific reason, no need to put the physical location you existed in for various past jobs. The only thing that matters is if you'll be able to be in the geographic space required for jobs you're applying to.

Another, if you're past a solid decade of experience, it's rarely necessary in tech to keep listing every position for the last gazillion years.

Just the last ~5-10 years plus a note that you have more and can discuss if interested. That'll help prevent the 20+ page resumes.

Any others you can think of this day and age? Any advice I should add to my list of advice I provide as I review people's resumes that might be helpful?
I'm hosting a workshop at CodeLand:Distributed
Tags: codeland, watercooler, conference
Published: 2020-07-04 15:36:42

---
title: I'm hosting a workshop at CodeLand:Distributed
published: true
description: I will host a workshop at the CodeLand:Distributed conference. In Rocking the Gamepad API we will explore the Gamepad API and use it to build a small game.
tags: codeland,watercooler,conference
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/bzz04hbzr1dltctfkgvb.png
---

A few months back, I submitted a couple of workshop ideas for the [Codeland conference](https://codelandconf.com/). Since then, the world has changed quite a bit, the conference moved online... and **one of the ideas got picked!**

This will be **the first time that I speak or host a workshop at a conference**, and I am excited –and nervous– beyond belief. (**Please, share any tips you may have!**)

The title of the workshop is "*Rocking the Gamepad API*" and it is aimed at people who do web development and like exploring different web technologies (no gaming experience is required.) 

We will:

- Talk about **Web APIs**
- Learn the basics of the **Gamepad API**
- Explain how to use it
- Explore extensions and the future of the API
- **Build a small game with HTML and JS**

It won't be too advanced, but some JavaScript knowledge is required. Also, some type of game controller that can be connected to the computer will be necessary to follow along.

I look forward to meeting you at CodeLand! Whether in the talks, this workshop, or in any of the other amazing workshops that are available.

---

The conference is on July 23 and 24, with **free talks on the 23<sup>rd</sup>** and many workshops on the 24<sup>th</sup>. The talks are free and the workshops are $25. [Register today, spots are limited!](https://codelandconf.com/#tickets)
Delete Node in a Linked List(in-place)
Tags: javascript, leetcode, linkedlist, computerscience
Published: 2020-07-04 10:27:07

[Problem on leetcode.com](https://leetcode.com/problems/delete-node-in-a-linked-list)

We are asked to delete a node from a linked list. And we have to do this without knowing anything about this node's parent or the root of the linked list.

Assuming a node structure that looks like this:
```javascript
function ListNode(value) {
     this.value = value;
     this.next = null;
}
```

Let's go through the solution looking at this example:
`A->B->C->D->E->null` and assume we are asked to delete `C`.

We will not be able to see: `A->B` so our effective list is `C->D->E->null`. Since we can't see `B` we need to make `C` look like `D` without damaging the link that `B` already has to `C`.

Here are the steps to solve this problem:
1. Copy D.value into C.value
2. Copy D.next into C.next

Here is the JS code:
```JavaScript
function deleteNode(node) {
  node.val = node.next.val
  node.next = node.next.next 
};
```

Thanks for reading!
Advance Mongodb queries - cheatsheet
Tags: mongodb, database, nosql
Published: 2020-07-04 16:27:40

Here are few less used but important Mongodb queries I use now and then. Will keep updating this page If I get to use different less used queries.

### Copy database
```javascript
db.copyDatabase("dbname", "dbnamenew")
```

### Drop database
```javascript
use dbname
db.dropDatabase()
```

### Active operations
```javascript
db.currentOp() or db.adminCommand( { lockInfo: 1 } )
```

### Kill operation
```javascript
db.killOp(opid)
```

### Query stats
```javascript
db.collection.find({"status":"single"}).explain( "executionStats")
```

### DB stats (in GB)
```javascript
db.stats(1024*1024*1024)
```

### Create index
```javascript
db.collection.createIndex( { status: 1 } )
```

### Get indexes on collection
```javascript
db.collection.getIndexes()
```

### Create read only access for user on mongodb
```javascript
db.createUser({user: "example_read",pwd: "12345", roles: [{role:"read", db: "dbname"}]})
```

### Get user roles on mongodb
```javascript
db.getUser("user_name")
```

### Export collection
```javascript
mongoexport --host=10.0.0.1:27017 --username=example --authenticationDatabase=admin --collection=example_mapper --db=dbname --out=example_mapper.json
```

### Import from collection
```javascript
mongoimport --host=10.0.0.1:27017 --username=example --authenticationDatabase=admin --collection=example_mapper --db=dbname --file=example_mapper.json
```

### Dump mongodb
```javascript
mongodump --host=10.0.0.1:27017 --username=example --authenticationDatabase=admin --db db_example --out dumps/
```

### Restore mongodb from dump
```javascript
mongorestore --host=10.0.0.1:27017 --username=example --authenticationDatabase=admin  dumps/
```

### Shell connect with ssh
```javascript
mongo --ssl --host docdb.amazonaws.com:27017 --sslCAFile rds.pem --username example --password asddasdasd
```
Telefoonnummer voor technische ondersteuning van Dell

Published: 2020-07-04 14:12:21

Of uw Dell-computer nu niet werkt of uw printer niet goed presteert, u moet het <a href="https://dell.klantenservicebelgium.be/">Dell klantenservicenummer bellen</a>. Met behulp van probleemoplossers van leidinggevenden in de klantenservice kunt u weer genieten van het werk op uw computer of printer. Dit nummer is 365x24x7 beschikbaar, zodat u zich geen zorgen hoeft te maken over de problemen die optreden bij Dell-producten.
Briefing 10
Published: 2020-07-04 16:58:39

*Original Post Date: 4/22/2020*
*Author: IvanCoHe*

## Hey people! So I'm going to start doing the Briefings like this now. It's easier for me to format and it serves the same purpose. Now, for the news:<br>
<br>

**The internal survival build was last updated 4 days ago.** This might mean nothing but it most likely means that this is a pretty stable build. I'd expect some updates in the coming days but this might even be the last one (Unprobable but still a possiblity)<br>

<br>

**A new seat is visible in the new gif.** It's basically an egg seat.<br>

<br>

**There's now pipe chests in survival.** Seen in the last gif, it looks like there will be a chest variety that allows you to connect it to pipes and create automatic sorting systems. It's also needed for the Packing Stations.<br>

<br>

**Thanks for reading Mechanics, see you next briefing!**<br>

<br>
Chest and seat<br>

![](https://cdn.discordapp.com/attachments/685994642768265235/702639725260963951/unknown.png)
Leetcode - Missing Number (with JavaScript)
Published: 2020-07-20 02:07:05

Today I am going to show how to solve the Missing Number algorithm problem.

Here is the problem:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d7z611jiswzzvub3r34m.png)

Solution:
I solved this problem in 2 different ways.

The first one is easier and simpler. I used a Set data structure to store an array. Then I iterate through it to find which number is missing.

```javascript
var missingNumber = function(nums) {
    let map = new Set(nums);
     
    let expectedLength = nums.length + 1
    
    for (let number = 0; number < expectedLength; number++) {
        if (!map.has(number)) {
            return number
        }
    }

    return -1
};
```


For the second solution I use Gauss' formula, which helps to sum sequences of numbers. You can see the formula below:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/j09q4he0mkwm9x791vd3.png)

Essentially, all we have to do is to find the expected sum by using Gauss’ formula and then subtract from it the actual sum of the array.


```javascript
var missingNumber = function(nums) {
    let expectedSum = nums.length*(nums.length + 1)/2
    let actualSum = nums.reduce((a, b) => a + b, 0)
    let missingNumber = expectedSum - actualSum
    
    return missingNumber 
};
```
How do you stay motivated with your side projects?
Tags: discuss, productivity, beginners
Published: 2020-07-19 23:16:15

---
title: How do you stay motivated with your side projects?
published: true
description: Tips and tricks for helping stay motivated on side projects.
tags: discuss, productivity, beginners
//cover_image: https://direct_url_to_image.jpg
---

For me, it's staying organized. I'm tracking my feature list on my Github project. Keeping the features relevant and up to date has helped me stay on track. Here's what my [Github project](https://github.com/jonathanyeong/phoenix_blog/projects/1) looks like:

![Github project](https://dev-to-uploads.s3.amazonaws.com/i/mrp3251sntj1ifpigk25.png)

What helps keep you motivated with your side projects? I'd love to hear some of your tips and tricks!
Scalar Type Declaration
Tags: php
Published: 2020-07-20 16:16:12

Today, I like to share some of the key features provided in PHP. The PHP community has introduced some good features like Scalar type declaration, Return type declarations, etc.., which add some extra features to the PHP development, and provides flexibility in the development lifecycle. In this blog, I would like to explain the Scalar type declaration feature, I hope this will help you to improve your knowledge and help you somehow in the future.

# Scalar Type Declaration
Type declaration is also known as Type Hinting, allows a function to accept a parameter of a certain type if the given value is not of the correct type (Integer, Float, Boolean, string) PHP will return a fatal error. The older version of PHP (PHP 5) gives a recoverable error while the new release (PHP 7) returns a throwable error.

PHP 7 has introduced the following Scalar type declarations.

1.Boolean
2.String
3.Float
4.Integer
5.Iterable
Scalar Type Declaration comes in two types Coercive(i.e. default), and another one is Strict, if we want to enforce PHP to use a strict type declaration then, we should set the strict value to 1 using a declare directive, please check the example below.

`declare(strict_types=1);`
Please check the example below for Coercive and Strict type declarations.

# Coercive Scalar Type Declaration

```
try{
     function sum(int …$ints) 
     {
         return array_sum($ints);
     }
}catch(Exception $ex)
{
   echo $ex->getMessage();
}
print(sum(2, ‘3’, 4.1));
```
In the above example just want to highlight one thing i.e. we are not using a strict value for parameter type like 2 of Integer type, 3 of String type 4.1 of Float type. The above code will output the value int(9).

# Strict Scalar Type Declaration

```
declare(strict_types=1);
try {
      function sum(int …$ints) 
      {
         return array_sum($ints);
      }
} catch (Exception $ex) 
{   
   echo $ex->gt;
   getMessage();
}
print(sum(2, ‘3’, 4.1));
```
Note that, if we declare the `strict_type` value to 1, the above code will output “Fatal error: Uncaught TypeError: Argument 2 passed to sum() must be of the type integer, string is given”.

The above code will help us to enforce the other developer to use a variable of strict type i.e. Integer, Float, etc.

# Use of Scalar Type Declaration

The scalar type declaration can be used in different areas of development, like, defining strict values in an interface, so that, the child class which is overriding the interface must follow the strict type.

I hope that will help you somehow. Feel free to leave a comment below. Let me know what you think about this
Ultimate PROBLEM SOLVING GUIDE for Acing Programming Interviews
Tags: career, interview, beginners, computerscience
Published: 2020-07-21 16:58:40

Advice like "clarify the question" and "write pseudocode" is a good place to start, but it's not where you want to end if you're trying to impress an interviewer with your problem solving skills. How do you actually SOLVE the problem?

In this video I dive deep into all of the steps -- and problem solving strategies -- you need in order to ace a high-bar coding interview. Watch this video if the feedback(lol) you're getting from rejections isn't helpful, and/or you want an honest explanation of what your interviewer is looking for. 

In addition to challenging one-size-fits-all advice, I address the crux of the problem solving coding interview: coming up with a solution while managing risk and limited time.

For timestamp links see video description in YouTube: {% youtube -UhBywlBvw8 %}

CANDIDATE PLANET:
Empowering candidates to ace interviews, negotiate offers and advocate for themselves at work. Leave a comment or email Lusen@CandidatePlanet.com with questions you want me to answer.

PLEASE SUBSCRIBE \o/:
☆ Youtube ☆ https://youtube.com/CandidatePlanet
☆ Newsletter ☆ http://newsletter.candidateplanet.com
☆ LinkedIn ☆ https://linkedin.com/in/lus

ONE-ON-ONE COACHING:
Schedule a one-on-one coaching session with me: https://lusen.youcanbook.me

SALARY NEGOTIATION PLAYLIST:
☆ https://www.youtube.com/playlist?list=PLY0uEDNh-Haqes9eEvyGtzrUWOHv-c1op

ACE YOUR INTERVIEWS PLAYLIST:
☆ https://www.youtube.com/playlist?list=PLY0uEDNh-HarP6UtKFYRJZnkXzz4ICi73

Dubstep bee and Kipo art inspired by Kipo and the Age of Wonderbeasts.
🔒 How do you admin your Tokens on Github?
Tags: discuss, beginners, github, git
Published: 2020-07-21 04:13:01

I'm using some APIs on my first web projects. I know isn't safe to let tokens visible on the repos, and I can use an .env file.

The thing is that, if I delete the project on my pc, will I lose the token info?

How do you admin your own tokens? I would like to read you.
Thanks! 🙌
A New Video Series: The Maintainers
Tags: videos, opensource
Published: 2020-07-26 05:39:47

---
title: A New Video Series: The Maintainers
published: true
date: 2020-07-21 01:20:56 UTC
tags: Videos,OpenSource
canonical_url: http://wildermuth.com/2020/07/21/A-New-Video-Series-The-Maintainers
---

[![The Maintainers](https://wilderminds.blob.core.windows.net/img/Main.00_00_16_03.Still001.png)](https://youtube.com/watch?v=dZ_ZVZS-FNc) I know you've heard this before, but I'm starting yet another video series Don't worry the Rants are continuing soon, just didn't feel right to complain during COVID-19 too much.

This new series is all about the open source projects you use every day. I am interviewing people who maintain those projects. I hope to get your favorite developers to talk about why Open Source is so important to them.

In this first episode, I talk with [Jimmy Bogard](https://twitter.com/jbogard) about AutoMapper and how he built it so many years ago. I hope you like it!

<iframe src="https://www.youtube.com/embed/dZ_ZVZS-FNc" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

If you did enjoy the video, please like and subscribe to my channel. Every subscription helps!

Do you have any of your favorite open source projects you'd like me to highlight? If so, just leave a comment and I'll see if I can shine a light on the maintainers!

[![Creative Commons License](http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png)](http://creativecommons.org/licenses/by-nc-nd/3.0/)

          This work by [Shawn Wildermuth](http://wildermuth.com) is licensed under a [Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License](http://creativecommons.org/licenses/by-nc-nd/3.0/).  
          Based on a work at [wildermuth.com](http://wildermuth.com).

* * *

If you liked this article, see Shawn's courses on [Pluralsight](http://shawnw.me/pscourses).
 ![](http://feeds.feedburner.com/~r/ShawnWildermuth/~4/wNQEirwaqIA)
Oauth 1.0 access token issue
Published: 2020-07-21 10:11:06

I was trying to get access token with oauth 1.0 but getting Invalid signature for signature method HMAC-SHA1. I have the request token and verifier. 

Api i want to integrate:
https://api.immobilienscout24.de/api-docs/authentication/three-legged/

$consumerKey = "myrealapiKey";
$consumerSecret = "wEBxKUuQWYqRQ0Kb";