teleren/devto huggingface dataset:
Converting a request HTTPError to Django Rest Framework
Tags: django, todayilearned
Published: 2021-09-02 12:49:15

Today I was working on a piece of code sits in a Django Rest Framework view and had an issue where I needed to call an external Rest API and still return the actual error rather than an "Internal Service Error".

Essentially the original code deep within a library went:

```python
result = requests.get(url)
result.raise_for_status()
```

So when calling this from a view, any error would directly translate to an internal server error. DRF includes `APIException` which is expected to be sub-classed so I did that with a a small init to take a status code instead of relying on the sub-class defining it.

```python
class GenericAPIException(APIException):
    def __init__(self, status_code):
        self.status_code = status_code
        super(GenericAPIException, self).__init__()
```

This meant that in my View:

```python
try:
    r = do_the_api_call()
except HTTPError as e:
    raise GenericAPIException(e.response.status_code)
```

This then meant that the status code proxies out via the view.
My personal 6 best tips for programmers🤩🤝
Tags: algorithms, programming, help
Published: 2021-09-02 12:37:15

### In this post I will tell you my own secrets and tips about programming!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ucv9ojfqup62tubsmja.png)
<br>
After 4 years of coding experience, I listed up the most important secrets you need to do, to earn way more experience and knowledge!!
<br>
### Ask other people for help!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4ta630vuu5wly1zbbje.png)
<br>
### Try to explain you your code to other people!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ht96splw1otiw0ohb0q.png)
<br>
### Do a code review and make your project more efficient!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccthnmb07gv3py3cim44.png)
<br>
### Join coding communities!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rui11m1jvox9404ddh8y.png)
<br>
### Learn more algorithms and data structures for better projects!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhvi173ixlk203scjj1y.png)
<br>
### Write your own projects!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8epnsl6f8nzaqmc093a.png)
Git and Github
Tags: github, git, webdev, design
Published: 2021-09-02 12:18:30

So we can talk about Git and Github. So Git and Github are different form each other.
Git:- 
Firstly we will talk about Git. So git is popular and its called as version control system mainly used by professional developers to have proper control over the projects. In Git you can config your name and email to make projects on Github. So if you want initialize a git repository first you will have to create a repository and then git init in Git bash so it will initialize a empty repository . Now you have to know about untracked and staged file its nothing much which tracks your files and tell whether you have done any changes. So there are 4 types u need to know untracked, unmodified, modified, staged. In untracked whether file is untracked you have to track them by typing git add . in Git bash after adding file it will go to staged area where you can commit by typing First commit ctrl+enter. If you wanna undo any file where you deleted file by mistakely you can type git checkout in Git bash. let talk about git status its nothing much to check your status about the project . Git log show that what you have commited in your project .Git diff is which compare working directory to staged directory. RM command is used to delete or remove the file from your project. Git ignore will ignore the unwanted file. Branches is very good feature in git .In branches the default branch is the master branch so where you can create
another branch work on it without messing the master branch and later you can merge them with your created branch.

Github:-
Github is free hosting services where you can host your projects for free and it built for developers. Remote repository to push any projects in Github u need to add remote it is URL which will get in your Github account after creating repository. so finally u can push the project by typing git push origin master and if u have created any branches you can also push them. Git clone where you can clone other projects  in your machines by typing in git bash git clone and the existing project URL.
Welcome to Tharun G‘s Blog. This is my first post.
Published: 2021-09-02 12:11:15

    I am a visual storyteller and an engineer who loves to experiment with unique ways of showing the world that I’m in. I’m an Explorer, Innovator and Maker of things and experiences.

    I love exploring and capturing beautiful places that people may never get to see or missed it.

I’m a photographer who shoots creatively. I have a passion for telling stories by capturing the most moments in a candid way. And I love making memories that last forever. My photos can tell the whole story of your precious moments that will last a lifetime for generations to come. I would love to help you with uniquely planning your special life events.

And, I’m a Drone Pilot & Maker who can help you build drones, deploy image recognition software, design hardware and wearables. Also, I can build your beautiful landing page & write code.
A Fun Programming Joke To Start Your Day
Tags: jokes, dailydeveloperjokes
Published: 2021-09-02 12:00:19

---
title: "A Fun Programming Joke To Start Your Day"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259a922f36.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_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 is a developer's favorite country song?

___A___: Hello World - by Lady Antebellum
 -->
What’s Your Status?
Tags: teamwork, softwaredevelopment
Published: 2021-09-03 12:47:48

---
title: What’s Your Status?
published: true
date: 2021-09-02 11:48:57 UTC
tags: teamwork,softwaredevelopment
canonical_url: https://medium.com/chingu/whats-your-status-40b152f004c1
---

#### Sprint 1 — Wednesday

![](https://cdn-images-1.medium.com/max/1024/1*U6CDgIAMt2l2vDoFqhwv6A.jpeg)<figcaption>Photo by <a href="https://unsplash.com/@goumbik?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Lukas Blazek</a> on <a href="https://unsplash.com/s/photos/status-report?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

### Sharing is Caring

The hardest part of a remote project is **_understanding what everyone on the team is working on_** at any point in time.

![](https://cdn-images-1.medium.com/max/640/1*kxcPMBD5obM009kRqRM2xg.png)

It’s important due to the _dependencies_ between the components different teammates are working on. Lack of information can result in these components not working as expected when they are brought together in the `development` branch.

So, what is the solution?

1. **_Use your team channel_** to ask questions and report issues.
2. **_Monitor your team channel daily_** so you don’t miss updates from your team mates. Even better, see if there’s a time of the day where all team members can be available, even if it is only for a few minutes, to chat.
3. **_Post your status_** at least every other day in the form of a text-based standup using this Markdown template:

\*\*\_\_My mood today\_\_\*\*: Use the emoji of your choice

\*\*\_\_Tasks I’m Working On\_\_\*\*:   
1. Task #1 + expected completion   
2. Task #2 + expected completion   
3. …

\*\*\_\_Tasks I’ll Be Working On Next\_\_\*\*   
1. Task #1   
2. Task #2   
3. …

\*\*\_\_I Need Help With\_\_\*\*:   
1. Question/Issue #1 — short description & what help do you need?   
2. Question/Issue #2 — short description & what help do you need?   
3. …

> Remember that reaching your team goal is more about coordination and communication than it is about technology!

### Before you Go!

Chingu helps you to get out of “Tutorial Purgatory” by transforming what you’ve learned into experience. The experience to boost your Developer career and help you get jobs.

You can learn more about **Chingu** & how to join us at [https://chingu.io](https://chingu.io/)

* * *
Building Conway's Game of Life in Javascript
Tags: p5, javascript, gamedev, tutorial
Published: 2021-09-02 11:24:07

Conway's Game of Life has amazed Computer Scientists and Mathematicians for over half a century now. For those who don't know, the Game of Life is a zero-player game that follows four simple rules and can end in chaotic, beautiful, and mind-blowing outcomes. This simple game can even be used to simulate a Turing machine (you can essentially program using the game).

Today, I'm going to be showing you how you can make this game yourself with only 100 lines of Javascript.

You can get a feel for the game here: https://playgameoflife.com/

---

###What is Conway's Game of Life?

Conway's Game of Life starts with a 2d grid, and each cell in the grid being either alive or dead. The grid will then evolve after each iteration based on the following rules:

1. Any living cell with less than 2 live neighbors dies
2. Any living cell with 2 or 3 live neighbors continues to be alive
3. Any dead cell with three live neighbors becomes a live cell
4. Any live cell with more than 3 live neighbors dies

Following these rules, each cell counts the number of live cells adjacent to it and determines its upcoming status.

---

###Tech We'll Be Using

To create our Game of Life Simulator, we are going to be using Javascript in conjunction with the following tools:

####P5.js

P5.js is an easy-to-use javascript graphics library. It is going to make displaying our cells extremely easy. You can check it out here:

https://p5js.org/

####Codesphere

Codesphere is a no-config cloud provider that will allow us to deploy our app seamlessly. We're going to use it to host our Game of Life simulator. You can learn more here:

[https://codesphere.com](https://link.codesphere.com/CZ)

####The Code

{% gist https://gist.github.com/LiorB-D/487d4ee4e59993fbe5e1279f0738d671 %}

####Cool Starting Grids

And there we go! We've created Conway's Game of Life with some pretty rudimentary javascript! Here are some cool creations you can create:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvdotq074o9yglx70v1x.gif)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28pybnkukn7xlk85vjap.gif)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fu7mvqzseuhjaw6novif.gif)
---

These are just the tip of the iceberg! By adjusting the grid length and survival rules there is literally an infinite number of patterns you can generate.

---

Hope you enjoyed it!

Happy coding from your good friends at [Codesphere](https://link.codesphere.com/CZ), the next-generation cloud provider.
Hiring full stack engineers at Setu 👨🏽‍💻👩🏽‍💻
Tags: python3, go, typescript, react
Published: 2021-09-02 11:14:30


👉 About the job

• Location — India 🇮🇳
• Tech stack —
  ◦ Backend: Python3, Golang, Flask, OpenAPI
  ◦ Frontend: Typescript, React
  ◦ Infra: AWS, Terraform

Check out the JD and apply here— https://setu.zohorecruit.in/jobs/Careers/15063000000516075/Full-Stack-Engineer?source=CareerSite

More about Setu— setu.co 
  
👉 Why Setu? 

We will spare no efforts to ensure that Setu empowers you to do the most important and impactful work of your career—
Opportunity to work closely with the founding team who built and scaled public infrastructure such as UPI, GST, Aadhaar, etc. 

• We care deeply about your development. So we work hard to provide you with: 
  ◦ Exposure to other verticals such as product, business, 
    developer experience
  ◦ A fully stocked library and unlimited book budget
  ◦ Tickets to conferences and industry events
  ◦ Weekly learning sessions on Friday where we invite both 
    team members and external experts to teach you something 
    new

• Attractive compensation. We don’t want money to ever be a 
  worry. So you can focus on doing your best work.

•Kick-ass benefits including comprehensive health insurance for you and your family, extraordinary coffee, and a beautiful office with lots of solid wood and natural light

Join us if you want to be part of a company that’s building infrastructure that will directly impact financial inclusion and improve millions of lives. No cashbacks, no growth-hacks, no bullshit. Just an audacious mission, and an obsession with craftsmanship in code.
Best Practices while Declaring JavaScript Variables
Tags: javascrip, react, django
Published: 2021-09-02 11:09:39

At first, var was the only global scope variable, but now we have let and const. Any experienced JavaScript developer will warn you against using the var scope. Don’t prompt many questions, stay with me until the last dot.

Avoid using letters.

It’s as simple as that. We need to understand what the variable stands for. Let the developer know what the value is representing. For example let fl=getFullNames(), its total different when another developer writes let fullNames=getFullNames(). It’s one of the core values while writing clean codes. Trust me, it might help you when you forget, or you want to alter something.

Always prefer const or let over var

Yes, both can be used to represent a variable, but with a different meaning. For const is used just like in other languages, the declared word is final and you cannot alter the value.

Var scope is initialized during hoisting hence might bow up some problems while working on a big project. The positive thing about let and const is that you might declare them in one block, again on the next block you declare with different values. Remember this cannot be achieved by var. Remember you can declare a variable twice when you use let.

Eg let marks=90
Function addMarks(){
Let marks=97;
Alert(marks)
//It will print 97
}
Alert(marks)

It will print the first 90.

But the best practice is to use a single variable for each name. It will help you when it comes to debugging your code. Avoid declaring these variables that you have already declared. Even when the project is large, try your level best to use a single let or constant for each sign and ents.

Declare variables directly during initialization

Here are two samples.
let marks, total
Marks=20
Total=80

Example 2:
Let marks=20; total=80

Use the second version. It shortens your code. Remember we need precise, short, and functioning code.

I believe we are now focusing only on const and lets. Always prefer to declare the variables at the top or outside the function. Your code might be easier to read. Hope at some point you will meet the error “undefined”, thus practice will save you from that error.

Avoid using words like name, constant, true, remember this is a global inbuilt js words. Kindly use your own local words.
How I Write Code: Pen & Paper
Tags: programming, ruby
Published: 2021-09-02 10:29:46

---
title: How I Write Code: Pen & Paper
published: true
description: 
tags:  programming, ruby
//cover_image: https://direct_url_to_image.jpg
---

Even though I love programming, I try not to sit in front of a computer screen too much. I do not find staring at a screen all day beneficial, not for my physical health, nor for my mental health. In the last few years, I’ve started a habit of sketching my programming ideas using pen and paper. I’m not talking here about todo lists, or making diagrams. I’m talking about actually writing code using pen and paper. [Let me explain](https://noteflakes.com/articles/2021-09-02-how-i-write-code-pen-paper).
Format Xero dates from the API
Published: 2021-09-18 17:50:06

---
title: Format Xero dates from the API
published: true
date: 2021-09-02 10:20:08 UTC
tags: 
canonical_url: https://dcblog.dev/format-xero-dates-from-the-api
---

Dates in Xero that are not already set to a datestring are in a format like `Date(1518685950940+0000)`

## How to format these

They are made up from unix timestamps in milliseconds rather than seconds, they need to be converted by taking the timestamp and times by 1,000

```

date("Y-m-d", 1518685950940 / 1000)
```

This will give you the formatted date.

When doing this over the API dynamically you can do this:

```

if (isset($inv['FullyPaidOnDate'])) {
    $date = str_replace('/Date(', '', $inv['FullyPaidOnDate']);
    $parts = explode('+', $date);
    $paidAt = date("Y-m-d", $parts[0] / 1000);
}
```
Compile your go app cross-platform easily!
Tags: go, programming, productivity
Published: 2021-09-02 09:44:15

Hello gophers! when you create an app with go, you also need to compile your app for other platforms and architectures. In go, you need to change environment variables for every compile. So i decided to make a simple tool named **CCGO** (**C**ross-platform **C**ompile for **Go**) that does this for us!


- [GitLab Repository](https://gitlab.com/aiocat/ccgo)


For now, it compiles your app to **14** different platform. but you also can make a config yourself!


It works pretty simple. Download the binary from release page and add to your path.


Now we can test the app. Lets create a empty dir and initialize our project with `go mod init example`. Then we will add a `main.go` file that contains:
```go
package main

func main() {
  println("Hello World!")
}
```
And now, we can test the ccgo. Lets run the ccgo with `ccgo example`. (the `example` is the name of the app.)


![Example Compiling Photo](https://i.imgur.com/jJKjWjH.png)


It compiled our app successfully. But where is the binaries? CCGO adds the programs to the `.ccgo` folder. If you can't see the folder in your project root, Make sure you enabled the see hidden file/folders.

![Example CCGO Folder Photo](https://i.imgur.com/PQCdENE.png)

CCGO also creates a sha1 checksum for your binary:
![Example Compiled Folder Photo](https://i.imgur.com/LR5jTxZ.png)

We also can create our own config. For this, we need to create a file named `ccgo.config.json` first. Then we can add the configs to the this JSON file. List of the configs with examples are avaible at gitlab repository `README.md` file.


Thats it! Since I just started yesterday, its current state is not very advanced. Please check the `README.md` file from gitlab repository if you want to contribute to this project.
How Do I Recover My Cash App Account Without Using A Linked Phone Number? 
Published: 2021-09-02 09:40:51

Don’t worry if you don’t know How Do I Recover My Cash App Account as the procedure of recovering your Cash App account is quite simple and straightforward.Here, you have toenter the email address that must be associated with your Cash App account if you don’t have access to your phone number.
https://www.experts-support.com/blog/how-do-i-recover-my-cash-app-account
What Are The Reasons Behind Sbcglobal Net Email Not Working Problems? 
Published: 2021-09-02 09:40:05

Are you not feeling well as your Sbcglobal Net Email Not Working in a proper manner?If really, then you should instantly take necessary aid to determine why you are facing these problems with your account. Once you determine it on your own, you will be able to get a permanent solution in no time. 
https://www.experts-support.com/blog/sbcglobal-email-not-working
Wordpress API request problem.
Tags: help, wordpress, http
Published: 2021-09-02 09:28:26

Let's assume a standard wordpress website on `https://example.com.au/`. We have created a dev version of the website at `https://example.com.au/dev`. 

We have installed and enabled a tool called `miniOrange` into our Wordpress 5.8 installation on the dev site. We have set up application passwords. Because we're using the free version of miniOrange, we've enabled Basic Authentication with Base64 Encoding of the username:password tuple. 

We're using Visual Studio Code's REST Client to send the request. The request is below (slightly obfuscated):
```
POST https://www.example.com.au/dev/wp-json/wp/v2/pages HTTP/1.1
Content-Type: application/json
Authorization: Basic WeAreNotAllowedToShowYouThisString

{
    "slug": "a-test",
    "status": "draft",
    "content": "<h1>booM</h1>",
    "title": "A Test"
}
```
When we send POST requests to the `https://example.com.au/dev/wp-json/wp/v2/pages` endpoint we receive the following: 
```
HTTP/1.1 401 Unauthorized
Connection: close
X-Powered-By: PHP/7.4.22
Content-Type: application/json; charset=UTF-8
Content-Length: 153
Date: Thu, 02 Sep 2021 09:15:40 GMT
Server: LiteSpeed
Alt-Svc: quic=":443"; ma=2592000; v="43,46", h3-Q043=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-25=":443"; ma=2592000, h3-27=":443"; ma=2592000

{
  "status": "error",
  "error": "INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE",
  "code": "401",
  "error_description": "Authorization header must be type of Basic Token."
}
```
There are a number of confusing things here, not least being that we have `Authorization: Basic WeAreNotAllowedToShowYouThisString` but we're receiving `Authorization header must be type of Basic Token.`

Has anyone seen anything like this and if so, what did you do to solve it? (We have written to miniOrange too.)
QuickApps - Issue When Setting the Animation Style of an Image Element
Tags: huawei, android, quickapps
Published: 2021-09-02 09:12:09

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

To achieve the image switchover effect, two image elements are stacked. One element's transparency changes from 1 to 0 to gradually disappear, so the other can appear. However, the previous image occasionally flickers and then disappears.

The code where the exception occurs is as follows:

{% gist https://gist.github.com/devwithzachary/3bc854e33a49f39dc40b2bb7ec7d8a44 %}

In the preceding code, the switchover effect is implemented by changing the transparency of the two image elements. The transparency is set in CSS of the second image element. However, the transparency animation is configured on this element in the imgcomplete() method. That is, the transparency value changes from 1 to 0. But the transparency variable preop bound to the CSS is set to 1.

This exception occurs when the animation completion time is earlier than the CSS implementation time.

Instead delete `style="{{'opacity:' + preop + ';'}}"` of the second image element in the template. Instead, change the transparency from 0 to 1 to achieve the effect.

{% gist https://gist.github.com/devwithzachary/fe5d34e51c3970597a214945de475898 %}

For more information, please visit the following links:

Animations
https://developer.huawei.com/consumer/en/doc/development/quickApp-References/quickapp-api-animate-0000001074264335.

Common Events
https://developer.huawei.com/consumer/en/doc/development/quickApp-References/quickapp-events-0000001123530338