teleren/devto huggingface dataset:
COPY to the clipboard in JS
Tags: javascript, tutorial, webdev, vue
Published: 2020-04-08 13:18:51

To set a textContent to the clipboard, you should get the desired element from DOM (_eg. document.getElementById(“element-id”)_) and access to its content:
![alt text](https://miro.medium.com/max/1400/1*A5esgEQ_sv5HO2426lMR1w.png "CodePic1")
then you should set your text to the clipboard :
![alt text](https://miro.medium.com/max/1400/1*dP-f2XcW2Av8kcJINqLXYg.png "CodePic1")
and when this function is executed, it’s done…!

>If you found it useful, you can follow me and also visit my [website](http://mohsenfallah.ir), because there are more ways to connect with me. I hope this would help you to improve your coding skills. Thank you for your attention.
___
_This article was originally published on The [Dev.to](https://dev.to/mohsenfallahnjd) on April 8, 2020 and was written by **Mohsen Fallahnejad**._
Introduction to Python Programming Basics(Part 1)
Tags: python, beginners, tutorial
Published: 2020-04-08 13:18:48

<h3>Variables</h3>

<blockquote>A variable is a container for a value and it can be of various data types.</blockquote>

<h4>Variable Rules</h4>

<ul>
	<li>Variable names are case sensitive</li>
	<li>Variable names must start with a letter or underscore</li>
	<li>Variables can have numbers but cannot start with numbers</li>
</ul>

<h4>Data Types&nbsp;</h4>

<p>int &mdash;  for numericals</p>

<p>string &mdash; for alphanumericals</p>

<p>float &mdash; for numerics with decimal points</p>

<p>boolean &mdash; true or false&nbsp;</p>


{% gist https://gist.github.com/cartel360/48b465e6598d750b49b02c6fcee42daf.js %}


<h3>Strings</h3>

<blockquote>Strings in python can be written with either single or double quotes&nbsp;</blockquote>



<h3>Lists</h3>

<blockquote>A list is a collection which is ordered and can be changed.</blockquote>

<blockquote>A list also allows duplicate members.</blockquote>

<p>To create a list we usually use square brackets or we can use a constructor as shown below;</p>
{% gist https://gist.github.com/cartel360/a06624b92528b5fc4488dc8c62f67bd6.js %}


<h3>Tuples</h3>

<blockquote>A tuple is a collection which is ordered and cannot be changed.</blockquote>

<blockquote>A tuple also allows duplicate members.</blockquote>

<p>In creating tuples we use parenthesis</p>

{% gist https://gist.github.com/cartel360/33493cde86dd7bc1b2a8250a7f4658a8.js %}



<h3>Sets</h3>

<blockquote>A set is a collection which is unordered and unindexed which means when I print a set now it won&rsquo;t be in the same when i print it again.</blockquote>

<blockquote>A set doesn&rsquo;t allow duplicate members</blockquote>
{% gist https://gist.github.com/cartel360/74d8f17316810d2c88b08779c95e3aa0.js %}

<h3>Dictionaries&nbsp;</h3>

<blockquote>A dictionary is a collection which is unordered, indexed and changeable.</blockquote>

<blockquote>A dictionary doesn&rsquo;t allow duplicate members.</blockquote>
{% gist https://gist.github.com/cartel360/04fbc454345ce73d5fb121ff5340a962.js %}

<h3>Functions</h3>

<blockquote>A function is a block of code which executes upon calling&nbsp;</blockquote>

<blockquote>Python is very sensitive to indentions and thus in creating functions, we make use of&nbsp;indents.</blockquote>

<p>In creating functions we use the def keyword, as shown below</p>
{% gist https://gist.github.com/cartel360/3ea6598cc58ea8299b3cb5fa66ca78d4.js %}

<p>&nbsp;</p>

<p>That&rsquo;s all for now, I&rsquo;ll be posting a continuation on this later on.</p>
Why do programmers say when they use tmux, their productivity shoot up the roof?
Tags: tmux, discuss, question
Published: 2020-04-08 13:18:31

Isn't `tmux` just a tool so that when you get disconnected, you still can come back to the process or command you were running, such as a Rails or Django server?

That's it?  How come then people say when they have `tmux`, it is like their productivity has shot up the roof?

If they start a day's work and the `ssh` never disconnected, isn't it all the same?
When did you start to learn productivity-boosting techniques and development tools? 🧰⏩
Tags: webdev, productivity, discuss, healthydebate
Published: 2020-04-08 13:18:16

Maybe you are familiar with the [Web Developer Roadmap](https://github.com/kamranahmedse/developer-roadmap)? 

{% post https://dev.to/javinpaul/the-2019-web-development-frontend-backend-roadmap-4le2 %}

It's well thought out. One thing that I noticed that is not included is development tools and productivity techniques. Things like: using a linter, Browser Sync/Live Preview, using a particular IDE with extensions, Emmet, debugging with Dev Tools, bash scripts, and so on. 

When I learned HTML in University, my teacher had us use notepad, and he warned us not to use an IDE to make our website submission, "he'd know", he told us! The attitude was minimal tools.

My friend began learning web development recently and she began with Atom. I don't know which is a better path overall, but I know I would have liked to be introduced to some of these things by someone else relatively early in my learning path. 

What do you think?
Tutorial: How to Write Web Form Data to MySQL Databases
Tags: tutorial, database, mysql
Published: 2020-04-08 13:15:46

Want to try out a simpler way to write your form data to your own systems? This tutorial uses WayScript, a new developer friendly platform we are building. Check it out for free on our website.  

##Introduction
Data collection forms work well in theory. You send a form out, gather data, and that data is written to some applications storage for you to retrieve it. What if you need to write form data to your own systems? WayScript provides a way for you to create forms, gather data, and write them to your own internal storage systems and databases. Whether these are Airtable bases, Google Sheets, or SQL based databases, we make it easy. In this tutorial, let's take a look at how we can create web forms, and connect them to your own database.

##Creating your Web Form
To create a web form which can be accessed at it's own url, we can use a form trigger to provide us this. We're able to customize the questions, selections, and more. This will be the head of our workflow.

![Form Trigger](https://cdn.wayscript.com/blog_img/72/1.png)

We're able to customize the form's questions with the settings on the left. In this example, let's set up just a few questions. Let's say we're making an employee workplace accident form:
![Example Form](https://cdn.wayscript.com/blog_img/72/2.png)

We could add as many fields and customization as we would like here. This form will be accessable at the provided url. If you would like to fill out the form we're making making in this example, you can find it [here](https://17033.wayscript.io/).

##Writing our Form Data to a Database
Once we collect the form data, it will be available to us on WayScript to process it as we want. To connect a database and write to it, we need to drag in an SQL module under our form trigger.

![Form Trigger](https://cdn.wayscript.com/blog_img/72/3.png)

After placing this module, we'll just need a little bit of code to write to the connected database:

![Form Trigger](https://cdn.wayscript.com/blog_img/72/4.png)

And just like that, we're writing form data to your database! Of course, the possibilities with WayScript are limitless and we could do more processing on this data. But hopefully this shows you how to start writing data to your own database with WayScript!
Learn Python in 90 seconds!
Tags: python, joke
Published: 2020-04-08 13:02:28

---
title: Learn Python in 90 seconds!
published: true
description: practical joke site that I made
tags: python, joke
---
It's quarantine days and everybody is doing something useful. I'm no different than the super cool people out there: I made the best tutorial for learning python on the Internet(s). The best part? It takes you 90 seconds to complete and after it you'll be fluent in python!

Intrigued? Let's go then: [pythonin90sec.com](https://www.pythonin90sec.com/)


Yes, it's a joke. Till next time. 

![speaking python](https://dev-to-uploads.s3.amazonaws.com/i/n7ymil5olcq5f745g72s.gif)
Debounce Any Effect by Creating Your Own useDebouncedEffect Hook
Tags: react, hooks, javascript, webdev
Published: 2020-04-08 12:53:00

---
title: Debounce Any Effect by Creating Your Own useDebouncedEffect Hook
published: true
description: In this post, we'll write a custom React hook that debounces any effect!
tags: react, hooks, javascript, webdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/9u5jq9dewkzdqufpwb9v.gif
---

Often, we want to wait until our user finishes an action to execute an asynchronous effect. A great example of this is executing a search after a user finishes typing rather than doing so on each key stroke. This prevents us from jarring UI changes or firing many unnecessary and potentially expensive fetch requests.

In this post, we'll write a custom React hook that debounces any effect!

# Writing Our Hook

Our hook should look just like a `useEffect` hook, with the exception that it should take an additional `time` parameter for the amount of time we want to debounce for. Therefore, the parameters should be:

- The effect function
- The dependency array
- The debounce time

## Achieving the debounce behavior

To debounce, we'll use a `setTimeout` with the user-provided `time`. The catch is that, if our effect re-runs before the timeout executes, we'll want to cancel the timeout and start a new one. We can accomplish that by using a cleanup function with `clearTimeout`. Our hook, therefore, is as follows:

```jsx
import { useEffect } from "react";

function useDebouncedEffect(fn, deps, time) {
  const dependencies = [...deps, fn, time] 
  useEffect(() => {
    const timeout = setTimeout(fn, time);
    return () => {
      clearTimeout(timeout);
    }
  }, dependencies);
}
```

# Seeing the Hook in Action

In this example, we'll simply set some state on a debounced delay based on when a user stops typing in a textbox. Here's the code!

```jsx
function App() {
  const [text, setText] = useState("")
  const [debounced, setDebounced] = useState("")

  useDebouncedEffect(() => {
    setDebounced(text);
  }, [text], 1000)

  return (
    <div className="App">
      <input onChange={e => {
          setText(e.target.value)
        }} value={text} 
      />
      <p>{debounced}</p>
    </div>
  );
}
```

And when we try it in action... it works!

![Text being debounced](https://dev-to-uploads.s3.amazonaws.com/i/9u5jq9dewkzdqufpwb9v.gif)
Daily Challenge #221 - The Merchant of York
Tags: challenge
Published: 2020-04-08 12:29:24

---
title: Daily Challenge #221 - The Merchant of York
published: true
series: Daily Challenge
description: Implement a function to solve Alcuin of York's math problem.
tags: challenge
---
Alcuin of York was an English clergyman and scholar who wrote, among other things, recreational mathematical problems.

One of them goes as follows: A merchant wanted to buy 100 pigs for 100 pence. He told his servant to go and buy them, paying 10 pence for a boar, 5 pence for a sow and 1 penny for two piglets. He also told him to buy at least one of each. How many boars, sows, and piglets must there have been for him to have paid exactly 100 pence for the 100 animals?

In this challenge, you are going to create a function `buyPigs` that takes two arguments.
- `amount`: both the amount of money to buy animals and the number of animals that must be bought.
- `specs` an object indicating how much the merchant is willing to pay for each kind of animal. It will always have the following structure:
  <pre>
      boar: { price: Number, qty: Number },
      sow: { price: Number, qty: Number },
      piglet: { price: Number, qty: Number },
  </pre>

The function will find a combination of pigs such that:
- There is at least one of each kind of pig
- The amount of pigs equals the amount of pennies
It will return an object indicating the amount of pigs of each kind that the servant bought.
If there is no way to solve it, it will instead return the object `{ error: 'Purchase not possible' }`
If there are more than one ways to resolve it, it only needs to return one.

Examples:
<pre>
const pigs = {
  boar: { price: 10, qty: 1 },
  sow: { price: 5, qty: 1 },
  piglet: { price: 1, qty: 2},
}

buyPigs(100, pigs) => { boar: 1, sow: 9, piglet: 90 }
buyPigs(150, pigs) => { error: 'Purchase not possible' }
buyPigs(300, pigs) => { boar: 3, sow: 27, piglet: 270 }
</pre>

<pre>
const pigs2 = {
  boar: { price: 5, qty: 1 },
  sow: { price: 1, qty: 1 },
  piglet: { price: 1, qty: 8 },
}

buyPigs(100, pigs2) => { boar: 7, sow: 61, piglet: 32 }
buyPigs(41, pigs2) => { boar: 7, sow: 2, piglets: 32 }
</pre>

Good luck!

***
_This challenge comes from [Savag​ePixie](https://dev.to/savagepixie) here on DEV. Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Daily Developer Jokes - Wednesday, Apr 8, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-04-08 12:00:29

---
title: "Daily Developer Jokes - Wednesday, Apr 8, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Wednesday%2C%20Apr%208%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259b29fe07.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ How do JavaScript developers break up?

___A:___ They always promise to callback
 -->
No more notifications, please
Tags: chrome, notifications, web, tips
Published: 2020-04-08 11:59:28

Someone, in some part, decided sometime that it would be nice for sites to notify users about 'something'. Nowadays, almost each site tries to notify you about something making navigation (at least for new visits and when you use incognito windows) painful: you have to say: 'no, I don't want your notifications'. 
In chrome/chromium you can stop this with (seen here: https://twitter.com/angelgavin/status/1247841130047307778 ):

`chrome://settings/content/notifications`

(Not sure if inserting tweets works here).

<blockquote class="twitter-tweet"><p lang="es" dir="ltr">Hasta las narices de que cada vez que visito un sitio web nuevo me pregunte si quiero recibir notificaciones.<br><br>¿A qué mente enferma se le ocurrió la idea?<br><br>En <a href="https://twitter.com/hashtag/Chrome?src=hash&amp;ref_src=twsrc%5Etfw">#Chrome</a>, por si os es de ayuda, se desactiva desde aquí --&gt; chrome://settings/content/notifications <a href="https://t.co/PRFzQYdntJ">pic.twitter.com/PRFzQYdntJ</a></p>&mdash; Ángel Gavín (@angelgavin) <a href="https://twitter.com/angelgavin/status/1247841130047307778?ref_src=twsrc%5Etfw">April 8, 2020</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
Newbie Problem - What to learn next?
Tags: webdev
Published: 2020-04-08 11:54:26

I know this only my second post and I wish I had done more but quite frankly I've been to lazy to finish and edit my previous drafts. They require a lot of mental effort and you'll see what I mean if and when I publish them. But now that COVID-19 has so graciously blessed us with its presence (saracasm) I've found more time to write these blogs.

With all this new found FREE time, my enthusiasm for learning is just growing as I find more courses and resources to improve my knowledge-base. However, discovering all these resources also made me realise that there is not enough time in the world to complete all of them so the questions becomes which ones do I pick. Do I select a group of courses and cycle through them or stick to one and master it? What should I learn first? Is it even worth learning ?

Look, I know that at some stage in my life - this year preferably - I want to be start coding in Java and or C++, but before I do that I want to get the hang of web development so that I can start freelancing and earn a little extra pocket money by doing a few gigs here and there (I am currently a University if you know what I mean). But this pursuit of money has begun to turn my quest to master web development feel like more of a chore. Honestly, it feels as though it is, if you compare it to machine learning, mobile development, networking, data science etc... 

So now I am torn between sticking with Javascript and its amazing frameworks or picking up an entire new language , Java, or doing both at the same time. The 3rd option sounds like a recipe for disaster. If you are experienced and would like to shed some light on my situation - because I could really do with some inspiration or direction - it would be much appreciated if you left a comment.

#whattolearnnext?
COVID-19 Mobile App with React Native!
Tags: reactnative, react, javascript, motivation
Published: 2020-04-08 11:35:35

Hi!
Last week I create an experimental project for tracking live data of COVID-19 pandemic. Simple interface and interaction. I designed it simple for testing 0.62 version of React Native and trying other features.

Unfortunately, neither the AppStore or Google Play doesn't accept applications about COVID epidemic, so I can't bring it live.

I've added features like data visualization and world map. Just for fun!

It's independent project, so you can fork and play it however you want. Any PR and support will be welcome of course.

Stay@home, stay safe!

Repo: https://github.com/ezranbayantemur/covid-19-app
China’s FinTech Sector to Brace for 'Capital Winter' Even After the Coronavirus Pandemic Subsides
Tags: blockchain, china, fintech
Published: 2020-04-08 11:17:19

Investment activity in China’s tech sector has seen a massive drop in the past four months since the coronavirus outbreak has emerged from the city of Wuhan. The venture capital market has been suffering a tremendous impact on its existing drop in activity.

Tech-based industries, including FinTech, artificial intelligence, and web-based services have seen a 31.3 percent decline from 173.5 billion to 119.1 billion in Q1, in the same period as last year. Investment deals have also seen a dip, from 1,143 to 634 in the same period, resulting in a 44.5 percent decline.

According to a report by Itjuzi.com, In 2019, 3161 startup companies were founded, while in Q1 of 2020, less than 100 startups were founded, which was around 3 percent of companies founded last year. Of those 100 startups, many were founded in January before the COVID-19 outbreak. The report further suggested that startups in artificial intelligence and e-commerce continue to attract funding, as shown in the first quarter.

Read More on <a href="https://blockchain.news/news/china-fintech-sector-brace-capital-winter-after-coronavirus-pandemic-subsides">here</a>

<a href="https://blockchain.news/">Blockchain.News</a> is a global leading English <a href="https://blockchain.news/analysis/hong-kong-blockchain-ecosystem">blockchain</a> media which brings you the most up to date coverage on blockchain, cryptocurrencies and financial technology.
How to get a user’s IP Address using just JavaScript (and an API call)
Tags: coding, axios, cloudflare, ipaddress
Published: 2020-04-08 16:14:44

---
title: How to get a user’s IP Address using just JavaScript (and an API call)
published: true
date: 2020-04-02 10:46:32 UTC
tags: Coding,Axios,CloudFlare,IP Address
canonical_url: https://blog.jws.app/2020/get-a-users-ip-address-using-just-javascript-and-an-api-call/
---

I have used [IP Chicken](https://www.ipchicken.com/) for checking my public [IP Address](https://blog.jws.app/2014/what-are-ip-address-classes/) for pretty much 15 years (since hearing about it on TechTV).  Once upon a time, I tried writing my own alternative in [ColdFusion](https://blog.jws.app/tag/coldfusion/) but it is a lot of overhead for such a dumb thing.  I started wondering if I could do it with just [JavaScript](https://blog.jws.app/tag/javascript/).

This is one way? :)

{% codepen https://codepen.io/steinbring/pen/VwLWXON %}

It uses a service that [CloudFlare](https://www.cloudflare.com/) offers, [Vue.js](https://blog.jws.app/tag/vue-js/), and [Axios](https://blog.jws.app/tag/axios/).  The data that [CloudFlare](https://cloudflare.com/cdn-cgi/trace) returns isn’t [JSON](https://blog.jws.app/tag/json/) but you can do some substrings to get what you need.

I will likely return to this at some point.  I think that there is a better method.

Also, I created [ip.jws.app](https://ip.jws.app/) (because why not?) if you want to see these concepts in action.
Post Makers - Week 3
Tags: react, covid19, jobhunt, quarantine
Published: 2020-04-08 10:30:58

Week 3 of the job hunt/quarantine combo has come and gone. More and more the days pass and seem to reflect some sort of movie, rather than the 2020 we all had in mind. Watching the news has become a sobering reality to what is going on around, and why it is necessary to follow the rules and stay indoors.

Not too much has changed since last week, i’m keeping up with the AM job application schedule, and carrying on the project with 2 of my classmates. All i can say is that I am so thankful to have a project so motivating to work on. I’m finding myself sitting there for hours a day, pouring over data, react docs and deep conversation with my Makers amigos. Although the topic is ironically what is dooming us to stay indoors, it is nice to make something factual, contemporary and somewhat useful for tracking the madness that is going on outside.

It also has me using some of the basic principals of coding again, the api data needs sorting, and filtering and separating and joining. Algorithmic thinking is just what i needed to kick the brain in gear and jump back into the world of the unknown.

It reminded me why i got into coding, it is the same appeal that used to have me playing 10 hours straight on my Super Nintendo….the want to succeed and explore. Dare i say this feeling with react is even more, i’m just scratching the surface of what this crazy library can do, and i find myself falling deeper into it the more i explore….

Currently the app is quite basic, displaying the overall cases, recoveries and deaths over the world, then each country and US state has its own meter on the google map api, and when clicked an info window pops up with the current stats of that country. I’m chuffed so far (https://covid-mapper.herokuapp.com/) but have big plans for the next stage - I’m going to get stuck int the world of graph visualisations to represent the data in various forms (I want to get the day by day increase of a country on click, rendering in a separate panel on the site).

Short and sweet this week, as many of you know, the priority is keeping safe, keeping sane and staying indoors!

I wish everyone luck in these crazy times,

David