teleren/devto huggingface dataset:
Go Course: Panic and Recover
Tags: go, tutorial, beginners
Published: 2022-07-25 09:03:45


So earlier, we learned that the idiomatic way of handling abnormal conditions in a Go program is using errors. While errors are sufficient for most cases, there are some situations where the program cannot continue.

In those cases, we can use the built-in `panic` function.

## Panic

```go
func panic(interface{})
```

The panic is a built-in function that stops the normal execution of the current `goroutine`. When a function calls `panic`, the normal execution of the function stops immediately and the control is returned back to the caller. This is repeated until the program exits with the panic message and stack trace.

_Note: We will discuss `goroutines` later in the course._

So, let's see how we can use the `panic` function.

```go
package main

func main() {
	WillPanic()
}

func WillPanic() {
	panic("Woah")
}
```

And if we run this, we can see `panic` in action.

```bash
$ go run main.go
panic: Woah

goroutine 1 [running]:
main.WillPanic(...)
        .../main.go:8
main.main()
        .../main.go:4 +0x38
exit status 2
```

As expected, our program printed the panic message, followed by the stack trace, and then it was terminated.

So, the question is, what to do when an unexpected panic happens?

## Recover

Well, it is possible to regain control of a panicking program using the built-in `recover` function, along with the `defer` keyword.

```go
func recover() interface{}
```

Let's try an example by creating a `handlePanic` function. And then, we can call it using `defer`.

```go
package main

import "fmt"

func main() {
	WillPanic()
}

func handlePanic() {
	data := recover()
	fmt.Println("Recovered:", data)
}

func WillPanic() {
	defer handlePanic()

	panic("Woah")
}
```

```bash
$ go run main.go
Recovered: Woah
```

As we can see, our panic was recovered and now our program can continue execution.

Lastly, I will mention that `panic` and `recover` can be considered similar to the `try/catch` idiom in other languages. But one important factor is that we should avoid panic and recover and use [errors](/courses/go/errors) when possible.

If so, then this brings us to the question, when should we use `panic`?

## Use Cases

There are two valid use cases for `panic`:

- **An unrecoverable error**

Which can be a situation where the program cannot simply continue its execution.

For example, reading a configuration file which is important to start the program, as there is nothing else to do if the file read itself fails.

- **Developer error**

This is the most common situation. For example, dereferencing a pointer when the value is `nil` will cause a panic.

---

_This article is part of my open source [Go Course](https://www.karanpratapsingh.com/courses/go) available on Github._

{% github karanpratapsingh/go-course %}
List of some useful GitHub repositories
Tags: github, resources, dsa, interview
Published: 2022-07-25 08:54:07

**List of some useful GitHub repositories !**

1. Competitions-and-Programs-List- https://lnkd.in/eebaFFHx

2. Paid-Internship-List- https://lnkd.in/dfVX49-u

3. Interviews-Resources- https://lnkd.in/gES5ix6g

4. DSA-Resources- https://lnkd.in/gBWc6sCc

5. Python-projects- https://lnkd.in/dXAVCnVG

6. Free-courses-with-Certificates- https://lnkd.in/e2ZvMgC

7. Free-programming-books- https://lnkd.in/dhH_excc

8. Data-Science-Projects- https://lnkd.in/dJXjUerQ

9. Portfolio-Websites- https://lnkd.in/d5dVap5K

10. Interview Experience- https://lnkd.in/gS45qVgP
Next.js is the master of all key in frontend
Tags: programming, webdev, javascript, tutorial
Published: 2022-07-25 08:50:00

In today's story, why you should choose next.js over Create React app and Gatsby. 

[Video link](https://www.youtube.com/shorts/JAkrNadoHnw)

**Conclusion**
Until next time, have a good day.

Keep developing!!

Our website [iHateReading](www.ihatereading.in) || [Youtube](https://www.youtube.com/channel/UC6I-Tz6QwYbJpoIK7l0NtXA) || [Twitter](https://twitter.com/treyvijay)
Implementing HowlerJs Audio In Ruby on Rails
Tags: ruby, javascript, rails, webdev
Published: 2022-07-25 08:46:49

Howler.js is an audio library for the modern web. It defaults to Web Audio API and falls back to HTML5 Audio. This makes working with audio in JavaScript easy and reliable across all platforms.
We will learn how to implement  it in our Ruby on Rails Applications
{% youtube gBJrRrErnCo %}
[4/40 things about data] The second most important rule of working with data: the fastest data is the one you don’t read
Tags: data, database
Published: 2022-07-25 08:44:00

As simple as it sounds, most people forget about using one of the most important database features: indexes. Well, you also need to think about what’s the data you actually need, a lot of apps are full of `select * from table`.

The problem is, as your system grows, so does the amount and complexity of queries. Knowing what data you need becomes harder. To avoid that you need… yes, data about how you query your data.
Appwrite Loves Open Source: Why I Chose to Support Flow-Launcher
Tags: opensource, appwrite
Published: 2022-07-25 08:37:25

Open source is at the ❤️ of everything we do at Appwrite, and we want to enable and foster the open-source community that helped us grow to nearly 24,000 stars on [GitHub](https://github.com/appwrite/appwrite).
Open-source projects, though, require a great deal of effort to maintain and grow. We use open-source tools every day to build Appwrite, and we want to help our community.
To give back, each Appwrite engineer gets to pick an open-source project for Appwrite to sponsor for one year.

## All I Want Is to Search My PC 🔍
I've always been both a Linux and Windows user. While using the latter, there was only one thing that I always envied macOS users: **Alfred**.

Everyone knows the joke by now: Windows search is awful and should be burned at the stake… 

![Bad windows search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zivzduwv8lb00boqelxr.jpg)

Lucky for us the **open-source community** is here to rescue us! While browsing through Reddit, I came upon [Flow-Launcher](https://github.com/Flow-Launcher/Flow.Launcher), and I immediately fell in love with it! 😍

### So What Can Flow-Launcher Do?
Simply put… Everything! Seriously it has an Everything plugin that allows you to search your files at lightning speed! 

The [plugin ecosystem](https://www.flowlauncher.com/docs/#/plugins) is amazing!! Do you want unit and currency conversion? You got it. Do you want GitHub integrations, instant translation, hex color conversion, putty, gifs, plex, and much much more? Guess what: you got it.

Do you want to find a cure to the existential dread born from the realization that we're all monkeys with shoes on a speck of dust orbiting around a small star in an uncaring universe… ehm, well… sorry, no luck here, but did I mention plugins? 

And if your favorite app/workflow doesn't have a plugin, you can simply **write a new one** and share it with the community.

Somehow the open-source community managed to fix something that a multi-billion dollar company like Microsoft couldn't. If you are a Windows user, Flow-Launcher will make your life a lot easier.

## Learn More about Appwrite

Appwrite is an open-source Backend-as-a-Service (BaaS), packaged as a set of Docker micro-services, to give developers of any background the tools necessary to build modern apps quickly and securely.

Chat with us on Discord, or, Learn more about Appwrite:

Check out Appwrite as the backend for your next [Web](https://appwrite.io/docs/getting-started-for-web), [Flutter](https://appwrite.io/docs/getting-started-for-flutter), or [Server-side](https://appwrite.io/docs/getting-started-for-server) application. Here are some handy links for more information:
* [Appwrite Contribution Guide](https://github.com/appwrite/appwrite/blob/master/CONTRIBUTING.md)
* [Appwrite Discord](https://appwrite.io/discord)
* [Appwrite Github](https://github.com/appwrite)
* [Appwrite Documentation](https://appwrite.io/docs)
Before Toptal Live Coding Interview
Tags: toptal, javascript, remote
Published: 2022-07-25 08:16:00


## Overview


It will take approximately 1 hour. It looks like 

- Introduction & Rules
- Entering your personal and professional details like
  - Your experience for each tech like `ruby`, `js`, `front-end`, `backend`
  - Location,
  - Your recent projects & most exciting thing about them kinda stuff
- Making sure you(yourself) completed the last coding-challenge.
  - they will ask you about the problems
  - what you needed to do 
  - how you approached
- 2 Algo-problems
  - You will get as much time you need to understand the problem. You can ask the interviewer.
  - timer starts only when you say you understood.
  - You don't have to explain the solution while you solve.
  - if you are about to finish 1st in `15 mins` then you will be given the 2nd problem.
  - you have to share the entire screen, not just a window
  - you can google language syntax but not the algo-solution 

---

## Preparation Guide
- Problems will not be `hard` because you only have `15 mins`
- Read & practice lessons from `HackerRank`, `Codility`, `Project Euler`
- Take enough time to understand the problem
- do brainstorming on paper if you feel so
- keep calm, they will normally add extra 2 mins
How to keep your email address private in GitHub
Tags: github, privacy, webdev
Published: 2022-07-25 08:01:00


I have been auditing the privacy of the apps that I use recently. After switching to a more privacy-conscious email provider ([Tutanota](https://tutanota.com/)), I also wanted to review where I publish that email address to.

One important place to check is any Git host you use. In your Git configuration, you must provide an email to serve as an identifier for your commits. 

Can you just provide a bogus email to GitHub and be done with it then?

According to GitHub, if you want to ensure that commits are attributed to you and appear in your contributions graph, then you should provide an email address associated with your GitHub account in your Git configuration. If this is not important to you, then provide whatever you want!

Let's update our configuration with an an anonymous email to get the best of both worlds.

## Update GitHub settings

Go to <https://github.com/settings/emails>. There is an option called "**Keep my email address private**".

Check the box!

<img src="https://www.roboleary.net/assets/img/blog/2022-07-25-how-to-keep-your-email-private-on-github/email-settings-github.png" alt="email settings github" loading="lazy" width="646" height="218">

This will remove your public profile email. A `noreply` email address is generated for you. It is *3703647+robole@users.noreply.github.com* for me. Now, this `noreply` email address is used when performing web-based GitHub operations (e.g. edits and merges) and when emails are sent on your behalf.

There is a second option "**Block command line pushes that expose my email**". If a commit contains a private email address associated with your GitHub account, the commit will be refused. It is a good idea to check this one too IMO.

That's the activities covered on GitHub.com. What about on the the command-line with Git?

## Update Git config

Let use the `noreply` email address in our Git configuration.

To set the email address for every repository on your computer:

1. Open a Terminal.
2. Set an email address in Git. I want to use my GitHub-provided `noreply` email address, but you can use any email address.

   ```shell
   git config --global user.email "3703647+robole@users.noreply.github.com"
   ```

3. Confirm that you have set the email address correctly in Git:

   ```shell
   git config --global user.email
   3703647+robole@users.noreply.github.com
   ```

If you want to check it works as expected. Push a commit to a repo on GitHub and go to that commit on the website. You can add `.patch` to the URL and you will see a summary of the metadata of the commit (as below). Check the `From` field.

<img src="https://www.roboleary.net/assets/img/blog/2022-07-25-how-to-keep-your-email-private-on-github/commit-metadata-github.png" alt="commit metadata summary on github" loading="lazy" width="1268" height="392">
Today's Fun Joke For Developers - Daily Developer Jokes
Tags: jokes, dailydeveloperjokes
Published: 2022-07-25 08:00:19

---
title: "Today's Fun Joke For Developers - Daily Developer Jokes"
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/5e12594a73e61.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:___ Why did the document store go out of business?

___A:___ It had NoSQL.
 -->
[XDPoS2.0] Forensics detection system testing is well underway 🚀
Tags: xdc, xdpos2, blockchain, xdcnetwork
Published: 2022-07-25 07:58:44

📣 We are pleased to announce a brand NEW realtime forensics detection system for XDPoS 2.0! Testing is well underway.
The system is powered by:
1️⃣ NodeJs Express + Docker + mongoDB as its data persistent layer
2️⃣ Typescript + React + webpack + D3 for the UI component
3️⃣ Github Action pipeline for CI/CD

### Updates for the week:

- Added new feature to show realtime committed block within XDCPoS chain on stats server: https://github.com/XinFinOrg/XDCStats
- Added Automatic deployment pipeline for Forensics UI: https://github.com/XinFinOrg/XDC_Forensics
- Successfully passed internal devnet testing. (Feel free to take a quick glance at http://144.126.140.1:8888)

### 🛠 For the coming weeks, we will be adding more exciting features to the forensics system, including:

1. Vote equivocation system(Detect suspicious behaviour from voting mechanism of XDC v2 consensus).
2. Automatic deployment pipeline for stats server.
3. Developer documentation improvements


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3t14w37cgwkjgvrp8fu.png)
Okteto: Need for developer tooling
Tags: kubernetes, okteto, dx
Published: 2022-07-25 07:49:00

In the early days (read precursor to containerization) development cycle was straight forward. You code with an editor, compile, build, run and test and are done. Deployment would be some version of copying to another device and setting come configuration.
The game changed with the advent of docker. One sets up a development host (often local machine) and uses some orchestration (aka docker-compose) to run locally qualify(unit-test) and push. CI environment is another world where configurations are re-applied an integration scenario is tested and given a go-ahead. Production is of-course the real place where hammer meets the iron and battle rages on ...

Developing this way is painful due to:
- multiple tools that need be used for each environment (eg: docker-compose on DEV, kubernetes on PROD)
- maintaining configuration parity across environments
- managing configuration drifts from cluster to code
- local development is a resource hog (in terms of cpu and battery; the process qemu-system-aarch64 was constantly taking >98% of my resources)

Expectations from a cloud-native DX:
- should be fast
- change reflection should be seamless (think live-preview)
- configuration overhead should be minimal
- simple flow - installation/setup, creating, tweaking and destroying environments should be easy

> [Okteto](https://github.com/okteto/okteto) accelerates the development workflow of Kubernetes applications. You write your code locally and **okteto** detects the changes and instantly updates your Kubernetes applications.

Typical workflow with okteto is:
0. configure okteto to connect to your cluster
1. `git clone <your repo>`
2. `okteto up` that helps you seamlessly deploy and synchronize apps to the cluster with:
 - bi-directional synchronization service through configuration
 - automatic local and remote port-forwarding for connecting through `localhost` and for attaching debuggers
 - interactive terminal for build-deploy-test cycles

---
*workflow, configuration and other details will follow in next posts of the series*
How To Create Products In Shopify Store
Tags: webdev, beginners, shopify, tutorial
Published: 2022-07-25 07:26:01

Learn How To Create Shopify Store (Shopify Store Setup Tutorial), Learn in English. Create Shopify Store, and earn money from home. Shopify Store creation and setup process for beginners. If you want to start drop shipping, or if you have brand and want to sell online by having ecommerce website then you can use Shopify to sell products.  Watch the complete video and learn How To Create Products in Shopify Store.

Shopify is an online Ecommerce platform which allows users to create online store. Using Shopify you can sell digital products, physical products and can also start drop shipping business. Shopify is one of the biggest ecommerce platforms and it is used by biggest companies across the world.

In this video I have shown complete process to create products manually and to bulk upload the products using csv file. This video is helpful for all the beginners and also to users who are already using Shopify but have lesser knowledge about Shopify.

Click the image given below to open the tutorial or click on link -> [Add Products In Shopify](https://youtu.be/FD_eGl6dB1k)


[![Add Products In Shopify](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/og6cz0s1qwpkw5qbukih.png) ](https://youtu.be/FD_eGl6dB1k)
How to shutdown a window using python? one-liner Python code
Tags: python, programming, beginners, tutorial
Published: 2022-07-25 07:05:00

Although windows provide a graphical user interface to showdown, restart, logoff, and hibernate our computer. But we can also write a Python script to showdown or restart our window with specified time intervals. 
Shutting down the computer is an operating system functionality, so to achieve this in Python, we can use the Python inbuilt os module to interact with the operating system.

##Shut Down the Window using Python 

Windows provide the shutdown /s terminal command to shut down the wind. And it will immediately shut down the computer. 
#####Command
```bash
shutdown /s
```
#####Shutdown program
```python
import os
os.system("shutdown /s")
 ```
> Note: The system() method will execute the shutdown /s command for the window.



##Shut Down the Window after a specific period in Python 
The shutdown command also accepts the /t flag for the period shutdown. It comes very handy when we want to set the time-out period before shutdown.
#####Command 
```bash
shutdown \s \t xxx
```

> Note: xxx are the number of seconds for the shutdown.

#####Shutdown program
```python
import os
 
os.system("shutdown /s /t 10")
 
print("Your Pc will shut down in 10 seconds")
```

##Restart the window using Python 
To restart the window immediately, we can raise the /r flag witht the shutdown command.
#####Command
```bash
shutdown /r
```
#####Restart program
```python
import os
 
os.system("shutdown /r ")
```

##Restart the Window after xxx seconds
We can also specify the xxx number of seconds to set a restart process. To set the time period we can use the /t flag and specify the xxx seconds.
#####Command
```bash
shutdown /r /t 10
```
#####Restart Program
```python
import os
 
os.system("shutdown /r /t 10")
 
print("Your Pc will restart in 10 seconds")
```

##Restart and shut down with a comment 
We can also specify the reason, message, or comment for the shutdown or restart processes, so we can know why we initiated the shutdown or restart.
#####Command 
```bash
shutdown /s /c message
```
#####Example
```python
import os
 
comment ="Time for work out"
 
os.system(f"shutdown /s /t 10 /c {comment}")
```
Exploring the NextJS bundle analyzer
Tags: react, nextjs
Published: 2022-07-25 06:54:52

Did you know that Next.js gives us an option to analyze our output bundle size?

While creating our application, it's hard to determine what will be included in the final build output.

But no worries, I'll show you how you can add the bundle analyzer to analyze the build output in this article.

## Installing the Next.js bundle analyzer

First, let's take an existing Next.js project to work on.
I will use my [Next markdown blog](https://github.com/rebelchris/next-markdown-blog) for this.

The first thing we want to do is install the analyzer with the following command.

```bash
npm install @next/bundle-analyzer
```

The next part is to create/modify our `next.config.js` file.

The first element we need is a definition of the analyzer, which we can import like this.

```js
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
});
```

The following step might depend on the fact that you already have some configuration.

If not, you can do the following export.

```js
module.exports = withBundleAnalyzer({});
```

Otherwise, you have to wrap your existing export with the bundle analyzer.

```js
module.exports = withBundleAnalyzer({
  reactStrictMode: true,
});
```

## Running the analyzer

To run the analyzer, we have to use the environment variable defined above.

The command would look like this:

```bash
ANALYZE=true npm run build
```

When you run this command, it will automatically open two pages in your browser.

- The client-side code
- The server-side code

![Next.js client side bundle analyzer](https://cdn.hashnode.com/res/hashnode/image/upload/v1657864420914/8ygVQ4W1r.png)
![Next.js server side bundle analyzer](https://cdn.hashnode.com/res/hashnode/image/upload/v1657864412561/yt81e4cX9.png)

You can quickly inspect what takes up the most space, or when using a Monorepos, which packages might have been included twice unintentionally.

### Quick command

We can also create a quick command, so we don't have to worry about setting this environment variable on every call.

Head over to your package.json file and add a new script like this.

```js
"scripts": {
	...
	"analyze": "ANALYZE=true next build"
},
```

Now you can quickly run the analyzer with the following command.

```bash
npm run analyze
```

I've also uploaded the changes to the project so you can view them on [GitHub](https://github.com/rebelchris/next-markdown-blog/tree/bundle-analyzer).

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
How to create Public URL in Django Project to access in Other Machines
Tags: django, python, vscode, djangorestframework
Published: 2022-07-25 06:53:45

I'm working Django Project.

1. How to create a Public IP permanently for Localhost(127.0.0.1:8000) IP in Django Project.
2. After Creating Public URL, how to allow access for Other users without Source Code.

when I run **python manage.py runserver x.x.x.x:8088** in command prompt it is generating a URL with specified IP address. But when I share/open this URL with others it is not working

Can any one help me to configure this issue.

Thanks in advance.