teleren/devto huggingface dataset:
Running Sapper on shared hosting
Tags: svelte, sapper
Published: 2020-04-23 07:28:25

This is a short way to publish your Sapper app to shared hosting that has node.js. This post is solution for the hosting that I've been using, but maybe it can transfer to some other shared hosting sites.

My assumption is:
1. Your host gives you shell (ssh) access.
2. You have dedicated folder ie. `public_nodejs` where you hosting forces you to put the node.js apps.
3. You host forces you to use `app.js` as start point for your application.

I'm assuming you are one folder above the `public_nodejs`. ``--force`` because we want to clone the repo into the directory that already exists.
```bash
cd public_nodejs
npx degit "sveltejs/sapper-template#rollup" --force
npm install
npm run build
```


Create `app.js` and upload, or just use nano
```javascript
require("./__sapper__/build/index.js");
```

Voila, your application works.

PS. Wanted to throw it in a post, so if someone else will struggle with this they have a simple solution.
Does conversational AI work for Enterprises and can they automate vital engagement processes?
Tags: artificialintelliigence, machinelearning, iot, python
Published: 2020-04-23 07:21:14

Recently we saw screenshot that became viral and thought it was free PR to the concerned organization but it might have done some damage to bots and sure they may be heading to file some defamation suit in some courts. 

Now the story, this organization is into financial services providing payment services. In the screenshot, the bot greets the users to ask a question and the user responds with a message that “I got scammed” and the bot responds with message ‘Great!’

The automated responses may turn weird at times and it may hurt the user more than the actual pain that made him to get in touch via the support portal.  
The virtual assistants can help in avoiding human interactions with instant responses and they are available 24/7. The caveat is on picking right processes that can be enabled with conversational AI via bots. 

1) As a start, Bots work without hassles with closed end options, like cancelling an order or track where the shipment currently etc. and further issues can be escalated to human intervention

2) It helps in managing enterprise stakeholders and smart workforce management via tools to update vacations, book conference rooms, and record expenses, get policy guideline clarifications etc. 

3) The bots also work well for enhancing process efficiency by answering questions based on pre-loaded intelligence like getting clarifications around legal documents, policies, safety guidelines, etc. 

4) Bots also do a wonderful job in answering information around processed data, like a quick glimpse of financials, sales figures, competitor information, and equity updates etc. and can be a wonderful assistant to CXOs. 

5) The major places not to leverage bots is around areas constrained by languages, emergency updates/clarifications, and emotionally sensitive areas. 

The best way gets start with Bot implementation: 

At OptiSol, we have center of excellence focused on AI and ML services and as part of that practice, we have built voice and text bots across verticals. We offer PoC development to evaluate the offering and our team of AI and ML engineers along with bot textual experts can assist in this part of digitization strategy.
Is anyone really using SASS anymore?
Tags: productivity, css, discuss
Published: 2020-04-23 07:09:17

OK, bit of a hot title, of course people are, hell I'm still using it. But, I had a question from a mentee the other day about 'what is SASS?' and 'what is the difference between SASS and CSS?'. 

Of course, I answered those, but it got me thinking about the relevance of SASS in today's front end workflow and tooling...

CSS itself has given us native solutions to some of the problems SASS originally solved (e.g. variables), and we've got so many options for development these days with Styled Components in React, Tailwind CSS, CSS-in-JS, etc. and dynamic imports are coming in JS. 

So my questions are this:

- Do you think SASS is losing relevance or usefulness in today's landscape?
- Are you still using it? Why? Why not?
- What other tools do you prefer or have started adopting in SASS's place?
- Do you have any tips, tricks or advice on being productive with modern CSS?
Asynchronous processing of data in Expressjs
Tags: help, node, express
Published: 2020-04-23 06:57:39

I've an Express route which receives some data and process it, then insert into mongo (using mongoose).

This is working well if I return a response after the following steps are done:

- Receive request
- Process the request data
- Insert the processed data into Mongo
- Return 204 response

But client will be calling this API concurrently for millions of records. Hence the requirement is not to block the client for processing the data. Hence I made a small change in the code:

- Receive request
- Return response immediately with 204
- Process the requested data
- Insert the processed data into Mongo

The above is working fine for the first few requests (say 1000s), after that client is getting `socket exception: connection reset peer` error. I guess it is because server is blocking the connection as the port is not free and at some point of time, I notice my nodejs process is throwing out `Out of memory` error.

Sample code is as follows:

```js
async function enqueue(data) {
    // 1. Process the data
    // 2. Insert the data in mongo
}

async function expressController(request, response) {
    logger.info('received request')
    response.status(204).send()

    try {
        await enqueue(request.body)
    } catch (err) {
        throw new Error(err)
    }
}

```

Am I doing something wrong here?
How to link Custom Domain with URL ?
Tags: help, node, webdev
Published: 2020-04-23 06:23:24

Hi, 
I am developing a service like Wix.com, Squarespace etc., using NodeJs
Can someone help me understand how they link custom domain name with the users website ?

Eg: A user owns a domain examplewebsite.in . Now he creates a website in Wix.com and links his domain to the website. How is the linking happening here ?

Thanks in advance
Algorithms Day 2- Naive String Search
Tags: algorithms, javascript, naivesearch, computerscience
Published: 2020-04-23 06:16:14

This algorithm works if you wanna search a smaller string inside a longer string. And they'll return the no of occurrences of that small string.


**Naive Search - Pseudocode**

+ Create a function that accepts a long string and a shorter string

+ Loop over the longer string. Inside that, we should loop over the smaller string.

+ If the string characters don't match we should break out from the inner loop

+ If the string matches we need to continue the loop for the rest of the smaller string

+ If the match was found we should increment the no of matches

+ Finally, we need to return the count.

+ The code is mentioned below


{% gist https://gist.github.com/DashingDaniel/72f70a446d5a47b3afca3d8f0a76f640 %}

Thanks for reading. Hope you'll find it useful
The path of a young samurai
Tags: webdev, node, javascript, beginners
Published: 2020-04-23 05:36:02

Yesterday I started to study node.js. Thanks to the YouTube channel "The Net Ninja" for lessons for beginners. I want to get knowledge in web development and make some kind of test project for portfolio. At the moment, I only know basic things, such as HTML, CSS, JavaScript. Also studied the preprocessor "SASS" and studied CSS Grid + CSS Flex-Box. After that I want to study the react.js, what do you think about this?

What tips can you give a beginner, which modules do you recommend studying for a start, and what projects should I try?
Covid19 India Update | Twilio x Dev Hackathon Submission
Tags: twiliohackathon, node, javascript, webdev
Published: 2020-04-23 05:00:33

## What I built
A covid19 case updates webapp. Basically, user registers on this website with their name, phone number and their state(limited to Indian states only) and then they receive covid19 case updates daily twice a day. This webapp helps user to be aware of total cases in their state as well as new cases of the day. I've used an external API to get the data of covid19 cases and using Twilio Programmable SMS API, it sends the daily updates to the users.

#### Category Submission: 
Interesting Integration: I integrated an [external api](api.covid19india.org) to get the data of covid19 cases in India.

Other Use Cases: [GRE](https://www.ets.org/gre/) Words Of The Day(Sending 5 words daily to user to learn new GRE Words),
Appointment Reminder Using Google Calendar API integrated with Twilio SMS API.

## Demo Link
[Covid 19 India Updates](https://covid19updates-india.herokuapp.com/)

Here is the sample message that user receives when they register successfully on the app.
![Registered Successfully](https://dev-to-uploads.s3.amazonaws.com/i/ojlcdyiwxesjyhm5q998.jpg)

Here is a sample message of case updates that user receives daily.
![SMS Updates](https://dev-to-uploads.s3.amazonaws.com/i/sn4sisxrbsl7e7z9xggk.jpg)

## Link to Code
Here is a github repo of the project.
{% github https://github.com/jamesshah/Covid19-Updates no-readme %}

## How I built it (what's the stack? did I run into issues or discover something new along the way?)
* Node.JS
* Express Framework
* MongoDB Databse
* Twilio Programmable SMS API

I wanted to take this hackathon as opportunity to learn something new and that's what I did. I learned Node.JS & Express to build the website and also learned MongoDB(NoSQL) for the Databse. Although I've been using Javascript for sometime but building a fully functional web app taught many many things that the tutorial and videos didn't.


## Additional Resources/Info

I've documented the whole journey of building this project from scratch in 4 post blog series. You can check it out here.
{% post https://dev.to/jamesshah/building-a-node-js-express-app-covid19-updates-part-1-4pg1 %}

It's been a great experience participating in this hackathon and building a project from an idea to the application. Hope you like it.
#####HappyCoding
Daily Challenge #231 - Perfect Powers
Tags: challenge
Published: 2020-04-22 13:39:07

---
title: Daily Challenge #231 - Perfect Powers
published: true
series: Daily Challenge
description: What is a perfect power anyways?
tags: challenge
---
A perfect power is a classification of positive integers:

In mathematics, a perfect power is a positive integer that can be expressed as an integer power of another positive integer. More formally, `n` is a perfect power if there exist natural numbers `m > 1`, and `k > 1` such that `mk = n`.

Your task is to check whether a given integer is a perfect power. If it is a perfect power, return a pair `m` and `k` with `mk = n` as a proof. Otherwise return `Nothing, Nil, null, NULL, None` or your language's equivalent.

Note: For a perfect power, there might be several pairs. For example `81 = 3^4 = 9^2`, so `(3,4)` and `(9,2)` are valid solutions. If a number is a perfect power, return any pair that proves it.

####Examples
`isPP(4)` => `[2,2]`
`isPP(9)` => `[3,2]`
`isPP(5)` => `None`

####Tests
`isPP(4)`
`isPP(8)`
`isPP(14)`

Good luck!
***
_This [challenge](https://www.codewars.com/kata/54d4c8b08776e4ad92000835) comes from bkaes 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!_
ลง Xcode และ iOS simulators ผ่าน command-line เพื่อทำ script อัตโนมัติ
Tags: ios, automation
Published: 2020-04-23 04:24:09

# xcode-install

รอบนี้เราจะมารู้จักเครื่องมือตัวนึงเป็น gem (โปรแกรมที่เขียนด้วยภาษา Ruby) สำหรับใครยังใช้ sudo gem อยู่แนะนำให้อ่าน "[เราไม่ควรใช้ sudo gem](https://medium.com/odds-team/เราไม่ควรใช้-sudo-gem-e1c37a0a02e4)" ก่อนนะครับ

## ติดตั้ง

```shell
[sudo] gem install xcode-install
```

ซึ่งระหว่างใช้งานอาจจะมีการถาม username, password ของ Apple Developer Account ด้วย ซึ่งสามารถตั้ง environment variables ได้จาก `XCODE_INSTALL_USER` และ `XCODE_INSTALL_PASSWORD` ตามลำดับ หรือ login ผ่าน command line ก็ได้ ถ้าใครเปิด Multi-Factor authen สามารถสร้าง app password เพื่อใช้แทนรหัสผ่านจริงได้

## คำสั่งพื้นฐาน สำหรับ Xcode

คำสั่งที่เราจะได้คือ `xcversion` ไม่ใช่ `xcode-install` นะ

- `xcversion update` มันจะไปตรวจที่ [developer.apple.com/downloads](https://developer.apple.com/downloads) ว่ามีเวอร์ชั่นอะไรให้ดาวโหลดบ้าง บางครั้งใน AppStore จะใหม่กว่าหน้าเว็บนี้ เพราะฉะนั้น ถ้าไม่เจอเวอร์ชั่นใหม่ในวันแรก ๆ ก็ไม่แปลก
- `xcversion install <version>` ไว้ติดตั้ง Xcode เวอร์ชั่นที่กำหนด
- `xcversion select <version>` เลือกเวอร์ชั่นที่ต้องการ ใช้แทน `sudo xcode-select -s <Xcode Path>`
- `xcversion select <version> --symlink` เพื่อให้ `xcode-install` เลือกเวอร์ชั่นและตั้ง link ไว้ที่ `/Application/Xcode.app` ให้
- `xcversion selected` ไว้ดูว่าใช้ Xcodeเวอร์ชั่นใด build ไหน ใช้แทนคำสั่ง `/usr/bin/xcodebuild -version`
- `xcversion uninstall <version>` ไว้ลบเวอร์ชั่นที่ไม่ใช้ทิ้ง

## คำสั่งพื้นฐานสำหรับ iOS simulators

นอกจากจะดาวโหลด Xcode ได้แล้วยังสามารถดาวโหลด iOS simulators ได้ด้วย

- `xcversion simulators` ไว้ดูว่าตอนนี้มี versions อะไรบ้าง และสามารถติดตั้ง versions อะไรได้บ้าง ทั้ง iOS, tvOS, watchOS
- `xcversion simulators --install=<ชื่อ simulator>` เช่น `xcversion simulators --install="iOS 12.4"` เพื่อติดตั้ง simulatorเวอร์ชั่นที่กำหนด

## ดูเพิ่มเติม

- `xcversion [command] --help` จะช่วยให้เราดูได้ว่า สามารถใช้คำสั่งอะไรได้บ้าง และแต่ละคำสั่งคืออะไร

## สรุป

เท่าที่ใช้งานก็สามารถใช้งานได้ดี เหมาะที่จะไปตั้งเป็นชุดคำสั่ง สำหรับคนที่เพิ่งติดตั้งเครื่องใหม่ได้ แต่เหมือนกับ internet ประเทศไทยจะไม่ค่อยเป็นมิตรกับเว็บ https://developer.apple.com/downloads เท่าไหร่ ซึ่งถ้าใช้เวลานานเกินไป อาจจะโหลดไม่สำเร็จได้

ถ้าเราโหลดจากเว็บ เราจะได้ `.xip` ซึ่งทำให้ copy ไปลงเครื่องอื่นได้ด้วย กรณีอินเตอร์เน็ตช้า แต่ถ้าติดตั้งผ่าน `xcode-install` จะไม่มี `.xip` ให้ก็อปไปเครื่องอื่น

ถ้าจะก็อป `.xip` ไปที่เครื่องอื่น แนะนำให้ใช้ USB Storage แทน AirDrop เพราะถ้าไฟล์ใหญ่มาก ๆ มักจะโอนผ่าน AirDrop ไม่ค่อยสำเร็จ

เหมือนเดิม ตอนนี้ก็ยังมองหางานอยู่ สนใจอยากได้ผมไปทำงานด้วยติดต่อมาได้เลยนะครับ
Airflow UI with Role-Based Access Control
Tags: python, apacheairflow, dataengineering
Published: 2020-04-23 04:17:07

This is the continuation to the previous article on the [Apache Airflow Installation](https://dev.to/citizenkot/apache-airflow-installation-mysql-celery-4n76)

To set up the Access control on the Airflow UI:

a. Update the Configuration file 
airflow.cfg file (should be available in ~/airflow/ directory) with the below entry. 

 **rbac = True**

b. run the below on your terminal

**airflow**

*the above step will create webserver_config.py file in your $AIRFLOW_HOME location.*

*most probably, you do not have to make any changes to the webserver_config.py file. If you want to make changes, please refer [Authentication section of FAB docs](http://flask-appbuilder.readthedocs.io/en/latest/security.html#authentication-methods).*

Now, run the below commands on the terminal

c. run **airflow initdb**
d. run **airflow create_user -r 'admin' -u '<uid>' -e '<email id>' -f '<firstname>' -l '<lastname>'**

e. now this will prompt you to enter the password for the user.

Start/Restart the airflow webserver, scheduler, worker.

tattadaa...

Launch the airflow UI url, you will see the Login Screen!
Vim to the rescue: Prologue
Tags: vim, tutorial, productivity, discuss
Published: 2020-04-23 04:16:24


<img src="https://dev-to-uploads.s3.amazonaws.com/i/emm29sdlf03xxvadfxq6.png" width=40% />


> Productivity is measured not just in terms of how fast you can get a task done, but how efficiently can you take it to completion. 

Vim is a text editor focused at keeping you away from the mouse. I started using vim a while back. Here is a reference to [my experience with vim](https://medium.com/gdg-vit/editor-almighty-79807100f10c). 

No matter how much you "think" you know vim, it always has a tendency to surprise you. That is why I decided to do a series called **Vim to the rescue**, where I take some day-to-day text editing / programming redundancy problems that can be solved using vim. This series is not meant to get you started with vim, but to give you an idea of how powerful vim can be and how it can be used to solve very practical problems. 

To start off with, here is a link to my dotfiles. The following repository contains my vim configuration and some of the awesome plugins that I use. I am sure this repo will help you, one way or the other :)

{% github L04DB4L4NC3R/DEC %}

Now if you do want to get started with vim, the following are some resources which I used:

* [Vimtutor](http://www2.geog.ucl.ac.uk/~plewis/teaching/unix/vimtutor)
* [Vim cheat sheet](https://devhints.io/vim)
* [Let vim do the typing](https://www.youtube.com/watch?v=3TX3kV3TICU&t=70s)
* [Learn vimscript the hard way](https://learnvimscriptthehardway.stevelosh.com/)
* [How to Do 90% of What Plugins Do (With Just Vim)](https://www.youtube.com/watch?v=XA2WjJbmmoM&t=1728s)
* [Vim Macros](https://sanctum.geek.nz/arabesque/advanced-vim-macros/)

Let me know some of the problems you might have faced in the past and how vim made it easy.
4 Gitcoin Hackathons Live Now With $90k in Prizes!
Tags: blockchain, ethereum, hackathon, opensource
Published: 2020-04-23 03:50:32

For the hungry devs out there, Gitcoin hackathons currently have almost **$90k** in prizes up for grabs between 4 events, the most they’ve ever had!



*   The [Cross-Chain Virtual Hackathon](https://gitcoin.co/hackathon/cross-chain/?tab=hackathon:16) includes Cosmos, Agoric, and Band Protocol, with **$25k** worth of prizes in the 3 week event. Check out this [blog post](https://gitcoin.co/blog/cosmos-cross-chain-hackathon/) for more information on Cosmos and their [$15k challenge](https://gitcoin.co/issue/cosmos/ics/408/4212).
*   Harmony's [Stake-Heist Hackathon](https://gitcoin.co/hackathon/stake-heist/?tab=hackathon:18) features **$40k** in ONEs for bug bounties and more creative project bounties. More details in [this blog post](https://medium.com/harmony-one/stake-heist-is-finally-here-launching-on-april-17th-at-noon-pt-and-running-for-two-weeks-in-801340b78a09) and you can check out the [prizes here](https://gitcoin.co/hackathon/stake-heist/?tab=hackathon:18)!
*   ConsenSys Health's [Stop COVID-19 Hackathon](https://gitcoin.co/hackathon/stop-covid/prizes/?tab=hackathon:19) has a **$20k** prize along with plenty of mentoring, webinars and workshops from experts in healthcare and technology.
*   Finally, [LongHash Ventures' Blockchain for Good Hackathon](https://gitcoin.co/hackathon/longhash/?tab=hackathon:21) has **$5k** in prizes with the same goal of building impactful solutions for social good to battle COVID. Learn more on the [landing page](https://www.longhashventures.com/hack/), and sign up to hack on the [prize explorer](https://gitcoin.co/hackathon/longhash/?tab=hackathon:21). If you are working on a COVID-19 or public health related project, **consider applying to both hackathons!**

As always make sure to check the [Hackathon List page](https://gitcoin.co/hackathon-list) for updates on ongoing and future events. Join us on the [Townsquare](https://gitcoin.co/) and in [Gitcoin Chat](https://gitcoin.co/chat) to interact with other hackers, the Gitcoin team, and sponsors. Register for events to get calendar invites for sponsor workshops, and check out our [Youtube Page](https://www.youtube.com/channel/UCeKRqRjzSzq5yP-zUPwc6_w) for past workshop recordings!

We hope you join us in one or many of the current hackathons!

~Connor and the Gitcoin Team
Javascript Notes, Part-03 - Closures
Tags: javascript, beginners, tutorial, webdev
Published: 2020-04-23 03:10:02

YOU CAN RETURN A FUNCTION FROM A FUNCTION!

This is possible because functions are first-class objects.

```javascript
function createFunction() {
 function multiplyBy2 (num){
 return num*2;
 }
 return multiplyBy2;
}
const generatedFunc = createFunction();
const result = generatedFunc(3); // 6
```
Returning a function, storing it in a variable(sorry, I mean const) and invoking the returned function from outside where it is defined. Well, Looks great!!

But wait! what if our returned function is using data of its parent function? Look at the below example.

```javascript
function outer (){
 let counter = 0;
 function incrementCounter (){ counter ++; }
 return incrementCounter;
}
const myNewFunction = outer();
myNewFunction();
myNewFunction();
```

Here, when our returned function is invoked we try to access a variable that is already dead! I mean, trying to access a variable from a function that already got executed, popped out of call stack, and whose local memory is cleared. There is no way of accessing that variable right?

But, this is JS! anything can happen, lol.
Okay! let's understand what is happening.

**Attention!**  *When a function is returned a datastore is created if the outer function has any data which is being referenced by inner function(returned fn). This datastore is called closure. I usually call it a backpack*

**One more time:** *A closure is a combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function's scope from an inner function.*[MDN]

Note that the data inside a closure is persistent and referred.

One more takeaway! See below example:

```javascript
function outer (){
 let counter = 0;
 function incrementCounter (){
 counter ++;
 }
 return incrementCounter;
}
const myNewFunction = outer();
myNewFunction();
myNewFunction();

const anotherFunction = outer();
anotherFunction();
anotherFunction();
```

Here we create two different backpacks(closures) for two variables myNewFunction and anotherFunction. This happens because we have two different execution contexts while assigning returned functions to variables.

Application of closures: Asynchronous JS, Iterators and generators, and many more.
Basic Multithreaded Ping in Rust
Tags: rust, showdev, sideprojects
Published: 2020-04-23 03:01:29

Recently, I finished writing a ping program with Rust. Basically, the program sends ICMP echo packets on one thread, and receives response packets on the other thread. Each packet keeps track of information such as process id, timestamp, etc. so we know whether our program sent the packet and we can calculate statistics like the round-trip time. The code is well-commented, and I hope that this can be a learning resource for others, since I learned a lot about both Rust and network programming when doing this project.

Link to the Github repo: [here](https://github.com/Daniel-Liu-c0deb0t/9S)

Here is a picture of the result:
![Ping result](https://dev-to-uploads.s3.amazonaws.com/i/x73tlh534cpo0qza4yx0.png)