teleren/devto huggingface dataset:
Ruby partition is great!
Tags: ruby
Published: 2020-11-10 02:29:50

Ever had a collection and wanted to do one thing for some items and something else for others? We have `partition` in ruby that lets us split the collection into two collections.

Ex:

```
arr = [4,9,10,6,8]
evens, odds = arr.partition {|e| e%2 == 0}
evens.each {|e|
  //process e
}
odds.each {|e|
  //process e
}
```
Hacktober 2020 Experience
Tags: hacktoberfest
Published: 2020-11-10 03:13:32



 Hi guys I'm Narayanan. I'm an aspiring engineer who is motivated to learn new things.


I love coding and I'm improving on it. I have learned Java and i know the basics of Python and C.

### Progress
I'm a beginner and I'm improving my skills on technology and so I'm excited to be a part of hacktober 2020.

### Contributions

I just contributed a few basic java based programs for beginners.


### Reflections
It has been a wonderful experience and I'm happy to be a part of hacktober 2020. Surely waiting for the next hacktober fest and hopefully make better contribution to the open source projects.
Spring Boot for war
Tags: spring, boot, java, war
Published: 2020-11-10 03:00:42

Spring Boot supports the following embedded servlet containers:
* Tomcat 
* Jetty
* Undertow 

You can use Maven, Gradle, or Ant/Ivy as build tools to generate the jar file. However, you may need to use your own server as WebLogic, Wildfly, JBoss, etc. In that case, you would need to generate a WAR file of your Spring Boot project. To do that you have to do the next changes:
* Change artifact type to WAR
* Extend SpringBootServletInitializer
* Override the configure method

```java
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(Application.class);
	}
}
```
mvn package will create a hybrid and a traditional (.original) WAR. The traditional WAR is produced without the embedded tomcat. So, you can use the .war.original file in your application server.
Modals Are Promises
Tags: ui, react, frontend, protip
Published: 2020-11-10 02:47:43

---
title: Modals Are Promises
published: true
description: A pattern for coding UI modals
tags: UI,react,frontend,protip
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/gen5jw8t9qa0ohg2i1yc.png
---

# Can modals be treated like promises

The answer is yes.  I can't count how many times I've coded a confirmation modal.  Every time I've been unhappy by the extra state management required to handle the open and close actions.  There must be a better way.  Promises are a natural resource for control flow.  Since a modal is almost always dictated by a user action, promises are a nice pattern.

#### Here is the tl;dr

```javascript
// get some context for the modal
const thingContext = {count: 109}
const userAction = new Promise((resolve, reject) => {
  // show the modal
  setDialog({resolve, reject, context: thingContext})
})
try {
  await userAction;
} catch {
  // negative action flow
  setLoading(false);
  setDialog(false);
  return false;
}
// positive action flow
```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3uhdlxy2lkqy4m0bq239.gif)

{% github kyleparisi/promise-modal %}
Hacktoberfest 2020
Tags: hacktoberfest
Published: 2020-11-10 02:00:25

Hi everyone! This was my second year participating in Hacktoberfest. Last year I got great support from a local dev community, and I was able to contribute to some open source projects.

Hacktoberfest helped me understand better how to contribute to open source software, and help the community.

This year I was not only able to contribute to some projects, but also help people who were willing to contribute to one of my projects. It was fun, and a satisfying experience. It even helped me understand better the role of a project maintainer.

I'm grateful for dev.to, DigitalOcean and Intel for organizing this amazing event!
Looping over a collection
Tags: python, beginners, coding, codenewbie
Published: 2020-11-10 01:47:47

Consider the following collection(list):
```python
fruits = ['apple', 'grapes', 'mango', 'banana', 'orange']
```

####To loop over the list `fruits`
```python
for fruit in fruits:
    print(fruit)
```

####To loop in reverse over the list `fruits`
```python
for fruit in reversed(fruits):
    print(fruit)
```

####To get the indices of the list `fruits`
```python
for i, fruit in enumerate(fruits):
    print(f'{i} - {fruit}')
```
####Output of `enumerate()`
```
0 - apple
1 - grapes
2 - mango
3 - banana
4 - orange
```

In the previous code snippet, we have used `enumerate` to loop over the list.

#### enumerate(iterable, start=0)
`enumerate()` allows us to loop over an iterable and provides an automatic counter. It takes two parameters:

1. `iterable` - an object that supports iteration like list, tuple etc.
2. `start` - specifies the starting index of the counter. It is optional and defaults to 0.

####Example
```python
for i, fruit in enumerate(fruits, start=1):
    print(f'{i} - {fruit}')

print("-----------")

for i, fruit in enumerate(fruits, start=100):
    print(f'{i} - {fruit}')
```
####Output
```
1 - apple
2 - grapes
3 - mango
4 - banana
5 - orange
-----------
100 - apple
101 - grapes
102 - mango
103 - banana
104 - orange
```
Explain Javascript Closures
Published: 2020-11-10 00:12:09

---
title: Explain Javascript Closures 
published: true
description: What are closures useful for.
tags: 
//cover_image: https://direct_url_to_image.jpg
---
So could someone give some examples as to how closures are useful? As I get its way of not using global variables. and you access it by creating two functions and returning the nested function.

Other than this I really don't see where or why you should use it.
How to convert characters to ASCII code and vice versa in JavaScript?
Tags: javascript
Published: 2020-11-10 00:00:00

---
  title: How to convert characters to ASCII code and vice versa in JavaScript?
  published: true
  tags: JavaScript
  date: Tue Nov 10 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/convert-characters-to-ascii-and-vice-versa-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-4950613497c4a4635f4f837b5f48f3d9.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/convert-characters-to-ascii-and-vice-versa-javascript)
  
## Contents

- [Convert character to ASCII code](#character-to-ascii)
- [Convert ASCII code to character](#ascii-to-character)

<a name="character-to-ascii"></a>

## Convert character to ASCII code

To convert characters to ASCII, you can use the `charCodeAt()` string method in JavaScript.

Consider this string,

```js
// string
const str = "Hello John!";
```

Let's convert the first character of the above string using the `charCodeAt()` method like this,

```js
// string
const str = "Hello John!";

// convert first character
// of string to ascii by passing the
// index number of character in the string
// as an argument to the method
const asciiVal = str.charCodeAt(0);

console.log(asciiVal); // 72
```

- The method accepts a valid index number in the string to get the ASCII value for that character.

See this example live in [JSBin](https://jsbin.com/napatavoni/edit?js,console).

<a name="ascii-to-character"></a>

## Convert ASCII code to character

To convert ASCII code to a character, you can use the `fromCharCode()` Static method in the String class in JavaScript.

Let's say we have ASCII code `65` like this,

```js
// ASCII
const asciiCode = 65;
```

Now let's convert this ASCII code to a character using the `String.fromCharCode()` static method like this,

```js
// ASCII
const asciiCode = 65;

// convert ASCII code to character
// by passing the code as an argument
// to the method
const character = String.fromCharCode(asciiCode);

console.log(character); // "A"
```

See this example live in [JSBin](https://jsbin.com/gohebeyali/5/edit?js,console)

You can also pass more than one ascii code as arguments to the method like this,

```js
// ASCII
const asciiCode = 65;
const asciiCode1 = 66;
const asciiCode2 = 67;

// convert ASCII code to character
// by passing the ascii codes
// as arguments to the method
const character = String.fromCharCode(asciiCode, asciiCode1, asciiCode2);

console.log(character); // "ABC"
```

See this example live in [JSBin](https://jsbin.com/xorepofofu/1/edit?js,console).

- The method accepts valid ASCII codes as arguments to convert to the appropriate character.

### Feel free to share if you found this useful 😃.

---
Running a 24/7 music stream for coders
Published: 2020-11-09 23:11:49

Hey I’ve just started running a 24/7 music livestream. I’m going to add some cool features and run it for a month before writing a post in depth about it. 

Anyways I was wondering if I could get feedback on the music and the whole stream

https://youtu.be/0EIV1B_ilrU
Asking for a friend (no, really)
Tags: startup, cto, earlystage
Published: 2020-11-09 23:06:23

---
title: Asking for a friend (no, really)
published: true
description: 
tags: startup, cto, earlystage
//cover_image: https://direct_url_to_image.jpg
---

Any of my developer connections out there with React Native and serverless FaaS/DBaaS experience, with the bandwidth and risk appetite for a CTO role (currently unpaid, equity-only) in an early stage startup? Similar to Uber/Lyft, but for limos and requiring mobile apps for riders and drivers as well as a web-based fleet management dashboard.

***NO AGENCIES***

Comment here or DM me and I'll get you connected with the CEO, a connection of mine and a current Y Combinator Startup School attendee like me.
Day 252: Darkness
Tags: hiphop, code, coding, lifelongdev
Published: 2020-11-09 22:43:06

_liner notes_:
- Saturday : Did the radio show from the park! Had a pretty good show. Went on a little bit of a rant. The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of the new Mississippi flag with the words Nov. 7th 2020, Democrat this up on the top and bottom](https://dev-to-uploads.s3.amazonaws.com/i/bxqjnc8dfk5h0lc7g0k6.jpg)

- Sunday : Found a new spot to park on the weekends. Pretty nice and off the main road. It rained hard all night. I slept really good. Spent most of the day in the park writing some code. Once I figured out some bugs, I headed to my folks place. Spent the night doing some more coding and watched "The Walking Dead" spinoff shows.

- Professional : Had a lot of meetings today. I did get to work on some documentation and demo some code I was working on. Not too bad.

- Personal : So there's a tropical storm by Florida and the darkness of the skies for the past couple of days is really eerie. Just want to go to sleep. haha

![Huge rock formation sticking out the ocean in Hvítserkur, Iceland and sunset](https://dev-to-uploads.s3.amazonaws.com/i/2k1a3yukl1hjtmggopb3.jpg)

So tired. I may have another demo with a local event organizer to see if the bug fixes I made over the weekend actually work just not on my computer. haha. Probably work on the layout for my new project.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube -ZWKByzpqDI %}
A Student's Perspective on HacktoberFest
Tags: hacktoberfest
Published: 2020-11-09 22:30:23

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->


### Hello there!
I'm a senior computer science student new to the DEV community. Since the beginning of 2020, I've been realizing how much more I need to learn after college. I joined this community to find resources and articles that expand my knowledge about different technologies and become more involved in the developer community. I saw Hacktoberfest as a great opportunity to put my name out in the community and experience large scale projects. 

### Background

<!-- Are you brand new to open source? What about coding in general? Tell us about how you got here -->

I've always been interested in computers and started programming with JavaScript on Codecademy in 2011. Since then, I've always seen programming as a limitless medium that allows me to dream of outlandish ideas and actually be able to implement them. I spend a lot of my time programming academically but I find myself unable to stop programming outside of school. If I'm not programming I enjoy researching new technologies and discovering more about this amazing industry.

Since I only made one open-source contribution before Hacktoberfest, I was still very much a beginner. However, I found there was plenty of helpful resources and documentation available that made me confident to contribute to larger projects. 

### Contributions

<!-- This is where you can list the contributions you made and explain why you chose the projects you did. Don’t forget to add links!  -->

Although my schedule is fairly packed with my studies, I made some small contributions. I found using the #first-timers-only tag on GitHub useful for finding introductory issues that I could manage. 

I made some documentation contributions to [Meshery](https://github.com/layer5io/meshery/pull/1760). 

Then I wanted to do some work on my personal website that is very barebones at the moment. I opened [my repository](https://github.com/DanRowe1/drowe-dev) up to the public and began creating issues. I was originally making the issues with the expectation that I would be the only one fulfilling them. However, I was very surprised to find community members found my issues and made pull requests to fulfill them. 


### Reflections
<!-- Overall, how has your Hacktoberfest 2020 experience been? If you’re a first-timer, will you participate again? What have you learned? Have you made any interesting connections? What is your next step in open source?  -->

Overall, I love this event. My eyes have been opened to the power of the open-source community and I would gladly participate again. I was astounded by the speed at which my issues were found and fulfilled on GitHub. I created an issue then went to make a sandwich and when I returned someone had completed it. Next year I would like to create a blank repository that starts with an idea at the beginning of HacktoberFest and see what the community can create together in just a month.
100 days of code - Dia 1
Tags: 100daysofcode, python, programming, productivity
Published: 2020-11-09 22:24:47

Para uma breve introdução...
[Pensei em fazer esse challenge para mostrar minha rotina, apenas como freelancer].

<h2>(09/11/2020)</h2>
- Comecei a planejar um projeto de ponto eletronico web, onde , de primeira mão, irá conter controle de entrada e saida de funcionarios, envio de mensagens por e-mail, fluxo e historico de funcionarios. ![f6cfe198-dc4a-4fcf-b2c7-daa7577c8109](https://dev-to-uploads.s3.amazonaws.com/i/l1nb2ogp7wp7bjavrvv2.jpeg)

<h4>Tecnologias</h4>
Nesse projeto irei utilizar:
- Python;
- Django;
- Bootstrap;
- A santíssima trindade (html, css, js);
- E outros widgets que irei implementando ao decorrer do projeto.

Hoje consegui terminar o layout da landing page, que será onde o usuário terá o primeiro contato com o produto e, terminei também, o layout do dashboard do sistema.

Por enquanto é isso...
The Fixed Line Mystery...
Tags: hack, ip
Published: 2020-11-06 23:20:01

![](https://riverside.rocks/assets/serve/production/app/5fa5da53823a9.png)

A few days ago I deiced to open up my SSH to the internet. Possibly not the greatest idea, but I have a service set up to block brute force attempts and report unauthorized connections to [AbuseIPDB](https://www.abuseipdb.com). After a few days I started noticing some odd patterns.

Over the last few days, I have gotten a *ton* of break in attempts from "Fixed Line" ISPs (IPs being used by people's homes and possibly businesses). A good deal of these requests appear to be coming from smaller ISPs (to this date no requests have come from one of the biggest ISPs in the United States, Comcast), mostly from CenturyLink Communications LLC.

At first I thought that most of these attacks were from exploited hosts - IPs that have been hacked. A bot (possibly a person) brute forced a login page that was on the internet, and uploaded malware that lets the IP scan for more login pages, and the cycle continues creating a botnet. While some of the requests were likely just this, I noticed something odd. Most of the IPs had only 1 or 2 reports (one of them being mine). I was a bit confused at why I was one of the only reports, but then I came up with an interesting idea.

# The Theory

Likely the malware inserted on to these IPs wasn't scanning the entire internet, instead it was scanning only residential CIDR blocks. My server's IP, which is a Comcast IP likely fell under one of the CIDR blocks. Most people choose to use web hosts instead of self hosting which would explain the few reports.

# The Lesson

If it doesn't need to be on the internet, don't put it on the internet. If you are unsure if you have any router logins online, please do an Nmap scan of your IP.

For example:
`nmap -sS 0.0.0.0`

Stay safe!

[AbuseIPDB - Riverside Rocks](https://www.abuseipdb.com/user/47625)

[My Website](https://riverside.rocks)
Docker connect with ReactJs Application
Published: 2020-11-09 22:10:41

1. sudo docker build -t aliendev66: frontend-invite.
2. sudo docker run -p 3000: 3000 -d aliendev66: frontend-invite
3. sudo docker ps

If you happen to restart your PC, run sudo docker start and the name of the image
To see all the created containers is: sudo docker ps -a

## Dockerfile

# Source Image

FROM node: 13-alpine

# Working directory (this is where the application will be inside the container).

WORKDIR / usr / app

COPY package * .json ./

# Adding `/ app / node_modules / .bin` to $ PATH

ENV PATH node_modules / .bin: $ PATH

# Installing application dependencies and caching.

# COPY package.json package.json

# RUN yarn add --silent

COPY. .

EXPOSE 3000

RUN yarn add react-scripts -g --silent

# start app

CMD ["yarn", "start"]
Why choose a mechanical keyboard
Published: 2020-11-09 22:08:09

The first factor that must be taken into account are the switches:

Switches are small pieces that register each time the key is pressed, transmitting an electric pulse and then signing the key.

This process is much faster than using the conventional membrane keyboards that use sheets with lines of contact contacts are superimposed and small layers of membranes with metallic contacts on the inner side come into contact with these sheets when pressing each key.

The switches also gain other aspects such as speed of responses and so on.

They are the main ways of choosing a mechanical keyboard.
# BLUE (TACTILE) switches.

Two types of tactile feedback - it is the most recommended for those who play and who type a lot. But it is a bad choice for those who type close to other users because it is very noisy.

# BROWN (TACTILE) switches.

Second choice for easy adaptation, it is quieter than blue, but still maintaining the standard of a traditional mechanical mechanical keyboard.

# RED (LINEAR) switches.

These are for specific types of users. These do not have any type of feedback, and are differentiated by the spring tension and the activation distance.

There are more types of switches, which I will explain in another post.
Multi-line string literals
Tags: lua, python, ocaml
Published: 2020-11-09 21:52:47

## Python

I suppose most people know that Python allows writing multi-line string literals in triple quotes. This feature relatively hard to miss because it's used in docstrings.

```python
def hello():
  """ Prints a greeting """
  print("hello world")
```

Using it for variables is also common.

```python
s = '''
hello
world
'''

print(s)
```

All in all, it's an easily discoverable feature.

## Lua

It's less widely known that Lua supports multi-line strings because it uses unusual delimiters: double square brackets.

```lua
s = [[
hello
world
]]

print(s)
```
Let's see if it works:

```
$ lua ./test.lua 
hello
world

```

Once you remember the delimiter, it's not harder to use than Python's triple quotes.

This syntax is also used by the [TOML](https://github.com/toml-lang/toml) serialization format.

## OCaml

OCaml's approach is the easiest of all. However, it's also the least easily _discoverable_.

To write a multi-line string, you... need not do anything special. You can use add line breaks to normal strings and the lexer will understand them.

```ocaml
let s = "
hello
world
"

let () = Printf.printf "%s" s
```

Let's test it:

```
 ocamlopt -o test ./test.ml 

$ ./test 

hello
world

```
Check Telescope posts' availability
Tags: opensource
Published: 2020-11-09 18:07:34

### Introduction
This week, I was assigned to add a new feature to check if a post from Telescope is available for my link checker CLI. Before digging any deeper, I would like to introduce a bit about [Telescope](https://telescope.cdot.systems/). 

It enables us to keep track of students' work through blog posts written by Seneca College students. By fetching data from multiple blogging sites such as Medium, Dev, WordPress,.. all blog posts of students will be automatically updated to the website whenever a new post is published.

### Set up the environment to work with Telescope.
To run Telescope locally, it asks us to put extra effort into setting up an appropriate environment. I am required to install WSL2, Redis, Elasticsearch, and Docker before starting the work. This is probably the most challenging part of the assignment this week. Therefore, I did counter some troubles while setting up the environment.

Elasticsearch not running after installation could be a thing. I had to make some diagnoses and realized my JDK was not compatible. It took me a considerable amount of time to fix it. Or I got trouble while installing the Linux subsystem since my disk was low in storage. However, these problems could be solved by doing research on Google. The point is you have to be resilient enough.

### Coding part
The coding part doesn't require a lot of work. I created an API handler that manages to make a GET request to the local Telescope API, and I check the availability of each URL response by the API.

```
const telescopeCheck = (api) => {
    axios.get(api)
    .then(response => {
        console.log("CONNECT TO TELESCOPE SUCCESSFULLY!!!");
        console.log("====================================")

        for (i = 0; i < response.data.length; i++)
        {
            checkURL(api+`/${response.data[i].id}`);
        }
    })
    .catch(err => console.log("Cannot connect to local API, please double check to make sure the API is initiated!!!"))
}
```

### Gist it done
Gist is a quick and instant tool that enables us to share code snippets without unnecessary work. To get technical notes between two commits, we simply use the command `git diff old_commit...new_commit`.

I am still not satisfied with the code snippets above. Therefore, any recommendation will be welcome. Thank you for spending your time reading my blog.
Python Zero to Hero - Ep.26 - Continue exploring Django
Tags: python, django, tutorial, beginners
Published: 2020-11-09 21:37:39

---
title: Python Zero to Hero - Ep.26 - Continue exploring Django
published: true
description: Following last week, we continue with our Django exploration journey.
tags: python, django, tutorial, beginner
---
Following last week, we continue with our Django exploration journey. If you have any questions or any suggestions about which Python topics to cover, please leave your comment at my [Twitch channel](https://www.twitch.tv/cheukting_ho)

You can get the slide deck [here](https://slides.com/cheukting_ho) and the example code and homework form [GitHub here](https://github.com/Cheukting/python02hero). Ask questions at my [Twitch channel](https://www.twitch.tv/cheukting_ho)