teleren/devto huggingface dataset:
How to: Deploy Create-React-App on Surge
Tags: surge, react, deploy, createreactapp
Published: 2020-12-05 14:43:38

---
canonical_url: https://blog.shaundai.com/blog/surge-create-new/deploying-an-app-with-surge/
---

#### Have a React app you're ready for the world to see? Check out these 5 easy steps to deploy that bad boy!



#### 1. Install Surge

First things first - let's make sure you have surge installed.

Install Surge globally ("globally" means that all of your projects will have access to Surge, not just this one) by typing this into your terminal:

```
npm install --global surge
```

#### 2. Create a build folder for your repo

In the terminal, get to the root directory of your completed React app ("root directory" is the highest-level folder for your app).  If you used create-react-app to get your app running in the first place, type npm run build in the command line and press enter. 

```
npm run build
```

Npm will create a build folder, which is basically a deployable version of all of the React files you've worked so hard on, minus the junk and the secret information you wanted to keep hidden.

Now navigate to your build folder by typing the following into the command line.

```
cd build
```

#### 3. Deploy to Surge

We're going to deploy to surge at this point, which is as easy as typing one word in the command window to activate the program: surge.  Type surge into the command line and press enter.

```
surge
```

#### 4. Create a Surge Account (or log into your existing account)

Surge will prompt you to either create an account or log in.  If this is your first time using Surge, use your email address and create a password to create a Surge account through the command line.  If you've used surge before, your most recently used credentials will appear and you can press enter to keep it moving or create a new account/enter a different login from there.


#### 5. Get your Domain

Surge will make up a domain name for you.  You can keep the domain they give you, change the surge sub-domain to your own available name (for example: 'my-customname.surge.sh'), or use a custom domain by following the [instructions here](https://surge.sh/help/adding-a-custom-domain)

>Press enter.

You're done!  Enter the link in your browser to see your app live in action.

Connect with me on [Twitter](https://www.twitter.com/shaundai) and on [LinkedIn](https://www.linkedin.com/in/shaundai).
How to Password Protect a Website or Web SubDirectory With .htaccess & .htpasswd
Tags: web, security, htaccess
Published: 2020-12-05 14:40:43

Working on a website that you need others to see, but not the whole world? Password protecting a website (or a sub directory within a website).

Protecting files on your website from unauthorized users can be very important. You can use PHP or any language to listen for login authorization information on each page, but that doesn’t protect your images, documents, and other media and it is not proper way to do so.

That’s why I’ve found the new method of protecting files and directories the most reliable and is actually a pretty easy thing to do.

![Image for post](https://miro.medium.com/max/60/0*bSZQq62XuA0dosm9.png?q=20)

<noscript><img alt="Image for post" class="ev el eh id w" src="https://miro.medium.com/max/672/0*bSZQq62XuA0dosm9.png" width="336" height="167" srcSet="https://miro.medium.com/max/552/0*bSZQq62XuA0dosm9.png 276w, https://miro.medium.com/max/672/0*bSZQq62XuA0dosm9.png 336w" sizes="336px"/></noscript>

To <span id="rmm"><span id="rmm">p</span></span>assword protect we will use .htaccess and .htpasswd method.

# Step1: Basic Coniguration

To make .htaccess files work as expected, you need to have below line in your site Apache configuration,

> _AllowOverride All_

So your file will look like

> _<VirtualHost *:80>_
> 
> _ServerName password-protected.com DocumentRoot /var/www/PasswordProtected <Directory /var/www/PasswordProtected> # This relaxes Apache security settings. AllowOverride all </Directory>_
> 
> _</VirtualHost>_

This tells Apache that it’s okay to allow .htaccess files to over-ride previous directives. You must reload Apache before this change will have an effect

> _sudo service apache2 reload_

# Step2: Create .htaccess and .htpasswd files

Create a file called .htaccess in the directory that you want to password-protect (in my case I am using /var/www/PasswordProtected directory) with the following content

> _AuthUserFile /var/www/PasswordProtected/.htpasswd AuthName “Authorization Required” AuthType Basic require valid-user_

Then create the file /var/www/PasswordProtected/.htpasswd which contains the users that are allowed to login and their passwords.

We do that with the htpasswd command, to use this command make sure apache2-utils package is install.

> _htpasswd -c /var/www/PasswordProtected/.htpasswd USER1_

The -c flag is used only when you are creating a new file. After the first time, you will omit the -c flag, when you are adding new users to an already-existing password file. Otherwise you will overwrite the file!!

And that’s it you are done !! Your website is password protected now.
TOML first class dates is a mistake
Published: 2020-12-05 14:37:06

Making something a first-class entity may seem like an unquestinably good idea, but it's not always the case. Sometimes it creates more problems than it solves.

I fear TOML's first-class dates is one of those cases. Here's why.

## Behaviour is ambiguous

The TOML spec does a good job at specifying acceptable date and time formats. However, it doesn't say what implementations are supposed to do with them.

What it says:

```
To unambiguously represent a specific instant in time, you may use an RFC 3339 formatted date-time with offset.
```

RFC3339 dates indeed specify a specific instant in time _in the past_. They aren't good for things like "an offer valid until 2038-01-19 in Nebraska" because the UTC offset of the Nebraska time zone isn't guaranteed to stay the same until 2038. Timezone changes aren't even _that_ rare and haven't all occured decades ago: for example, Brazil stopped using DST in 2019.

But, that's not really my point. My point is that the spec doesn't say whether the result of deserializing a TOML date should be a timezone-aware object or converting it to a UNIX timestamp is acceptable. In practice... it varies.

Why this matters? If an implementation doesn't preserve timezone information (which it isn't required to do), then `dump(load(toml))` is a lossy operation. It can be quite a serious issue for tools that automatically manipulate TOML files.

## There's no natural datetime type choice for every language

Some languages, like Python or Go have datetime types and functions in their standard library. Whether a "batteries included" is a good approach or not is debatable.

What isn't debatable is that other languages like Rust or OCaml do not have it built-in—they leave choice of a datetime library to use developer.

However, it means that a TOML parsing library will have to either force a datatime library choice on developers who want to use it, or provide an abstraction mechanism.

# Conclusion

All in all, I think TOML would really be better off without first-class dates, which aren't even used all that often in the wild.
7 Reasons Why You Should Apply for TCL
Tags: react, webdev, javascript, beginners
Published: 2020-12-05 14:35:05

"*When you value and appreciate something, you can't stop talking and writing about it.*" -Anonymous

That's how I feel about [TCL (or, The Collab Lab)](https://the-collab-lab.codes/). I just can't shut up about my experience with them. :sweat_smile:

Here are a few reasons why I appreciate that program and the people behind it so much, and why you should apply to join them if you're an early-career React developer and looking to gain some experience in working with a diverse team in agile development.

*(It's a free program, by the way.)*

**1- The culture and community**:
One of the main things I admire about TCL is the culture and community. They care so much about the participants no matter what their backgrounds, beliefs, or religions are. 

Their [code of contact](https://the-collab-lab.codes/code-of-conduct/) is proof of how much they care.
  

**2- The mentors**:
Having mentors is priceless, especially if they're doing it out of passion. And TCL has a habit of attracting only passionate, experienced mentors.


**3- The team**:
I mean, who doesn't want to work and be friends with people from different cultures and countries? Who doesn't want a few people to go through all the frustration and code bugs with? *No one, obviously*.


**4- Git and Github**:
Working with TCL will get you more and more comfortable working with Git and Github. You'll learn how to write good pull requests and why, how to review other people's code, and how to resolve code conflicts. 


**5- Code reviews and office hours**:
Yes, you get those every week for eight weeks in a row.


**6- The weekly sync calls**:
Each Sunday, you'll give a short presentation about the work you and your pair of the week will do that week. I think that's one of the most helpful things about the program. It lets you practice how to talk about and explain the code you write, which can be very handy in interviews.


**7- [Andrew Hedges](https://twitter.com/segdeha)**:
*(I was going to add Andrew as the first reason here but then decided to save the best reason to the last)*

Andrew is the founder of Collab Lab and an engineering manager at [Zapier](https://twitter.com/Zapier). The kindness he has shown us at TCL is unbelievable. You need him in your social media life as a reminder that there are people out there who wake up each morning thinking, *"Hmm, what can I do today to help people I don't even know but care deeply about?"* And that one day, those people are going to save us all.
____
Thank you for reading, and if you're interested, please [apply here](https://the-collab-lab.codes/apply/). 
 
The applications will be open from tomorrow to December 12.
Advent of Code 2020 Solution Megathread - Day 5: Binary Boarding
Tags: adventofcode, challenge
Published: 2020-12-05 14:34:49

---
title: Advent of Code 2020 Solution Megathread - Day 5: Binary Boarding
published: true
description: We're using binary thinking to figure out what seat is ours, like your typical holiday traveler does.
tags: adventofcode, challenge
series: Advent of Code 2020
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/9mkn73zpd8vj33t8idae.png
---

And so closes out the first week.  Can you believe we're already 20% of the way through the challenge?  How's everybody doing staying on top of it?  I was in awe of some of the solutions I saw yesterday.  And I believe we had another couple firsts for new languages.  Anyways, to the puzzle:

## The Puzzle

In [today’s puzzle](https://adventofcode.com/2020/day/5), we've lost our boarding pass.  But, like any tech-savvy holiday traveler, we're writing a program to use binary partitioning to unravel strings like BFBFFFBLRL into seat ID's.  So.  Yeah.  Good luck!

## The Leaderboards

As always, this is the spot where I’ll plug any leaderboard codes shared from the community.

```
Ryan's Leaderboard: 224198-25048a19
```

If you want to generate your own leaderboard and signal boost it a little bit, send it to me either in a DEV message or in a comment on one of these posts and I'll add it to the list above.

## Yesterday’s Languages

Updated 03:07PM 12/12/2020 PST.

| Language   | Count |
|------------|-------|
| JavaScript |     4 |
| Ruby       |     2 |
| C          |     2 |
| PHP        |     2 |
| Rust       |     2 |
| Python     |     2 |
| C#         |     1 |
| Go         |     1 |
| COBOL      |     1 |
| TypeScript |     1 |
| Elixir     |     1 |
| Haskell    |     1 |


Merry Coding!
Why won't Java import my package?
Tags: help, watercoooler, java
Published: 2020-12-05 14:19:52

I have the filesystem:
```
code:
    Main.java
    org:
        json:
            /* code */
```
and it showed up in VS code like for a second, and I thought I secured a victory, but, then it just vanished.
When it showed me I could use `JSONObject` from the library, I was ecstatic, and I tried making a variable with it, but after I made the var, and tried to hover over the class for documentation, nothing came up.
I tried to ctrl+click on it so see if it'd bring me to the file, but it said the file "`code/libs/org/json/JSONObject.java`" didn't exist(??? why that path??).

I retried, doing `import org.json.*;`, but I'm not getting any results now, and I don't know what I did the first time to make it work.


Does anyone have advice?


<div>
##    <b><center><b>Thanks!<br/>Cheers!</b></center></b>
</div>
Advent of code
Tags: adventofcode, challenge
Published: 2020-12-05 14:00:19

I recently came a cross interesting December challenge.
It's called advent of code, it has quite interesting challenges that you can solve using any programming language..

Here some small info:

Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

https://adventofcode.com/

If you have some extra time in December feel free to participate.. :)
A Beautiful Connection Between Coding and Embroidery
Tags: devjournal, react, redux, codenewbie
Published: 2020-12-05 13:34:00

_This post was originally published on December 5, 2020 on [my blog] (https://alexlsalt.github.io/blog)._

I'm sitting here on this lazy Saturday morning, working on my latest embroidery project. (In case you didn't know, I've gotten *really* into this new hobby over the past month!)

When I was just starting out with embroidery and learning the ins and outs of the different types of stitches, I felt like I was just barrelling through each design as a means to finish and move on to the next one.

What started as an almost-compulsive drive to complete each project turned into stress and tension - something that I never thought would come out of such a relaxing pastime???

### But as I was working through stitching a series of flowers and leaves in my latest project this morning, I came to the realization that there's actually *nothing* dictating that I need to go quickly in order to finish it.

I mean (not saying I'm going to or anything) I could potentially work on the project for a year if I wanted to - taking care to get each stitch just right, watching videos of particularly difficult stitch techniques that I'm just not understanding from visual explanations of the technique, etc.

And then, of course, I thought about that in terms of my own coding journey and the adventure I've been on over the past year and a half.

I've touched on it a tiny bit in my last couple of blog posts, but I'm having the same realizations as I'm deepening my understanding of Redux and state management within increasingly more complex web applications.

### Taking my time to truly understand something, and intentionally *not* moving on until I'm comfortable with a certain concept has proven to be the best strategy for improving my skills as a developer.

If that means stopping my learning for the day in order to come back the next day with fresh eyes and a fresh outlook, then that means it'll take me an extra day to move on.

And that's totally fine. Plus! It definitely beats the frustration of moving on anyway and then having to circle back way down the road to try to understand it again (putting us right back at Square One).

Honestly, taking up embroidery was meant to give my brain the occasional break from coding and constant learning.

But I'm actually delighted to report that what it's really giving me is a great dose of perspective and appreciation for taking all the time I need along the greatest adventure of my life (thus far).
Why Yes to UI and No to ML/AI?
Published: 2020-12-05 13:29:19

If you are unable to decide between UI and ML/AI, I would suggest you go for UI.  Below I describe a few reasons why you should choose UI over ML/AI.

### Degree of Difficulty:
To secure a good enough job in ML/AI, your math and statistics skills have to be excellent. You would also need to know which algorithm suits which condition, how to train algorithms better, how to do better feature engineering among many other things that are not easy to master. Whereas in UI, within a few weeks of learning, you can become an entry-level developer. It is way easier to get someone job-ready in UI than in ML/AI.

### Rapid automation:
In the ML/AI domain, automation is going to replace most of the jobs in the future. Even now, companies such as Microsoft, Amazon, and Google have ready-made API's to train the algorithms.

### Scarcity of good projects in India:
Currently, the majority of good projects in the ML/AI domain are being implemented in the US. There are few good ML/AI projects in India. Even the Indian government is not showing much interest in ML/AI.

### Market readiness:
Jobs available in the ML/AI domain outside India are also less. In spite of this being the case, there are many ML/AI courses online which claim that AI is the future and that there are many jobs here. Don't get allured by them. When working in any field, one should try to be in the top 1% of that field, and getting to the top 1% in ML/AI is difficult compared to getting to the top 1% in UI. Also, programming and software development are skills that will keep one employed for a long time.

If you are keen on pursuing a career in ML/AI, complete your graduate studies in India and then pursue MS and P.H.D in the US. This will help you build a better career in this field.

**Credits:** [Which career path to choose? UI or AI?](https://www.youtube.com/watch?v=oZhXwCEBmmk&list=PLzvhQUIpvvuhpBvp_dmjPizeHLVpMCxYB&index=5&ab_channel=TanayPratap) by [Tanay Pratap](https://tanaypratap.com)
Daily Developer Jokes - Saturday, Dec 5, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-12-05 13:00:20

---
title: "Daily Developer Jokes - Saturday, Dec 5, 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=Saturday%2C%20Dec%205%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/5e1258a63bab5.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:___ What did the array say after it was extended?

___A:___ Stop objectifying me.
 -->
Shortcuts For Command-Line Ninjas
Published: 2020-12-05 12:55:06

Nowadays, I spend more time in the Terminal. I'm learning some useful shortcuts to get things done faster. Here are some of those shortcuts.

## Navigation

`Ctrl + a` => Go to the beginning of a line.  
`Ctrl + e` => Go to the end of a line.  
`Alt + b` => Move backward one word.  
`Alt + f` => Move forward one word.  

## Cutting & Pasting

`Ctrl + k` => Delete all after the cursor.  
`Ctrl + u` => Delete all before the cursor.  
`Ctrl + w` => Delete one word before the cursor.  
`Ctrl + y` => Paste deleted caracters.  

__(tips: use Alt + b to move anywhere you want and use Ctrl + k to delete all words after the cursor.)__

## Others

`!!` => Repeats the last command.  
`Ctrl + h` => If you don't want to use the BACKSPACE key.  
`Ctrl + j` => If you don't want to use the ENTER/RETURN key.  
`Alt + u` => Capitalize all characters in a word after the cursor.  
`Alt + l` => Uncaptalize all characters in a word after the cursor.  
`Ctrl + l` => Clears the screen and redisplay the line.  
`history` => To see the past command you used. To use those command type ! before the command number.  

**(tips: use Alt + b and Alt + u to Capitalize a word before the cursor. The same goes for Alt + l)**
What was I doing in this shell?
Tags: bash, linux
Published: 2020-11-14 14:09:18

Do you frequently open another SSH window for another task or to connect to another machine? I know I do. Do you ever return to those windows a day or two later and wonder what you were doing there to begin-with? I know I do.

Put this into your .profile to to run the `lulwat` function any time you hit <kbd>enter</kbd> three times in a row.

```
# source me.

export PROMPT_COMMAND=btnMash

function btnMash {
  # Init a counter for prompts-displayed if its missing
  [[ -f /tmp/promptsDisplayed ]] || history | tail -1 | awk '{ print $1 }' > /tmp/promptsDisplayed;

  # Init a counter for commands
  [[ -f /tmp/commandsRun ]] || (history | tail -1 | awk '{ print $1 }' > /tmp/commandsRun)

  COMMANDS=$(cat /tmp/commandsRun)

  # Increment prompts-displayed counter
  echo $(($(cat /tmp/promptsDisplayed)+1 )) > /tmp/promptsDisplayed;

  history | tail -1 | awk '{ print $1 }' > /tmp/commandsRun

  if [[ $COMMANDS -lt $(cat /tmp/commandsRun) ]]
  then
    cat /tmp/commandsRun > /tmp/promptsDisplayed
  fi

  PROMPTS=$(cat /tmp/promptsDisplayed)

  if [[ $PROMPTS -ge $(($COMMANDS+3)) ]]
  then
    lulwat; rm /tmp/promptsDisplayed; return
  fi
}

function lulwat {
	# If I am su-ed into this account, tell me.
	#
	ID=$(id | awk '{gsub(/[\(-\)]/," ")} { print $2 }');
	WHO=$(who -m | awk '{ print $1 }')

	[[ "$ID" == "$WHO" ]] && echo "You are: $ID"
	[[ "$ID" == "$WHO" ]] || echo "You are: $ID (su-ed from $WHO)"

	# Hostname and path
	#
	printf "On: $(hostname):$(pwd)\n"

	# If this a git repo, remind me of the remote
	#
	git status &>/dev/null && (
		printf "$(git remote -vv | awk '{ print $2 }' | head -1) ($(git branch | awk '{ print $2 }'))\n"
	)
}
```
Machine Learning solutions at Adevinta and BenevolentAI
Tags: machinelearning, nlp, seo, health
Published: 2020-12-05 12:47:22

The last event organised by the Adevinta Spain Meetup group was focused on describing applications of Machine Learning in different industries.

In the first talk, Ana Solaguren-Beascoa Negre, from BenevolentAI, detailed how drug discovery R&D is still a huge challenge for the pharmaceutical industry. It is expensive, has a high percentage of failure in programmes and this translates into a high societal cost. In this talk, she gave an overview of the world of how the BenevolentAI platform is trying to improve and speed up the process of drug discovery by using Machine Learning in different areas, focusing more in the area of chemistry.

The second talk was focused on the Machine Learning project that has led to a significant improvement of the InfoJobs SEO through Natural Language Processing techniques by generating an internal link structure of the site.


{% youtube 3GC0xpqXOjo %}
Rate my Portfolio website
Tags: portfolio, github, webdev, review
Published: 2020-12-05 12:08:24

Hey Guys,
- Recently I built my portfolio website.
Please have a look and rate it. Also any new suggestions and improvements are heartfully welcomed :D.
[Portfolio](https://anujbansal16.github.io/)

- Also there is a cool way to create the portfolio on the github profile itself. Checkout that too in the link below -:
[Github](https://github.com/anujbansal16)