teleren/devto huggingface dataset:
Sets in Python
Tags: python, beginners
Published: 2020-02-20 13:46:06

In <a href="https://python.org">Python</a>, a `set` is a container whose objects must be unique. If you try to add something that's already in the set, it will not do anything (no error will be thrown).

## Set example

Open the Python <a href="https://pythonprogramminglanguage.com/repl/">interactive shell</a> to try it out. You can define a set by calling the *set()* method.

```python
    >>> a = set([1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4])
    >>> a
    {1, 2, 3, 4}
    >>> 
```

It uses curly braces `{` `}`, but don't be confused with a <a href="https://pythonprogramminglanguage.com/dictionary/">dictionary</a> because it's a set. You can double check this with the type() function

```python
    >>> type(a)
    <class 'set'>
    >>> 
```

To add elements to the set, use the `.add(object)` method.

```python
    >>> a.add(4)
    >>> a.add(5)
    >>> a.add(6)
    >>> a
    {1, 2, 3, 4, 5, 6}
    >>> 
```

You can remove elements with the pop() method

```python
    >>> a
    {2, 3, 4, 5, 6}
    >>> a.pop()
    2
    >>> a
    {3, 4, 5, 6}
    >>> 
```

To remove a specific item call the `.remove()` method

```python
    >>> a.remove(5)
    >>> a    
    {3, 4, 6}
    >>> 
```

## FrozenSet

A <a href="https://docs.python.org/2.4/lib/types-set.html">frozenset</a> is different in mutability: it's frozen, cannot be changed, modified.

You can try adding or removing elements in the Python interactive shell:

```python
>>> a = frozenset([1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4])
>>> a
frozenset({1, 2, 3, 4})
>>> a.add(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'frozenset' object has no attribute 'add'
>>> 
```

## Operations on sets

You can do a variety of operations on sets

```python
>>> pets = { 'cat','parrot','dog' }
>>> zoo = { 'elephant','rhino','dog' }
```

Intersection of two sets

```python
>>> pets & zoo
{'dog'}
```

Union of two sets

```python
>>> pets | zoo
{'dog', 'parrot', 'elephant', 'rhino', 'cat'}
```

Symmetric difference of two sets

```python
>>> pets ^ zoo
{'parrot', 'elephant', 'rhino', 'cat'}
```

Asymmetric difference of two sets

```python
>>> pets - zoo
{'cat', 'parrot'}
>>> 
```

You can test if a set contains an object, by using the `in` keyword. This returns a <a href="https://pythonprogramminglanguage.com/booleans/">boolean</a> value (**True**/**False**). 

```python
>>> 'cat' in pets
True
>>> 'rhino' in pets
False
>>> 
```

The `in` keyword can also be applied to other sequences like <a href="https://stackoverflow.com/questions/626759/whats-the-difference-between-lists-and-tuples">tuples</a> or <a href="https://pythonbasics.org/list/">lists</a>.

The typical operations you'd expect like `min(set)`, `max(set)` and `len(set)` can be applied too.
The HTTP Status Codes You Need to Know
Tags: beginners, http, webdev
Published: 2020-02-20 14:07:07

---
title: The HTTP Status Codes You Need to Know
published: true
description: What's that status code mean? Whether you're working on the client or the server, you'll need to know these common HTTP response codes.
tags: beginners, http, webdev
canonical_url: https://blog.bearer.sh/common-http-status-codes/
cover_image: https://images.unsplash.com/photo-1503365113766-4a362681eac5?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=2000&fit=max&ixid=eyJhcHBfaWQiOjExNzczfQ
---

Working on the web means coming into contact with HTTP responses. Whether you spend your time primarily on the client or on the server, you're likely familiar with the popular ones like 200, 404, and 500. While memorizing all the codes using [cat memes](https://http.cat/) as a mnemonic can be helpful, let's dive deeper into what some of the most common codes mean.

## What is an HTTP status code?

HTTP response status codes are a set of [standardized](https://tools.ietf.org/html/rfc2616#section-10) and agreed upon numbers that identify information about an http response.

Status codes are 3 digits and broken down into 5 categories, each organized by the first digit of the number. You'll see these abbreviated as the first number, followed by two "x" characters. For example, "4xx".

- 1xx: **Informational** provides information about a request in progress.
- 2xx: **Successful** indicates that the request was received and accepted.
- 3xx: **Redirection** indicates that the request has to be redirected.
- 4xx: **Client Error** indicates that an error has occurred on the client.
- 5xx: **Server Error** indicates that an error has occurred on the server.

If you're consuming an API, it is usually safe to assume that it conforms to these standardized codes. If you are the one creating an API, make sure to match your responses with the appropriate code. 

[👉 Read on](https://blog.bearer.sh/common-http-status-codes/?utm_source=dev&utm_medium=continue_reading&utm_campaign=common_http_statuses)
Using Kafka with Dapr on Kubernetes
Tags: azure, opensource, kubernetes, kafka
Published: 2020-02-20 13:56:18

I generally don't do screencasts or video content 😋 Wanted to share a quick demo that I had recorded to showcase how to use [Kafka bindings with Dapr](https://github.com/dapr/components-contrib/blob/master/bindings/Readme.md)

I used:

- [Dapr on Kubernetes](https://github.com/dapr/docs/blob/master/getting-started/environment-setup.md#installing-dapr-on-a-kubernetes-cluster) (`minikube`)
- [Azure Event Hubs](https://docs.microsoft.com/azure/event-hubs/event-hubs-for-kafka-ecosystem-overview?WT.mc_id=devto-blog-abhishgu) as the Kafka cluster

> The code is available on [GitHub](https://github.com/abhirockzz/kafka-dapr-eventhubs-k8s)

Let me know what you think 🙂

{% youtube gxn2oX85vqI %}
Run a regex on each line of a file (Go)
Tags: go, tutorial
Published: 2020-02-20 13:53:33

Want to find a word in a file? Want to run regexes on a specific pattern? Easy peasy lemon squeezie.

```go
    package main

    import (
    	"bufio"
    	"fmt"
    	"log"
    	"os"
    	"regexp"
    )

    func main() {
    	file, err := os.Open("file.txt")
    	if err != nil {
    		log.Fatal(err)
    	}
    	defer file.Close()

    	scanner := bufio.NewScanner(file)
    	r, err := regexp.Compile("treasure") // this can also be a regex

    	if err != nil {
    		log.Fatal(err)
    	}

    	for scanner.Scan() {
    		if r.MatchString(scanner.Text()) {
    			fmt.Println(scanner.Text())
    		}
    	}

    	if err := scanner.Err(); err != nil {
    		log.Fatal(err)
    	}
    }
```
Testing App Layout with Expo
Tags: expo, ui, reactnative, ux
Published: 2020-02-20 13:41:20

Ever needed to make sure your Expo App’s UI doesn’t break across all of your target devices? Can’t be bothered having to deal with simulators/emulators for different devices?

Then these two methods might help save you some time.

<h3>Method 1: Expo Web</h3>

The first and possibly simplest method is to use Expo Web. By bundling your app for web you have a window that you can dynamically resize to the most extreme heights/widths and aspect ratios to test it all out (see below). This is built into any Expo project you create and your app can be launched from the CLI by pressing ‘w’ which will start a webpack server and open it in a new tab for you!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8t0g6xzmeiyuxyfqjsjc.gif)

But there is a big caveat - if you use modules that aren’t react-native-web supported then you’ll just get a fatal error on start up... which is where method 2 might be a little better.

<h3>Method 2: Use a top-level View</h3>

It seems simple but only occurred to me the other day - why not just make your top level component a `<View />` that you can set the height and width of to mimic the layout on any device. The obvious issue with this is you need a larger device with large screen dimensions than whatever layout you want to try out - I mainly develop for iPad at the minute and so this works quite well for me (see screenshot below).

```jsx
// In App.tsx (or App.js if your still using vanilla JS)
// Define a test height and width to mimic any device
const testHeight = 400;
const testWidth = 250;
// ...
render() {
  return(
    <View style={{height: testHeight, width: testWidth}}>
     {/* The rest of your app here */}
    </View>
  );
}
// ...
```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/meivgsp3ps6xwyu03a7c.png)

<h3>Method 3: Just use a simulator...</h3>

If neither of these solutions fit your needs then you might be best sticking to using a standard simulator or emulator (or stealing all of your roommates’ phones to try your copy of flappy bird on). At the end of the day they give you a true representation of what the app will look and feel like on any device and more importantly let you ensure the functionality of your app works cross platform.

Thanks for reading! If you have any tricks for this let me know below!
Select a DOM element with getElementByID
Tags: javascript, dom, tutorial, browser
Published: 2020-02-20 13:07:30

---
title: Select a DOM element with getElementByID
published: true
description: We are getting familiar with some popular document methods.
tags: javascript, dom, tutorial, browser
series: Get Started with JavaScript in the DOM
---

If you would prefer to watch this post, you can do so with this [community resource lesson on egghead.io.](https://egghead.io/lessons/javascript-select-a-dom-element-with-document-getelementbyid?pl=introduction-to-client-side-web-apis-72d0&af=ay44db)

Getting an element by id is so common that the document object has a helper function for us to use.

Given this html:

```html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Select an Element with document.getElementById</title>
  </head>
  <body>
    <ul>
      <li id="movie-1">Peanut Butter Falcon</li>
      <li id="movie-2">Knives Out</li>
    </ul>
  </body>
</html>
```

We can grab our `<li id="movie-2">Knives Out</li>` by calling `document.getElementById('movie-2')`.

That's it!
Custom Exceptions in Python
Tags: python, beginners
Published: 2020-02-20 12:58:43

<a href="https://python.org">Python</a> Applications may call custom exceptions by creating a brand new exception class. Custom Exceptions need to be derived from the `Exception` class.

## What is an Exception?

An exception can be thrown with the `raise` keyword. They can be handled with the <a href="https://pythonprogramminglanguage.com/try-except/">try-catch</a> block.

You can try this in the Python shell, by typing `raise Exception("your message")`.

    ➜  ~ python3
    Python 3.7.5 (default, Nov 20 2019, 09:21:52) 
    [GCC 9.2.1 20191008] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> raise Exception("No can do")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    Exception: No can do
    >>> 

All built-in exceptions use the `Exception` class. User-defined exceptions should be derived from this class (<a href="https://pythonbasics.org/inheritance/">inherited</a>).

## Custom Exception

The program shown below creates a custom exception `HappyError` that inherits from the `Exception` class.

```python
class HappyError(Exception):
    pass

raise HappyError("To happy to run")
```

The above program then raises the `HappyError` exception:

    ➜  ~ python3 program.py
    Traceback (most recent call last):
      File "t.py", line 5, in <module>
        raise HappyError("To happy to run")
    __main__.HappyError: To happy to run

Many modules define their own exceptions.

Optionally you can override the <a href="https://pythonbasics.org/constructor/">constructor</a> like this:

```python
class ValidationError(Exception):
    def __init__(self, message, errors):

        # Call the base class constructor with the parameters it needs
        super().__init__(message)

        # Now for your custom code...
        self.errors = errors
```

But with Python 3 Exceptions, you don't need to do override anything. If all you want is an informative message for your exception, do this:

```python
class MyException(Exception):
    pass

raise MyException("My car is swimming")
```
Freeze First column and first row in react native with table component?
Tags: reactnative, npm, javascript, android
Published: 2020-02-20 12:43:12

0


I have created table component with first column sticky, but i want same as first row also sticky, i tried with flatlist, scrollview, react native table component also. I didn't get properly?. It's working only one way, i need it in both way's.
Best reactjs training in ahmedabad

Tags: react
Published: 2020-02-20 12:41:41

LogicRays Academy is an IT training institute that provides professional training courses for students & professionals in Ahmedabad. We have expert trainers to assist you in learning a variety of training courses from basic to advance. With 100% practical training, we help you in improving your logical skills so that you can develop quality projects.If you want to learn Reactjs with training on live projects, then you should contact us in Ahmedabad.

You can contact us at https://www.logicraysacademy.com/
How to apply the eye Ball Rotation using ARKit in iOS from FaceTracking
Published: 2020-02-20 12:36:08


I am using ARKit's ARFaceTrackingConfiguration to track the facial blendshapes along with left and right Eye Transforms. I am exporting this data into json and apply this data on 3d model ( which preconfigured shape keys, eye nodes). I was able to apply the blend shape data, but I got struck at how to apply the eye rotations. am getting leftEyeTransform, rightEyeTransform which is simd_float4*4 from FaceAnchor. Here how to apply the rotation on eye nodes from the transform values.
I believe for eyes, it is enough to apply the rotation.

I have tried with the below to get the orientation from eyeTransforms:

Method 1:

let faceNode = SCNNode()
faceNode.simdTransform = eyeTransform
let vector = faceNode.eulerAngles
eyeLeftNode.eulerAngles = vector

Method:2

let faceNode = SCNNode()
faceNode.simdTransform = eyeTransform
let rotation = vector_float3(faceNode.orientation.x, faceNode.orientation.y, faceNode.orientation.z)
let yaw = (rotation.y)
let pitch = (rotation.x)
let roll = (rotation.z)
let vector = SCNVector3(pitch, yaw, roll)

eyeLeftNode.eulerAngles = vector

Method: 3
let simd_quatf = simd_quaternion(eyeTransform)
let vector = SCNVector3(simd_quatf.axis.x,simd_quatf.axis.y,simd_quatf.axis.z)
eyeLeftNode.eulerAngles = vector


None of the ways are working. I am not able to figure out the actual problem on how to rotate the eyeBalls. Can you please tell me how to do this

Thanks,
Chaitanya
VSCodium the open-source version of VSCode without telemetry
Tags: vscode, productivity, webdev, beginners
Published: 2020-02-20 12:33:10

Hi everyone,

Today I am writing about VSCodium the opensource version of VSCode without telemetry that for me personally is faster than the VSCode official version. 

The good thing about this project is that you already get the installer for your system so you don't need to build from source. 

Also as far as I tested all the extension from the marketplace works and your user data will not be recorded. I think this is a good solution for projects that need confidentiality.

The VSCodium project and installers can be downloaded from here https://vscodium.com/

What do you think **Dear Reader**, would you give VSCodium a spin?

**Update**(Important)

Tim Bachmann asked in the comment section of the article for an explanation on the following: 


> How (if at all) does VSCodium prevent plugins from sending their own telemetry data?

I got in touch with the VSCodium Team using their GitHub and they had the following to say through @stripedpajamas:

> Hi @wolfiton -- first of all thanks again for writing the article. Second, questions like this one are best sent on in our Gitter chat (gitter.im/VSCodium/lobby) so that the issues don't get too clogged up.

>To answer your question: yes! Extensions are 3rd party code and each must be evaluated for telemetry on its own. Many MS-built extensions are programmed to send telemetry and it isn't clear whether or not those extensions honor VSCode/VSCodium's telemetry settings.

> Additionally, the marketplace itself should be considered a 3rd party API (owned by Microsoft), so any searches / installations using the marketplace (including from within VSCodium) are most likely being logged and aggregated by the API owner.

> For more info there is a small section on our Docs page about it and other parts of VSCodium that "use online services": https://github.com/VSCodium/vscodium/blob/master/DOCS.md

> Cheers

  
Thank you again @stripedpajamas for the fast response and permission to post the quote above.
 

Credits:

https://vscodium.com/

Thank you VSCodium Team for the fast response especially,too @stripedpajamas
RFC: Call React component state variables "statelings"
Tags: react, watercooler, javascript
Published: 2020-02-20 12:22:58

I've been a professional web developer for just over 10 years now. I'm currently the lead web development instructor at [Better Coding Academy](https://codebetter.com.au), and as part of what I do, I post videos on our YouTube channel at [https://www.youtube.com/c/BetterCodingAcademy](https://www.youtube.com/c/BetterCodingAcademy).

_(Subscribe for awesome web development content!)_

I was talking with one of my students, and he asked me this question regarding React:

> Hmm...
> What do you call the things that exist inside `state={}`
> Statelings?

It totally caught me off guard.

For those of you who don't know, the "proper" name is **state variables**, but personally I'm ever so slightly biased towards **statelings**.

What do you guys think? 😁
What is the programming tutorial in 2020, you wanted to learn but couldn't find?
Tags: discuss, beginners, tutorial
Published: 2020-02-20 12:18:36

Hi everyone,

What is the programming tutorial in 2020, you wanted to learn but couldn't find?


I am really curious also what would you like to find in a tutorial to make it stand out?

Also, what is your favorite tutorial and teacher so far?

Let's discuss this

Thanks in advance to all participants to this discussion
5 UX Interactions I Hate that Work in Business
Tags: webdev, career, design, ux
Published: 2020-02-20 11:13:49

User Experience is something I take very seriously, especially after having made systems that need to be utilised within seconds with workflows for health and medicine where those things are crucial.

So when I see UX that fundamentally tries to stop people from achieving their goals, or practices that seem counter-intuitive to growing an audience and making money, it drives me a little insane.
{% youtube JrRJv6r1WnM%}
In this latest video, I go over just 5 of the things that frustrate me when it comes to bad user experiences that seem to be adopted by a large number of businesses and seem to effectively work for them.

<strong>These 5 include:</strong>
<ol>
<li>Unable to view a websites content until you signup to their newsletter</li
<li>Disabling your AdBlocker in order to view content</li>
<li>Sharing or Liking a Twitter/Facebook page before downloading resources</li>
<li>Requesting me to accept push notifications without my permission every time I visit the page</li>
<li>Having a countdown to purchase a product.</li>
</ol>

These are just a few of the ones that bug me but seem to be working for a heap of organisations, like Medium, Forbes, and Airliners.

What are some of the things that you find as terrible user experiences on websites but know deep down inside, probably drive lots of customer acquisitions and sales?

## Follow and support me: 
Special thanks if you subscribe to my channel :)
* [Youtube](https://www.youtube.com/channel/UCvM5YYWwfLwpcQgbRr68JLQ?sub_confirmation=1)
* [Patreon](https://www.patreon.com/adriantwarog)
* [Twitter](https://twitter.com/twarogadrian)

## Want to see more:
I will try to post new great content every day. Here are the latest items:
* [Learn how to make a Triangle in CSS once and for all](https://dev.to/adriantwarog/learn-how-to-make-a-triangle-in-css-once-and-for-all-2pfe)
* [Adobe XD to HTML Full Process](https://dev.to/adriantwarog/adobe-xd-to-html-full-process-ao6)
* [How to implement Dark Mode with CSS new media call: prefers-color-scheme](https://dev.to/adriantwarog/how-to-implement-dark-mode-with-css-new-media-call-prefers-color-scheme-3h65)
* [Creating a Mobile Design and Developing it](https://dev.to/adriantwarog/creating-a-mobile-design-and-developing-it-5c4o)
Unable to Load Angular8 application in Mac-IOS(Safari Browser)
Published: 2020-02-20 11:44:03

Unable to access Angular8 application in Mac-iOS machine in Safari Browser. But could able to access the application in Chrome browser without any issue.
The issue in the console(developer tools) mentions about CORS but this is not the case when we check in other browser. Is Angular8 not supported in Mac-iOS(Safari browser)?
Mac-iOS version is 13.33
Please advise.
Is setting position of elements relative or absolute elements to move left, right, top, bottom  correct
Tags: css, html, javascript
Published: 2020-02-20 11:11:38

To make elements move left, right, top, bottom I have to set position property to relative or absolute but when I resize the window, I see elements are rearranged incorrect way. I want to move elements left, right, top, bottom as well on window resize element to show in correct manner. How to achieve this?
Hey, it's been awhile
Tags: project, ideas, inspiration
Published: 2020-02-20 11:03:45

---
title: Hey, it's been awhile
published: true
description: Inspire me
tags: project, ideas, inspiration
---

Hey everyone! It's been awhile since I last posted here. But I'm back! Hooray! 🎉🎉🎉

I've been busy with quite a few things lately. But lately I've been itching to get back into some coding. I want to stretch my mind a bit and refresh my hands to get used to coding again.

So here I am! I wanted to ask for some ideas from you guys of what you might want me to code! Here are 2 things that I do know:

- Django
- React

That's it. Pretty limited I guess. But I'm willing to learn new things! So shoot 'em at me and I'll give it a shot! 😄✨
DEV extreme moderation !!! #htwgm !!!
Tags: smn, bnb, htwgm, watercooler
Published: 2020-02-20 10:55:58

*The #linux tag is meant for content directly related to linux OSes. Posts focused on WSL should be tagged with #wsl instead.*

I wonder what the L in WSL stands for ? HAS THE WORLD GONE MAD #htwgM 

OK i admit @DEV is 'THE GOTO PLACE FOR DEVs' (maybe because of the moderation) but WHO MODERATES THE MODERATORS ?
GetWidget open source News app developed by Ionicfirebaseapp
Tags: flutter, opensource
Published: 2020-02-20 10:45:31

Have you used our GetWidget library? If not then let's start with our real-time live open-source Flutter news app that builds using GetWidget library and Flutter.
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vdcvohfrdq8800w9mcfo.png)

Check out more details about open-source projects and download here and start building Flutter app with the use of GetWidget.👇👇👇

https://www.ionicfirebaseapp.com/products/flutter-news-app

Check out how to start GetWidget: https://docs.getwidget.dev/

This app is UI kit so if you would like to make a fully functional just like a real news app then you will require a backed to perform your action and maintain it. So let's build some awesome app with Flutter and let us know what awesome feature have you built in this open-source news app.