teleren/devto huggingface dataset:
Python If-Else Condition
Tags: python, webdev, django
Published: 2020-04-26 11:36:59

Conditioning is the most basic operator in any programming language. Python provides some of the built-in additional tools which we'll be learning in the section of our python tutorial.

**Example**: To create a simple `if` statement.
```python
    a=10 
    b=5
    
    if a > b:
        print("Yes the value of a is greater than b value.") 
    
    #PYTHON OUTPUT
    Yes the value of a is greater than b value.
```
## If Else Conditional Statement

**Example**
```python
    a=10
    b=11
    
    if a >= b:
        print("Yes the value of a is greater than b value.") 
    else:
        print("Yes the value of b is greater than a value.") 
    
    #PYTHON OUTPUT
    Yes the value of b is greater than a value.
```
## Elif Conditional Statement
```python
    user_role = 'STAFF'
    
    if user_role == 'ADMIN':
        print("Welcome Administrator")
    elif user_role == 'STAFF':
        print("Welcome Staff")
    
    #PYTHON OUTPUT
    Welcome Staff
```
## Nested if-elif in python

**Example**: To check greater of 3 nos.
```python
    a=10
    b=11
    c=9
    
    if a > b:
        if a > c:
        print('A is greater')
        else:
        print('C is greater')
    elif b > c:
        print("B is greater")
    else:
        print('C is greater')
    
    #PYTHON OUTPUT
    B is greater
```
**Example**: Short-Hand If Condition
```python
    a=12
    b=14
    
    if b>a: print(b)
    
    #PYTHON OUTPUT
    14
```
**Example**: Short-Hand if-else condition
```python
    a=15
    b=16
    
    print(a) if a>b else print(b)
    
    #PYTHON OUTPUT
    16
```
**Example**: Multiple conditioning use `AND` `OR` operator.
```python
    a=35
    b=25
    c=33    
    if a>b and a>c:
        print('A is greater than B and C')
    // PYTHON OUTPUT
    A is greater than B and C
    a=30
    b=25
    c=33    
    if a>b or a>c:
        print('Because A is greater than B') #if any one condition is True
    // PYTHON OUTPUT
    Because A is greater than B
```
## **Top Python Posts**

*   [Python List](https://dev.to/pavanbaddi/python-lists-hcb)
*   [Python Strings](http://thecodelearners.com/python-strings/)
*   [Python Anonymous Lambda Functions](https://dev.to/pavanbaddi/python-anonymous-lambda-functions-4i6a)

This article is taken from [ the code learners python conditional statements](http://thecodelearners.com/python-if-else-condtion/)
Quick Checks for Log Repetition
Tags: linux, bash, sysops
Published: 2020-04-26 11:21:35

Got paged at 06:30, second disk alert on an Apache proxy in 24 hours. 

```
$ tail -500 access_log | awk '{ print $11 }' | while read l ; 
do echo "$l" | cksum; done | sort | uniq -c | sort -rnk1
    254 646511054 1131
    241 4112021984 1128
      1 785623522 964
      1 3691076460 4
      1 3287357281 899
      1 2484884658 1131
      1 2437517015 72
```

Looks like 99% of requests are the same 2 things. Eyeballing demonstrates my hosts are getting polled hard by a user. They are suspended until they explain what they are doing to generate ~15 gigs of logging all by themselves every 20 hours.
Vue routing 
Tags: vue, vscode
Published: 2020-04-26 11:17:58

#Hello everyone! 

Today I'll be helping you out getting into Vue.JS routing. It's really easy and I think that you will get into it very easy. This is my first post, I hope you will like it.

###What is routing? ✈
Routing or router in web development is a mechanism where HTTP requests are routed to the code that handles them. To put simply, in the Router you determine what should happen when a user visits a certain page.

###What we can use routing for?  🤔
Routing is mostly used to make website routes when visiting (e.g localhost:8080/home). This gives us a lot of functionality to work with. We can restrict people from visiting a page on our site if he e.g isn't logged in to access. Another good usage is when user tries to access a nonexistent website page we can redirect him to a certain page section (e.g '/not-found').

###How to integrate Vue router? 😯
It's really easy to integrate Vue router into your project when starting it up. We will be creating our project in the Vue CLI which is really neat for creating new projects as it does everything for you.

![alt text] (https://i.imgur.com/z62m9Bj.png, "vue-create")

After typing this portion we will manually select next features: 

![alt text] (https://i.imgur.com/fAr01jo.png, "vue-create")

After that you can also add history mode for the router and let the app install.
Your App.vue file should look like this:

![alt text] (https://i.imgur.com/2C3tjf5.png, "vue-app")

So _'router-link'_ is similar to our _'a'_ tag which we normally use to send someone to our designated link. The difference between those two is that _'router-link'_ sends you to the route you want to go and with that it renders the components of that route. The #id will always stay the same which means that it won't have to re-render to every component in order for it to work. It will stay as it should. 

The next thing is the _'router-view'_ and to put it simply it just renders the components of each route you are currently visiting. 

There is two ways you can create routes, I will show them in the next section.

![alt text] (https://i.imgur.com/4VI9hyG.png, "vue-routing")

The first object is an example of classic route you can integrate very easily as you see you just need to import the view you want to render on the route and set the object as you see on the picture.

The second object shows you how to lazy load a route. It is basically the same except of the last component argument. The difference is that this component is going to be lazy loaded. What is lazy loading a route and is it better? 
Lazy loading a route is basically loading or downloading the route component upon it's rendering so we don't need to download every component we use. This is done because we can't predict if the client is going to visit that page and for the performance sake it is better to lazy load routes or in bundles.

This is basically the end of my first post I hope you like it and enjoy it! 📃
how to add items to an array in JS
Tags: javascript
Published: 2020-04-26 11:10:47

To add elements to an array we will to use the splice  function.

.splice(index, howmany, item1, ....., itemX)

index :	 what position to add/remove items, Use negative values to specify the position from the end of the array
howmany	: items to be removed. If set to 0, no items will be removed
item1, ..., itemX	Optional. The new item(s) to be added to the array
3 trends that I like in web design
Tags: webdev, beginners, ux
Published: 2020-04-26 11:07:58

Hi everyone,

Today I want to write about the three trends in web design that I like the most and offer some examples of how they are useful

#Trend 1

**Micro interaction**

Micro-interactions are great when you want to build feedback for the user and also helps the user understand what is happening in your application at any given time.

A good example would be a form that is submitting some data to the backend.

![Submit button using micro interactions](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2016/10/1477350953submit-button.gif)

As you can see Dear Reader this trend really helps the user see what is happening and also brings some cool effects while waiting for an action to finish.

#Trend 2

Big images

Let's begin this section with a quote and start from there:
> "A picture is worth a thousand words"
So a picture can sometimes describe better a certain thing or feeling but also one deed can sometimes replace any image.
> Henrik Ibsen first said: "A thousand words leave not the same deep impression as does a single deed." 

But coming back to our trends, images can really help the users understand what your website is about, so use them.

Let's imagine that we are building a mountain hiking website and adventure service.

What type of images should we use?

The answer is: Too use the images that are connected to what you are building, down below there is an example that we could use **Dear Reader**.

![Mountain Hike](https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg)

#Trend 3
**Gradients**

The use of gradients can sometimes help lift the mood and also create subtle transitions and focuses the user's attention towards certain elements or certain actions available on the page.

They are used especially on landing pages or on product pages, alongside big images.

An example of this can be found below:


![Explore new Zealand](https://www.artonicweb.com/learn/wp-content/uploads/2018/01/from-here-to-everywhere-1024x505.png)

I hope you enjoyed the article **Dear Reader**.

If you liked the article share it on social, so others can enjoy it too.


Credits:
https://www.sitepoint.com/how-to-lift-your-ux-out-of-the-pack-with-micro-interactions/
https://dribbble.com/shots/1673204-Submit-Button
https://en.wikipedia.org/wiki/A_picture_is_worth_a_thousand_words
https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg
https://www.artonicweb.com/learn/wp-content/uploads/2018/01/from-here-to-everywhere-1024x505.png
How to create a reusable table component with ReactJS in 2020
Tags: codewithghazi, react, bootstrap, javascript
Published: 2020-04-26 11:02:26

If you want to learn how to create a reusable table component with react js and bootstrap to display data in a beautiful tabular format in your application with less code and higher reusability within just 10 mins then please read through this post and you will be a PRO in creating reusable table component in ReactJS.

## Why we need a reusable table component?
After developing numerous applications in ReactJS, I have found a pattern of some components such as Table, Form Inputs, Buttons, Modals these are some types of components we need most of the time and writing it again and again to every component we have more number of lines which is almost duplicate and does almost the same thing only the data it reflects or action it performed are different.

So I created a playlist of Reusable form component with React on Youtube you can watch it here. Today I will be sharing table component with you guys which I have created in just 10 mins and saved my days of work in displaying tabular data in my applications.

Table component’s HTML is almost the same the only thing changes is the data we pass to the table, so why not make it reusable and save time in the future development of the application and this will help us keep code clean, tested, and maintainable.

Final Output
![create a reusable component with react and bootstrap](https://codewithghazi.com/wp-content/uploads/2020/04/tables-1024x521.png)

[Read full article here](https://codewithghazi.com/how-to-create-reusable-table-component-with-reactjs-in-2020/)

{% github https://github.com/gkhan205/react-reusable-table-component %}
Custom domain name, Heroku, and SSL
Tags: help, heroku, namecheap, ssl
Published: 2020-04-26 10:24:24

I tried to move domain name from Heroku to Namecheap, and got SSL problem.

Do I need Let's Encrypt or something? Or, do I purchase SSL on Heroku or Namecheap site?

BTW, the website is <http://zhquiz.cc>. (Cannot use https:// here, but it redirects to https:// anyway.)
My first Powershell Azure Function
Tags: powershell, azurefunctions
Published: 2020-04-26 09:46:16

Photo by Tim Mossholder on Unsplash

I'm mostly a C# developer. Lastly, i had to programmatically modify an Azure Web application to add or remove firewall rules in a Web application and a SQL one.
To me, it was obvious to use:
- a C# Azure function
- [azure C# sdk](https://github.com/Azure/azure-sdk-for-net)

It was easy for the SQL part.
but i was stuck for the Web application part, as the firewall rules was part of the inner configuration of the web application.

It was a surprise to me as the Powershell Core command was pretty simple to use.
So i was gladly surprised to see powershell function available, and the experience is simple.

##Modules

I just need Az modules to complete my task. In order to check which modules are available, i just have to insert those lines in the function:

```powershell
Get-Module -ListAvailable | Select-Object Name, Version | Sort-Object -Property Name
```
Az modules are here, so nothing to install.

##Identity

For the authentication / authorization part, i rely on a [Managed Service Identity](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview), and on role based authorization control (RBAC) on the Web application.

In order to connect and i have the right identity i just have to:

```powershell
Connect-AzAccount -Identity
$az = Get-AzContext
write-host $az
```


##Command to execute

I just have to execute the command to add the access :

```powershell
Add-AzWebAppAccessRestrictionRule
```

Hope this helps !
Go - Convert Structs to Map
Tags: go
Published: 2020-04-26 08:26:04

This hack uses https://github.com/fatih/structs


```golang
package main

import (
	"fmt"

	"github.com/fatih/structs"
)

type User struct {
	FirstName string `structs:"first_name"`
	LastName  string `structs:"last_name"`
}

func main() {
	a := User{FirstName: "John", LastName: "Wick"}
	s := structs.New(a)
	m := s.Map()
	for k, v := range m {
		fmt.Println("key", k, "value", v)
	}
}
```

Output is:

```
key first_name value John
key last_name value Wick
```
Learn How to Upload Image in Laravel Using Dropzone
Tags: laravel, dropzone
Published: 2020-04-26 08:21:02

Hello Artisan

In this example tutorial i am going discuss about dropzone. In this tutorial i will show you that how we can upload image in laravel using dropzone. You know that dropzone is the most popular, free and open-source library that provides drag and drop file uploads with image previews. It’s lightweight, doesn’t depend on any other library (like jQuery) and is highly customizable.

https://www.codechief.org/article/learn-how-to-upload-image-in-laravel-using-dropzone
Headless CMS recommendations
Published: 2020-04-26 08:10:31

I have used headless CMS for personal projects or smaller clients. However, for a number of large clients (both private and government sectors) I have used Drupal and Wordpress due to the client's preference. 

However, I am really looking at some of the headless CMS alternatives due to a lack of flexibility with time spent configuring Drupal projects.

Can anyone recommend a good headless CMS, specifically for large clients?
Tiniest bubble sort on the net?
Tags: javascript
Published: 2020-04-26 08:01:04

I stumbled on an older dev.to post by the great [Greg Bullmash](https://dev.to/yiddishninja/javascript-bubble-sort-in-the-fewest-lines-5e5n) that I really liked because it triggered my code-golfing nerve, and I figured I could come up with a bubble sort one-liner!

Turns out I was wrong, I need at least ~~4~~ 3 lines to make tiniest working bubble sort algo on the net* but it was still a fun exercise so I'm sharing it.

```js
const bubblie = (arr, swaps = false) => {
  arr.forEach((e,i) => { e > arr[i+1] ? ([arr[i], arr[i+1]] = [arr[i+1], arr[i]], swaps = true) : false });
  return !swaps ? arr : bubblie(arr, false);
}
```



*citation needed
What Westworld and React Hooks have in common
Tags: react
Published: 2020-04-26 07:50:13

⚠️ **Spoiler alert!** If you haven't watched [Westworld](https://en.wikipedia.org/wiki/Westworld_(TV_series)) perhaps you may want to skip this post.

In the first season of Westworld androids are reset and their memories erased every time they "die" or after each "narrative cycle". Androids cannot take their memories with them (nor learn from them) for the next cycle. **In a way they're stateless.**

![Maeve](https://dev-to-uploads.s3.amazonaws.com/i/l4ahfmi6lf7n7zec6fj9.png)

On episode 4 Maeve seems to malfunction and has memories from when the scientists fix her wounds and reset her every time. But this only lasts for one cycle and then she forgets again.

One day, after a daydreaming episode she draws her vision (a man in a hazmat suit) on a piece of paper and starts wondering where to keep the drawing. She suspects everything in her room is carefully reset every time.

![Maeve lifts the floorboard](https://dev-to-uploads.s3.amazonaws.com/i/i8uiqlju2ppxnm7aoran.png)

She decides to hide the piece of paper under a loose floorboard. When she lifts the board she finds a lot of similar drawings that had been stored in there before.

![Maeve finds other drawings](https://dev-to-uploads.s3.amazonaws.com/i/7nsh02zxy45kje7ndrrl.png)

**That's basically React.useState.**

Imagine a component with a text input. The user enters some data, but this is a pure function! where do we keep this data for the next time the function is run? 

**Under a floorboard.**

```js
const [drawings, setDrawings] = useFloorboard()
```
Oneclicktheme - Get free UI resources
Tags: css, html, design, ux
Published: 2020-04-26 07:46:42

OneClickTheme is a web design blog showcasing free high-quality design resources like Sketch, Figma files, HTML website templates, fonts, illustrations, and other cool stuff. You can get free Handpicked freebies & UI Kits and also download free design resources for **Sketch**, **Adobe XD**, **Figma**, **InVision Studio**, **Adobe Photoshop**, **Adobe Illustrator** to kickstart your project. Enjoy!

I made this website for my own personal collection. Now, I think this can help a community to get started the web business. If you are a creator then you can submit your resources here by emailing to oneclicktheme@gmail.com.

Visit site [**https://www.oneclicktheme.com/**](https://www.oneclicktheme.com/ "One Click Theme")

You can also vote on producthunt https://www.producthunt.com/posts/oneclicktheme

Just Press ⌘+D to bookmark this site. Thank you!!

I hope you've found this blog very helpful. Feel free to share your thoughts and opinions and leave me a comment if you have any problems or questions.

Till then,

**Keep on Hacking, Cheers**
Companies and universities have a problem with the word "free"
Tags: free, online, university
Published: 2020-04-26 07:46:28

A Free Online University with official knowledge seems impossible in a world dominated by fear and ignorance (see: COVID-19 history hit).

However, today lots of potential students have to stand an elitistic, imposed model of society based on money and laws that defend big bank accounts without a maximum limit number.

"Free" becomes a forbidden word in this context, where even the most clever and generous people have to adapt to the market and its demmand: no money for investigation, unless it carries economical benefit for the capitalist.

Of course, China has to have a better education system. We do not know too much about China, but I am sure they do not have to pay thousands for one year of university career.

Of course: they do not compite, they collaborate.

They say that China is a fascist state. But I do not see the difference between what China does, and what media does with the time they have to educate and show people the world.
Any thoughts on create-react-app breaking due to one line npm package
Tags: javascript, react, npm
Published: 2020-04-26 07:32:14

It seems like create-react-app broke because of an error in one of its npm dependency. The dependency itself is just one line of code, more specifically it checks to see whether a certain object is like a promise or not (is an object with `then` method).

https://github.com/then/is-promise/issues/13#issuecomment-619402307

The issue seems to have been resolved, as I can create a new react app using create-react-app

This situation reminds me, and apparently many others, of the time when one package was unpublished from npm and caused many projects to fail.

https://arstechnica.com/information-technology/2016/03/rage-quit-coder-unpublished-17-lines-of-javascript-and-broke-the-internet/

The package under question here is is-promise and has this code
```javascript
function isPromise(obj) {
  return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
}

```

So what are your thoughts on it? Should such trivial functions be inlined? Or are there better alternatives?
UpDoer Technology- An Independent Software Testing Company
Tags: QA, testing, AutomationTesting, MobileAppTesting
Published: 2020-04-26 07:14:48

UpDoer is an India-based Software Testing/QA company. With 25+ Engineers on board, the company covers the entire STLC helping large enterprises and startups accomplish their most ambitious business goals. This company’s service includes core testing services (performance testing, security, compatibility, localization testing, test automation, etc.) and value-added services (QA consulting, business analysis). UpDoer expertise stretches in every direction: e-commerce, healthcare, telecom, banks and finance, logistics, oil, and gas, etc.
What is your preferable NPM package boilerplate?
Tags: discuss, javascript, typescript, node
Published: 2020-04-26 07:14:10

There are lot of people who contributes to open source community. This is mainly about javascript community. So just want to discuss and share what are your preferable NPM package boilerplates that you would use when you start creating a new NPM module.

There will be multiple boilerplates for different projects. No matter what share it. As an example there will be typescript, react, vue, typescript + react etc package boilerplates. 

This is what i use for react and typescript.

tsdx: https://github.com/jaredpalmer/tsdx

Thank you!

Reach Me:
[Blog](https://chathula.dev)
[Twitter](https://twitter.com/chathulaC)
[Linkedin](https://www.linkedin.com/in/chathula)