teleren/devto huggingface dataset:
Bootcamp Java Developer Day #10
Tags: java, bootcamp
Published: 2020-10-02 01:13:50

#### Day 10:

Resuming to bootcamp...

I only studied one topic today. There is always a small test at the end of each topic and I bombed it five times. I think I'm tired and I'm not absorbing much content today.

The Discrete Mathematics test had two tough questions for me, but I think I did well. Let's see when the Professor release the grades. 

#### 8) Ongoing: Implementing Collections and Streams with Java

Today's topic were:

- Comparator
java.util.Comparator;
java.util.Comparable
+
java.util.ArrayList;
java.util.Collections;
java.util.List;

We used these interfaces to order lists. I didn't try to code bubble sort, insertion sort or any other sorting algorithm in Java for comparison. I've done them in python, maybe I can rewrite them in Java in the future.
I wrote a browser extension to protect your privacy
Tags: watercooler, privacy, webdev, showdev
Published: 2020-10-02 01:05:11

Ever wonder if you could simply mask your tab while you were sharing your screen during a meeting or because someone is by your desk? Well, maybe not the latter recently because you know...🤷‍♂️. The extension allows you to mask any tab or if you want to mask all open tabs in the current window, there is a shortcut key for that. Oh and you can customize the shortcut key bindings to your liking. You are most likely going to have to customize it since it seems that most shortcut combinations that I could think of were in conflict with something else 🤦‍♂️.

The browser extension is available for Firefox, and Edge (Chromium) right now, with Chrome becoming available pretty soon! Download the extension for Firefox [here](https://addons.mozilla.org/en-US/firefox/addon/privacy-shade/) and Edge [here](https://microsoftedge.microsoft.com/addons/detail/shade/beejdgamkplgnpoabpkgpkdcbdhhnial).

If you have any feedback or issues to report, please consider submitting an issue using one of the templates [here](https://github.com/praneetloke/shade-browser-extension/issues/new/choose).

Here's a gif showing you how it works.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/eaqvc5gcb9gr6wai12dk.gif)
What do you want to know about coding in Minecraft or Roblox? Let us know for the chance to be featured on DevDiscuss!
Tags: discuss, podcast
Published: 2020-10-02 00:56:18

---
title: What do you want to know about coding in Minecraft or Roblox? Let us know for the chance to be featured on DevDiscuss!
published: true
tags: discuss, podcast
---

The [DevDiscuss Podcast](https://dev.to/devdiscuss) begins with an interview and ends with commentary from listeners — and we like to feature the actual _voices_ from our community!

### **This week's prompt: “What do you want to know about coding in Minecraft or Roblox?”** 
  
For your chance to appear on an upcoming episode, answer the question above by:

- Calling our Google Voice at +1 (929)500-1513 and leave a message 📞

- Sending a voice memo to pod@dev.to 🎙

- OR, leaving a comment here (we'll read your response aloud for you) 🗣

_Please send in your recordings by October 7th at 5 PM PT (8 PM ET, 12 AM UTC)_

---

Don't forget to check out the [latest episode](https://dev.to/devdiscuss/s2-e7-serverless-and-the-cloud-101), released on September 30th!
Global and Local Items, C++
Published: 2020-10-02 00:54:38

Confused: Two files, one works, one doesn't, difference is that the declaration "vector string Name;" is placed in two locations, one preceding the "int main()" statement and one within the function. The compiler issues an error for the one that precedes the "int main()" function that the command "getline" is not a valid name. I thought that in C++, one could declare the variable either globally or local to the function and would still be interpreted, in a different manner of course, but not issue and error the the command is not valid in one case, totally confused and any help will be appreciated, Sid Kraft.
Challenge Accepted! Just F*ing Ship It.
Tags: nocodeoverlays, justfingshipit, womenmakechallenge
Published: 2020-10-02 00:52:12

---
title: Challenge Accepted! Just F*ing Ship It.
published: true
description: I'm participating in this year's Just F*ing Ship it Challenge by Women Make.
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/zvr7a01y00fsgw2w0vsi.png
tags: NoCodeOverlays, JustFingShipIt, WomenMakeChallenge
---

Great news! I'm joining the 30-day Just F*ing Ship It challenge to launch [No-Code Overlays](https://nocodeoverlays.com) on October 31st, 2020. If you want to read all the background information on the project, how I came up with my idea, and what the next few days will be like, make sure to check out the [No-Code Overlays blog](https://nocodeoverlays.com/blog)! I'll keep posting updates there as well, so keep your eye out every few days or so.

![A white page with black text. At the top is the site title "No-Code Overlays". Below it, smaller body text reads, "Empowering anyone to create interactive streaming overlays without learning how to code." At the bottom is small text and a link that reads "Made by Ashlee M Boyer". In the middle is a yellow square that looks like a sticky note. It is turned at an angle. It has 4 lines of text with the most emphasis on the third line, a countdown. It reads, "Coming Soon! October 21st, 2020 5pm ET. 35d 3h 5m 40s. Check in periodically for details."](https://github.com/NoCodeOverlays/nocodeoverlays.com/raw/master/public/preview.png)
Elixir เรียกฟังก์ชันแบบ dynamic
Tags: elixir
Published: 2020-10-02 00:42:27

Elixir เป็น functional language ซึ่งโครงสร้างของโค้ดจะถูกประกอบขึ้นมาจากการ ร้อยเรียงการเรียกใช้งาน function เล็กๆ ให้เป็นการทำงานที่ซับซ้อนขึ้น

โค้ดของ Elixir จะถูกจัดกลุ่ม function ออกเป็น module ตัวอย่างเช่น

```elixir
defmodule Calc do
  def add(a, b) do
    a + b
  end
end
```

ก็คือเราสร้าง module Calc ที่มีฟังก์ชันชื่อ add

เวลาเรียกใช้งาน function นั้นต้องใช้ชื่อ module แล้วใช้ `.` ตามด้วยชื่อ function และ `()` ที่มี arguments ที่ต้องการส่งใช้ function เช่น

```elixir
Calc.add(10, 20)
```

## เรียก function แบบ dynamic module

อย่างไรก็ตาม นอกจากความเป็น functional language แล้ว Elixir ยังเป็น dynamic language ด้วย

จริงๆแล้วการเรียก function ด้วย `.` นั้นประกอบด้วย 3 ส่วน

- ชื่อ module
- ชื่อ function
- ลิสต์ของ arguments (arg1, arg2, ...)

ใน Elixir ชื่อของ module ก็ถือว่าเป็นข้อมูลที่มีประเภทเป็น Atom ดังนั้นถ้าเรามีตัวแปรเก็บชื่อ Atom แบบนี้

```elixir
mod = Calc
```

เราสามารถเรียก function ให้ทำงานได้เช่นกันแบบนี้

```elixir
mod.add(10, 20)
```

ด้วยเทคนิคนี้เราสามารถเขียนโค้ดซึ่งแยก module ออกเป็น parameter เพื่อที่จะทำให้เราเปลี่ยน module ได้ เพื่อที่จะเปลี่ยนกลไกการทำงานไม่ fix ตายตัว หรือเพื่อทำให้ง่ายต่อการเขียน test เช่น

```elixir
defmodule Apply do
  def add(mod, a, b) do
    mod:add(a, b)
  end
end
```

จะเห็นว่า function `Apply.add` จะรับ parameter `mod` เข้ามาแล้วเอาไปใช้เพื่อเรียก `mod:add(a, b)` เราสามารถเรียกใช้ Apply.add ได้โดยส่ง module เป็น argument เข้าไปแบบนี้

```elixir
Apply.add(Calc, 10, 20)
```

หรือถ้าเรามี module อื่นที่มีฟังก์ชัน `add/2` แบบนี้

```elixir
defmodule Text do
  def add(a, b) do
    "#{a}, #{b}"
  end
end
```

เราก็สามารถเรียกใช้ Apply.add ได้แบบนี้เช่นกัน

```elixir
Apply.add(Text, "Hello", "World")
```

## เรียก function แบบ dynamic module และชื่อ function ด้วย apply

ใน Elixir ชื่อ function ก็เป็นข้อมูลแบบ Atom เช่นกัน เช่นฟังก์ชัน `add` ก็คือ Atom `:add` นั่นเอง

และ Elixir มีฟังก์ชันชื่อ apply ที่จะรับชื่อ module, ชื่อ function ที่เป็น Atom และ ลิสต์ของ arguments เพื่อเรียกฟังก์ชันแบบ dynamic ให้กับเราเช่น เราจะเรียก Calc.add ผ่าน apply ได้ดังนี้

```elixir
apply(Calc, :add, [10, 20])
```

และเรียก Text.add ผ่าน apply ได้แบบนี้

```elixir
apply(Text, :add, ["Hello", "World"])
```

## สรุป
ดัวยความเป็น dynamic ของ Elixir ทำให้เราสามารถ apply function โดย แยก module ออกไปเป็น parameter ได้

หรือเมื่อใช้ apply function ก็ทำให้เราแยกชื่อฟังก์ชันเป็น parameter ได้เช่นกัน

ช่วยให้เราสามารถเขียนโค้ดที่รองรับการเปลี่ยนการทำงานโดยการเขียนเป็น module ให้แล้ว apply แบบ dynamic ได้เลย

สามารถเขียนโค้ดส่วนที่ซ้ำกันออกมาแล้วทำให้ส่วนที่ไม่ซ้ำแยกเป็น module ใหม่ที่รับเป็นแค่ parameter เข้ามาได้ง่ายๆ และทำให้ทดสอบได้ง่ายอีกด้วย
I just started a YouTube on coding tutorials
Tags: javascript, webdev, tutorial, showdev
Published: 2020-10-02 00:26:44

Nice to meet you all.

I'm Alan - I have around 8 professional years of experience under my belt now. I consider myself a full stack developer but at the moment my full time role is Mobile Team Lead for a leading provider of local government software.

On my day to day I code using ReactJS with the Ionic Framework to create our cross platform mobile apps.

I've always wanted to start a youtube channel, with my own name, and introduce myself as myself, teaching what I know best: to code.

I've just went ahead and got stuck in and put out my first quick coding tutorial on Javascript forEach loops.

Check it here and let me know what you think:
[📹 forEach array loop method - Javascript tutorial in under 5 minutes 👈](https://youtu.be/yTLD4GNs1dA)

![Foreach in JavaScript](https://dev-to-uploads.s3.amazonaws.com/i/ym278tdbyaa184ue2m8h.png)

I'd appreciate a like and a comment (and even a sub) to help me get going!

I'm definitely going to continue this little "Mini series" on these very small topics to get my channel off the ground. I plan on covering all types of array methods in JavaScript and maybe some more basic fundamentals aswell. All with the same styled art for thumbnails and the same sort of process. 👏😀

In contrast to that I want to create some videos where I'm coding a real project to give an insight into how I code and give tips throughout the video, for example building a calculator, notes app, etc etc.

I'm also planning on reviewing UI frameworks, CSS frameworks, component libraries etc!

I'm planning on a video per day at the moment 🧙‍♂️

Thanks!
New: "Cheat sheet" view for Topic pages
Tags: html, css, javascript, git
Published: 2020-10-02 00:23:32

We recently added code snippets directly to some of our Topic pages. Now users can easily skim through them to find what they're looking for.

The new Topic pages look like this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lqrz7s1wct6c1ug2uksf.png)

We're calling this new layout the "cheat sheet" view because it allows you to get information at a glance.

For comparison, our old Topic pages consisted of lists of links, like this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dugb7ivtjdoyc47rowji.png)

They were functional, but hard to skim through, especially on the pages with a lot of tutorials. To be clear, some of the Topic pages are still keeping the old format for now (like the Text Editor Basics page in the example above), but that may change in the future.

You can check out our list of Topic pages on the [Simple Dev home page](https://simpledev.io/). Try viewing the HTML, CSS, Git, and npm pages to see examples of the new layout.

If you want to find information even faster, don't forget that you can always use our powerful search feature to instantly find any tutorial on the site.

Have fun coding!
I learned React Hooks and now I'm the happiest dev on the planet! 🌎
Tags: react, codenewbie, javascript
Published: 2020-10-02 00:23:00

A couple days ago I posted about [a simple CRM tool I made](https://www.indiehackers.com/post/after-learning-react-for-the-past-24-hours-i-made-a-simple-crm-tool-02d26f1ef9) after learning React basics **in 24 hours**.

I got lot's of useful feedback. [Mike Cavaliere](https://mikecavaliere.com) told me about this thing called *React Hooks*. At the time, I was somewhat familiar with the term but didn't know what was so great about it.

Anywho, this morning I took the time to learn the basics of `useEffect` and `useState` and I am literally the ***happiest developer on the planet***. 😎

![Happy picture](https://th.wallha.com/ts/VsdePo0R.jpg)

## Why am I so happy? 😁

It's simple.

The workflow to create components is much smooth and neat. Also much easier than using class components instead.

I'm thinking of improving my current set of skills and then will start to learn Redux and Styled Components.

---

I would love if any of you have feedback on what I should fix/learn next. The Github repository is below if you want to take a peak at the code. 😉

👉 https://github.com/BraydenTW/simple-react-crm

---

*This was originally posted [on IndieHackers](https://www.indiehackers.com/post/i-learned-react-hooks-and-now-im-the-happiest-dev-on-the-planet-555b517186)*
Happy dev.to-day to me?
Tags: watercooler
Published: 2020-10-02 00:17:31

It's been exactly a year since I joined dev.to. Back then, I joined as a "side-effect" of Hacktoberfest. 

I want to take this opportunity to thank all of you for being

- a great resource of knowledge
- a constructive & inclusive community
- a great audience and
- a source for new friends and ideas

Remember my first Hacktoberfest package unboxing with me: [youtube](https://youtu.be/saYv5jhDSHg)
10 Best Visual Studio Code Extensions for Web Development
Published: 2020-10-02 00:07:37

As a Software Engineer, I like to focus on the creative task (e.g., coding) and want to leverage the tedious, repetitive tasks with the help of IDE. Another critical and often neglected feature of modern IDEs is that they reduce the Context Switching of the developer by providing the tools for day-to-day Job.

Context Switching in programming is expensive. But Context switching of the human brain is significantly more costly than CPU’s context switching.

In my programming career, I have used many free (KDevelop, Eclipse, NetBeans, Atom, Sublime Text, and VS Code) and many commercial IDE. Among them, I found Visual Studio Code is the best IDE, especially for Web Development. Developed by Microsoft in 2015, it quickly rose to prominence and loved by the developers. The Stack Overflow Developer Survey 2019 has ranked VS Code as the most popular IDE for Web development:

Installing an Extension
If you know how to install a VSCode extension, you may skip this section.

First of all, you need to have VSCode installed on your system. I assume you already have but if you haven’t then you can download it by following the link here. Next, launch VSCode and open the Extensions tab from the left sidebar or hit command-shift-x on macOS or ctrl-shift-x on Windows and Linux. There, you will see the list of installed extensions. You can search for other extensions. Once you find an extension, simply click the Install button. You may need to reload VSCode in some cases. If not, you’re good to go!

 
Here’s a list of the top VSCode extensions that every web developer must have:

Material Icon Theme
Atom Keymap
Prettier – Code formatter
Bracket Pair Colorizer 2
Auto Rename Tag
HTML CSS Support
Emmet
PHP IntelliSense
Email [to make .eml files colorful]
Auto Close Tag
How to get User in ipython - Django
Tags: python, django, shell
Published: 2020-12-07 12:49:13

---
title: How to get User in ipython - Django
published: true
date: 2020-10-02 00:00:00 UTC
tags: #python, #django, #shell
canonical_url: https://tech.serhatteker.com/post/2020-10/how-to-get-user-in-ipython-django/
---

## Problem

You are trying to get `User Model` in your **Django** app but getting `ImproperlyConfigured` error instead.

Verbose mode of the error says:

> ImproperlyConfigured: Requested setting AUTH_USER_MODEL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Your workflow would be like below:

```bash
(.venv) ~/yadrta $ ipython
Python 3.8.1 (default, Feb 12 2020, 16:30:11)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from django.contrib.auth import get_user_model

In [2]: User = get_user_model()
---------------------------------------------------------------------------
ImproperlyConfigured                      Traceback (most recent call last)
<ipython-input-2-6968e3c2733c> in <module>
----> 1 User = get_user_model()

~/yadrta/.venv/lib/python3.8/site-packages/django/contrib/auth/__init__.py in get_user_model()
    155     """
    156     try:
--> 157         return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
    158     except ValueError:
    159         raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form 'app_label.model_name'")

~/yadrta/.venv/lib/python3.8/site-packages/django/conf/__init__.py in __getattr__(self, name)
     81         """Return the value of a setting and cache it in self.__dict__."""
     82         if self._wrapped is empty:
---> 83             self._setup(name)
     84         val = getattr(self._wrapped, name)
     85         self.__dict__[name] = val

~/yadrta/.venv/lib/python3.8/site-packages/django/conf/__init__.py in _setup(self, name)
     62         if not settings_module:
     63             desc = ("setting %s" % name) if name else "settings"
---> 64             raise ImproperlyConfigured(
     65                 "Requested %s, but settings are not configured. "
     66                 "You must either define the environment variable %s "

ImproperlyConfigured: Requested setting AUTH_USER_MODEL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

In [3]:
```

## Solution

You should use [IPython] in [django shell]. Just run:

```bash
$ python manage.py shell -i ipython
```

You can also look at this post: [How to Run Django Shell in Python] for detail.


All done!


[IPython]: https://ipython.org/
[django shell]: https://docs.djangoproject.com/en/dev/ref/django-admin/#cmdoption-shell-interface
[How to Run Django Shell in Python]: https://tech.serhatteker.com/post/2020-09/run-django-shell-with-ipython/
How to redirect all emails to one inbox on Yii2 applications
Tags: yii2, email, debug, smtp
Published: 2020-10-02 04:39:31

---
title: How to redirect all emails to one inbox on Yii2 applications
published: true
date: 2020-10-02 00:00:00 UTC
tags: yii2, email, debug, smtp
canonical_url: https://glpzzz.dev/2020/10/02/yii2-redirect-all-emails.html
---

[\yii\mail\BaseMailer::useFileTransport](https://www.yiiframework.com/doc/api/2.0/yii-mail-basemailer#%24useFileTransport-detail) is a great tool. If you activate it, all emails sent trough this mailer will be saved (by default) on `@runtime/mail`instead of being sent, allowing the devs to inspect thre result.

But what happens if we want to actually receive the emails on our inboxes. When all emails are suppose to go to one account, there is no problem: setup it as a param and the modify it in the `params-local.php` (assuming advaced application template).

The big issue arises when the app is supposed to send emails to different accounts and make use of replyTo, cc and bcc fields. It’s almost impossible try to solve it with previous approach and without using a lot of `if(YII_DEBUG)`.

Well, next there is a solution:

```
'useFileTransport' => true,
'fileTransportCallback' => function (\yii\mail\MailerInterface $mailer, \yii\mail\MessageInterface $message) {
    $message->attachContent(json_encode([
            'to' => $message->getTo(),
            'cc' => $message->getCc(),
            'bcc' => $message->getBcc(),
            'replyTo' => $message->getReplyTo(),
        ]), ['fileName' => 'metadata.json', 'contentType' => 'application/json'])
        ->setTo('debug@mydomain.com') // account to receive all the emails
        ->setCc(null)
        ->setBcc(null)
        ->setReplyTo(null);

    $mailer->useFileTransport = false;
    $mailer->send($message);
    $mailer->useFileTransport = true;

    return $mailer->generateMessageFileName();
}

```

How it works? `fileTransportCallback` is the callback to specify the filename that should be used to create the saved email on `@runtime/mail`. It “intercepts” the send email process, so we can use it for our porpuses.

1. Attach a json file with the real recipients information so we can review it
2. Set the recipient (TO) as the email address where we want to receive all the emails.
3. Set the others recipients fields as null
4. Deactivate `useFileTransport`
5. Send the email
6. Activate `useFileTransport`
7. Return the defaut file name (datetime of the operation)

This way we both receive all the emails on the specified account and get them stored on `@runtime/mail`.

Pretty simple helper to review emails on Yii2 applications.
Memory efficient way of reading and downloading a large file in Ruby
Tags: ruby
Published: 2020-10-02 11:39:10

---
title: Memory efficient way of reading and downloading a large file in Ruby
cover_image: https://www.kartikey.dev/assets/files_image.jpg
published: true
date: 2020-10-02 00:00:00 UTC
tags: ruby
canonical_url: https://www.kartikey.dev/2020/10/02/memory-efficient-way-reading-and-downloading-file-in-ruby.html
---

### To read a large file from the disk

[`File.foreach`](https://ruby-doc.org/core-2.7.1/IO.html#method-c-foreach) method reads the file line by line; that is why it is safe to use for large files.  
It can accept the block to execute each line of a file.

Example:

```ruby
File.foreach('example.jsonl') { |line| JSON.parse(line) }
```

However, in the Ruby documentation, you will not find this method defined on the [`File`](https://ruby-doc.org/core-2.7.1/File.html) class. It is defined on [`IO`](https://ruby-doc.org/core-2.7.1/IO.html), which is a superclass of [`File`](https://ruby-doc.org/core-2.7.1/File.html).

### To download the large files from the Internet

We can use [`IO.copy_stream`](https://ruby-doc.org/core-2.7.1/IO.html#method-c-copy_stream) to download the large files from the Internet. It will create a stream instead of loading the whole file into memory before writing.

Example:

```ruby
IO.copy_stream(open('http://example.com/file.jsonl'), 'file.jsonl')
```

To sum it up…

Memory friendly methods:  
[`File.foreach`](https://ruby-doc.org/core-2.7.1/IO.html#method-c-foreach), [`IO.copy_stream`](https://ruby-doc.org/core-2.7.1/IO.html#method-c-copy_stream)

Other methods to read a file:  
[`File.read`](https://ruby-doc.org/core-2.7.1/IO.html#method-c-read), [`File.readlines`](https://ruby-doc.org/core-2.7.1/IO.html#method-c-readlines)
Spotlight stops indexing Applications
Tags: macos, spotlight, mojave, bash
Published: 2020-10-02 07:00:10

---
title: Spotlight stops indexing Applications
published: true
date: 2020-10-02 00:00:00 UTC
tags: macos, spotlight, mojave, bash
canonical_url: https://solrevdev.com/2020/10/02/spotlight-stops-indexing-applications.html
---

All of a sudden spotlight on my macOS Mojave macmini stopped working…

There is a process called `mdutil` which manages the metadata stores used by Spotlight and was the culprit for my issue.

The fix after some Google Fu and some trial and error was to restart this process as follows:

```powershell
sudo mdutil -a -i off  
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist  
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist  
sudo mdutil -a -i on

```

Hopefully this won’t happen too often but if it does at least I have a fix!

Success? 🎉