teleren/devto huggingface dataset:
Force Https with .htaccess
Tags: htaccess, https
Published: 2021-12-29 12:34:00

After installing an SSL certificate, your website will be accessible via HTTP and HTTPS. However, it is better to use only the latter, because it encrypts and additionally secures the data of your website. With some hosters there is a setting in the web interface to force HTTPS with just one click. Unfortunately, it happens again and again that this setting does not work correctly with various CMS systems. You can also use the .htaccess file (which we recommend) to force an HTTPS connection.  This tutorial shows you how to do that.

##Force HTTPS for all traffic

One of the many options you have with .htaccess files is to redirect HTTP traffic to HTTPS. You can enable the feature to force HTTPS for all incoming traffic by following the steps below:

1. Go to the file manager in your hosting panel and open the .htaccess in the appropriate folder where your domain points to. If the file is not there, you may need to create and/or share it.
2. Scroll down until you find "RewriteEngine On" and paste the following lines of code below it:
```php
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
```
3. Save the change.

> IMPORTANT: Make sure that the line "RewriteEngine On" does not appear twice. If the line already exists, simply copy the rest of the code without it.

##Forcing HTTPS for a specific domain

If you have two domains that both point to the same website, but only the first domain should be redirected to https (for whatever reason), you can use the following code:
```php
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^yourdomain-1.de [NC] 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
```
##Force HTTPS for a specific folder

The .htaccess file can also be used to force HTTPS for specific folders. However, the file should be placed in the folder that is to establish the HTTPS connection.
```php
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(folder1|folder2|folder3) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
```
Replace the "folder" with your "directory".

After you have made the changes, clear your browser's cache and try to connect to your website via HTTP. If everything was added correctly, it will now redirect to the HTTPS version.

##Conclusion
Congratulations! You have just successfully edited your .htaccess file and redirected all HTTP traffic to the secure version HTTPS. Depending on the platform you developed your site on, there may be alternative methods to enable this feature.

If you have any tips, tricks, or suggestions to share with us, we welcome your comments!


Connect me on [Twitter], [LinkedIn] and [GitHub]!

Visit my [Blog] for more articles like this.



[Blog]: https://waterproof-web-wizard.com/blog
[Twitter]: https://www.twitter.com/proofwebwizard
[LinkedIn]: https://www.linkedin.com/company/waterproof-web-wizard
Crypto business that makes you a Billionaire (Part-1)
Tags: businessideas, cryptobusinessideas, cryptoexchange
Published: 2021-12-29 12:49:15

Crypto is booming day by day pace. According to the projections, digital money would be over $1100 million by 2025. Cryptocurrencies will have an annual growth rate of around 10% which indicates that in the future we will going to talk more than now.
Among the customers, they buy and sell items using cryptocurrency through the crypto business. In addition, the reach of cryptocurrencies among people gives them more confidence to start a crypto business. Cryptocurrencies are accepted by top companies like Microsoft, AT&T and Wikipedia these are the organizations where you can pay with cryptos like Bitcoin.
Looking to step into the crypto business, but have a blur idea of where and what to start?
The good news is there are a plethora of opportunities in your hand to make a great living! Here are the ideas to start a most profitable business in 2022!
Here they are:
Cryptocurrency business is the topmost business idea among millionaires. The first one is Cryptocurrency Exchange Platform Development.
Cryptocurrency Exchange Platform Development is a business that allows users to trade, buy, sell their assets using fiat money or other digital currencies. Well, there are two ways to create your crypto exchange platform 1) Start from scratch 2) clone script — more secure, safe, and cost-efficient
There are a lot of crypto exchange clone scripts are available in the market like Binance, LocalBitcoins, wazir, etc. But for the inevitable features and functionality, most of them are prefer [Binance Clone Script](https://maticz.com/binance-clone-script). In 2020, the Binance exchange has generated over $570 million in revenue. Before you going to launch you have to find the best Crypto Exchange Development Company to build your own Crypto Exchange platform like Binance.
Maticz, the pioneer Crypto Exchange Development Company that delivers 200+ successful projects worldwide. Before choosing us look a proven demo’s from our experts. ([Get a Live Demo](https://maticz.com/requestquote)).We also offers [Pancakeswap Clone Script](https://maticz.com/pancakeswap-clone-script), [NFT Development Services](https://maticz.com/nft-development-company), [BSC NFT Marketplace](https://maticz.com/bsc-nft-marketplace-development) , [BEP20 Token Development](https://maticz.com/bep20-token-development). 

Hope this article should help you to step into the crypto business. Stay connected with us for more business ideas will engage with you soon in part-2.
Software Architecture Design and Engineering at a Startup
Tags: programming, design, architecture
Published: 2021-12-29 14:03:34

The great thing about starting a new project is that you get a clean slate. No baggage of design choices that you hated to look at every day in your last project. But how many times have you seen a shiny new project not turning into the same intractable mess?

It is more likely to happen in a fast-paced startup. The faster the pace, the sooner it happens. So how do you balance moving fast without being trapped in analysis paralysis and keep technical debt at a manageable level?

You design for change. Ignore the refrain that prevention is better than cure. Instead of preventing the mess, you should embrace it and mitigate it when it happens. That’s what we have done at Slang Labs.

In this article, I discuss:

- Startup Reality: forces and constraints in a startup.
- Engineering Philosophy: our philosophy to manage that reality.
- Slang Architecture: evolution of Slang microservices and SDKs guided by our philosophy.

[Continue reading » ](https://medium.com/@scgupta/microservices-software-architecture-design-and-engineering-at-a-startup-c2df9587debd)
cross-env for front-end (Nextjs) on Windows 10 11
Tags: nextjs, webdev, startup
Published: 2021-12-29 17:48:53

If you are doing front-end projects on windows 10 or 11. 
specially, you want to run some of sample codes from GitHub!
Do not forget to install "npm i cross-env" on your project.
```
> npm i cross-env
```
The "cross-env" helps us save a lot of time. otherwise the codes threw errors!
for example:

1. read some of files from folder (markdown for blog etc.) on Nextjs
   
2. use "NODE_ENV=development" on project.json, see below command about lingui.
```
    "__NoWorkOnWindow_lang:extract": "NODE_ENV=development lingui extract --clean",
    "lang:extract": "cross-env NODE_ENV=development lingui extract --clean",

```

Happy Coding!
Highlighting: sync-contribution-graph
Tags: github, javascript, bash, git
Published: 2021-12-29 20:39:25

A couple of weeks ago, I nearly scrolled past this gem on my twitter feed: [sync-contribution-graph](https://github.com/kefimochi/sync-contribution-graph), by @kefimochi. Go have a look! 

You can use this tool to have your GitHub contribution graph accurately reflect contributions from other accounts you make use of. For example, outside of work I use the handle [mtfoley](https://github.com/mtfoley), but I have a separate account I use for my job. I like the idea that I could use this to accurately reflect my activity level, and that no private information about that work handle is revealed.

The way it works is pretty straightforward.  When you configure it with a username and a time frame (year), it performs an HTTP request to the appropriate URL, and parses the HTML in the response for the dates/counts of contributions (these correspond to those little green squares).  Based on this data, it creates appropriate `git` shell commands. The shell commands are saved to a file that can optionally be run immediately. Here's a snippet that's the meat of it in [src/index.js](https://github.com/kefimochi/sync-contribution-graph/blob/main/src/index.js):
```javascript
import { parse } from "node-html-parser";
import axios from "axios";
import fs from "fs";
import shell from "shelljs";


// Gathers needed git commands for bash to execute per provided contribution data.
const getCommand = (contribution) => {
  return `GIT_AUTHOR_DATE=${contribution.date}T12:00:00 GIT_COMMITER_DATE=${contribution.date}T12:00:00 git commit --allow-empty -m "Rewriting History!" > /dev/null\n`.repeat(
    contribution.count
  );
};


export default async (input) => {
  // Returns contribution graph html for a full selected year.
  const res = await axios.get(
    `https://github.com/users/${input.username}/contributions?tab=overview&from=${input.year}-12-01&to=${input.year}-12-31`
  );


  // Retrieves needed data from the html, loops over green squares with 1+ contributions,
  // and produces a multi-line string that can be run as a bash command.
  const script = parse(res.data)
    .querySelectorAll("[data-count]")
    .map((el) => {
      return {
        date: el.attributes["data-date"],
        count: parseInt(el.attributes["data-count"]),
      };
    })
    .filter((contribution) => contribution.count > 0)
    .map((contribution) => getCommand(contribution))
    .join("")
    .concat("git pull origin main\n", "git push -f origin main");


  fs.writeFile("script.sh", script, () => {
    console.log("\nFile was created successfully.");


    if (input.execute) {
      console.log("This might take a moment!\n");
      shell.exec("sh ./script.sh");
    }
  });
};
```

I made some suggestions in the setup workflow on the repo and submitted a [PR to update the README](https://github.com/kefimochi/sync-contribution-graph/pull/8).  I hope you find this and other work by @kefimochi to be of interest!
Generative Art With Python
Tags: python, programming, tutorial
Published: 2021-12-29 21:41:24

#Let's Create Art With Code
Join us as we learn how to [generate art with Python](https://www.iceorfire.com/post/generative-art-with-python)! Even if you aren't artistic you can give Jackson Pollock a run for his money.

# Support Me
If you find these tutorials helpful, please consider [buying me a coffee](https://www.buymeacoffee.com/z4F8QVS6w). Thanks!
Holidays, Entrepreneurship and SLOs with Nobl9
Tags: leadership, podcast, techtalks, startup
Published: 2021-12-30 20:57:22

It's finally here, the end of season 1 of the podcast is upon us! To celebrate, Santa is bringing something special - entrepreneurship advice for all the would-be founders of the world, [ages 1 to 92.](https://www.youtube.com/watch?v=hwacxSnc4tI&ab_channel=WalterTan)

Brian Singer, co-founder & CPO of Nobl9, sits down with Dev Interrupted to help us close out season 1 with a conversation on what it takes to found your own company. Having founded a pair of companies, one of which he sold to Google, Brian has a deep understanding of what it takes to successfully found and scale a startup. More than that, he knows what VCs are looking for. 

In addition to our conversation on entrepreneurship, we also discuss Service Level Objectives, the ins and outs of Nobl9’s SLO platform and why SLOs and error budgets will become commonplace approaches in the industry, much in the same way we practice Agile today. 

From the entire team at Dev Interrupted, we want to give a heartfelt thank you to everyone who has supported us and continued on this journey with us. Producing this podcast every week has been an absolute pleasure and we are so thankful for the outpouring of support we have received this past year. Expect big things - and even bigger stories - in season 2 of the podcast. 

Have a wonderful New Year, we’ll return on **January 8th** with a HUGE episode for the official start of season 2.

{% spotify spotify:episode:5ht1sKI7v43cLhZhywCqkE %}

## Episode Highlights Include:
* Why VCs don’t like single founder companies
* Scaling beyond the first 20 employees
* What are [SLOs](https://nobl9.com/)?
* Understanding when [tech debt matters](https://linearb.io/blog/technical-debt-ratio/?__hstc=75672842.b37abbbdf4f34a742895a6b2675da07e.1632418321637.1640804382855.1640838597523.186&__hssc=75672842.1.1640838597523&__hsfp=1615045989)
* The reason sales is the #1 skill for an entrepreneur

## Join the Dev Interrupted Community
With over 2000 members, the Dev Interrupted Discord Community is the best place for Engineering Leaders to engage in daily conversation. No sales people allowed. [Join the community >>](https://discord.com/invite/devinterrupted)

![https://discord.com/invite/devinterrupted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qous1521acseykryclzp.png)
JSON WEB TOKEN(JWT)
 
  

Published: 2021-12-30 10:08:38

JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. So in the tutorial, I introduce how to implement an application “Reactjs JWT token Authentication Example” with details step by step and 100% running sourcecode.
– I give you an Epic of the application, a fullstack excutive flow from frontend to backend with overall architecture diagram.
– I give you a layer diagram of Reactjs JWT Application.
– I give you an implementatin of security backend sourcecode (SpringBoot + Nodejs JWT RestAPIs).
– I guide you step by step how to develop a Reactjs JWT Authentication application.
– Finally, I do an integrative testing from Reactjs JWT Authentication application to Backend Security RestAPIs
For the Reactjs JWT Authentication tutorial, we have 2 projects:
– Backend project (using SpringBoot or Nodejs Express) provides secured RestAPIs with JWT token.
– Reactjs project will request RestAPIs from Backend system with the JWT Token Authentication implementation.

User Registration Phase:
– User uses a React.js register form to post user’s info (name, username, email, role, password) to Backend API /api/auth/signup.
– Backend will check the existing users in database and save user’s signup info to database. Finally, It will return a message (successfully or fail) to
User Login Phase:
– User posts user/password to signin to Backend RestAPI /api/auth/signin.
– Backend will check the username/password, if it is right, Backend will create and JWT string with secret then return it to Reactjs client.
 
After signin, user can request secured resources from backend server by adding the JWT token in Authorization Header. For each request, backend will check the JWT signature and then returns back the resources based on user’s registered authorities.
Topic: JS Promise vs Async await
Tags: javascript
Published: 2021-12-30 11:51:32

As JavaScript is an Asynchronous(behaves synchronously), we need to use callbacks, promises and async await. You need to learn what is async-await, what is promise, how to use promise and async-await in javascript and where to use it.

## **Promise**

- **What is Promise?**
A Promise is a rejected value or succeeded value of asynchronous function and when the operation is not fulfilled or fulfilled and thus promise is created. 
 
Promise have three states.
1. pending: initial state, neither fulfilled nor rejected.
2. fulfilled: meaning that the operation was completed successfully.
3. rejected: meaning that the operation failed.

## How to use Promise? See the example below
```
const calculate = (a,b,c) => { 
  return new Promise((resolve, reject) => {
  setTimeout(() => {
    if(a<0 || b<0 || c||0){
       reject("no number can be negative.")
    }
    resolve('Calculation: ', a+b+c);
  }, 1000);
 }
}
 
calculate(5,7,8);
.then((reolveOfCalculate)=>{
  console.log(reolveOfCalculate);
}.catch((rejectOfCalculate)=>{
  console.log("rejectOfCalculate");
})
```
From above example, I am trying to give a little explanation about promise. A promise is created in calculate function. When the operation of the function is fulfilled then, it calls a callBack function and the success value is kept in **resolve** argument. Similarly, a callBack function is called, and the failure value is kept in **reject** argument when the operation is not fulfilled. 
The success and rejected value is consoled by taking an argument respectively **reolveOfCalculate**, **rejectOfCalculate**.

Promise can be written in chaining. See below... 

```
const calculate = (a,b,c) => { 
  return new Promise((resolve, reject) => {
  setTimeout(() => {
    if(a<0 || b<0 || c||0){
       reject("no number can be negative.")
    }
    resolve('Calculation: ', a+b+c);
  }, 1000);
 }
}
 
calculate(5,7,8);
.then((reolveOfCalculate)=>{
  console.log(reolveOfCalculate);
  return (reolveOfCalculate, 3, 2);
}.then((chaining1)=>{
  console.log(chaining1);
}).catch((rejectOfCalculate)=>{
  console.log("rejectOfCalculate");
})

```
## **Async await**
Async await is the lighter version of promises. Because, basically promises works behind the await methods. The await operator is used to wait for a Promise. It can only be used inside an async function within regular JavaScript code. 

## Return value: 
Returns the fulfilled value of the promise, or the value itself if it's not a Promise.

```
const calculate = (a,b,c) => { 
  return new Promise((resolve, reject) => {
  setTimeout(() => {
    if(a<0 || b<0 || c||0){
       reject("no number can be negative.")
    }
    resolve('Calculation: ', a+b+c);
  }, 1000);
 }
}
```
```
const add = () => {
   const sum1 = await calculate(1,2,3);
   const sum2 = await calculate(sum1,2,3);
   return sum2;
}
add().then((result)=>{console.log(result)}).catch((error)=>{console.log(error)};
```

## Why to use Async await:
Async await is cleaner than promises. So, most of the programmers suggest to use async await to make our code readable and cleaner.
What is VOID Operator - Daily JavaScript Tips #3
Tags: javascript, node, webdev, tutorial
Published: 2022-01-10 04:16:59

The `void` operator returns `undefined` value;
In simple words, the `void` operator specifies a function/expression to be executed without returning `value`

```js
const userName = () => {
	return "John Doe";
}

console.log(userName())
// Output: "John Doe"

console.log(void userName())
// Output: undefined
```
[Live Demo](https://jsfiddle.net/psfhozqn/)

***
Thank you for reading

- Follow me on Twitter - [@codewithsnowbit](https://twitter.com/codewithsnowbit)
- Subscribe me on YouTube - [Code With SnowBit](https://www.youtube.com/channel/UCNTKqF1vhFYX_v0ERnUa1RQ?view_as=subscriber&sub_confirmation=1)
JS Intro
Tags: javascript, tutorial, beginners
Published: 2022-01-14 07:35:34

- [There are 8 fundamental data types in JavaScript: strings, numbers, Bigint, booleans, null, undefined, symbol, and object.](https://www.codecademy.com/resources/docs/javascript/data-types?page_ref=catalog) 

- First seven data types except object are primitive data types.

- BigInt is necessary for big numbers because they are unreliable with Number type 
 

#### example below: 

```
console.log(9999999999999999); // 10000000000000000
console.log(9999999999999999n); // 9999999999999999n
```

-  Objects, including instances of data types, can have properties, stored information. The properties are denoted with a . after the name of the object, for example: 'Hello'.length.

-  Objects, including instances of data types, can have methods which perform actions. Methods are called by appending the object or instance with a period, the method name, and parentheses. For example: 'hello'.toUpperCase().

- We can access properties and methods by using the ., dot operator.

- Built-in objects, including Math, are collections of methods and properties that JavaScript provides.

- Properties of an object can be either a value, or a method (a function only accessible to an instance of the object). A method is an attribute, but that does not make an attribute a method. A method is function, so performs some task. .length is a value, only.
- String.prototype.trim() =  method removes whitespace from both ends of a string and returns a new string, without modifying the original string

---

**What does it mean by an instance of a data type?**

```
a = 42
```
Above we assign an integer value (a number) to the variable, a. When we poll the type of a we are actually polling the type of 42. a is not an object, but a reference to an object. 42 is identified by the interpreter as being a number type so gives it a wrapper object of that type.
```
typeof 42  =>  'number'

typeof a   =>  'number'
```
So a refers to an instance of a number type.
Working on my 2nd Project: JavaScript Tic Tac Toe!
Tags: javascript, webdev, beginners, programming
Published: 2022-01-14 16:48:19

Hey Guys,

Been a week or 2 but I'm back like I said I would regarding the 2nd Project.

This will be a short post just to document my experience so far of the last 12 days. The challenge of pushing the game out so far has been a bitter/sweet one. On one hand I was able to get everything coded pretty quickly with the assistance of some youtube videos and mentors but by the time it came to submission of my deadline there was an error in the code not allowing the game to function properly to its full potential.

And for me that sucked bigtime. At this moment I'm unable to go and make any more changes on the submission as that will count as cheating on my end and could affect my grade so I will have to wait till marking has been completed on the project till I can make that change again.

All in all this project has been a good learning experience for me in terms of Javascript use. Some of the concepts have now been solidified for me and I know how to use Javascript lines of code to my advantage and the syntax no longer seems foreign to me anymore which is the point!

One thing I can definitely suggest for other newbies out there learning Javascript is that they should try to work on a small project right after they have done a course on it or read through some material as that would be the only way things make sense and stick in your head. Because there is no way your going to understand:

```
function handleSubmit(event) {
  event.preventDefault();
  let p1 = form.elements['password'].value;
  let p2 = form.elements['confirm-password'].value;

  if (p1 !== p2) {
    let errorDiv = document.getElementById('errors');
    errorDiv.innerHTML = "<p>Please ensure your passwords match.</p>";
    errorDiv.style.display = 'block';

```
If you are not applying it practically to the project you're using.
Making mistakes and then going back and making those changes to make the code work is one of the true and better ways to make concepts stick in your head and help you progress.

As for now I will revisit this blog post and paste the link for the finished game but at this present moment I'm not happy with the outcome so I will postpone publishing it for now.

Until then I'm going to be working on my 3rd Project which is in Python! As you know I did a bit of Python training before my Bootcamp so the language isn't alien to me. However, applying it practically may be another story so I'm going to try my best to produce the best results this time. 

Hope you enjoyed this read and stay tuned for the next post.
Follow me on Twitter: @CodezMikazuki 
Mika/Malcz.