teleren/devto huggingface dataset:
Short-circuit Evaluation Of Logical Expressions In Python
Published: 2022-12-03 22:19:45

I read about a short-circuit behavior in python that strategically places a "guard" just before a logical expression that might cause an error after evaluation. The book said it's a clever technique called the "guardian pattern"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ipbcdp8i21uifeiwrioe.jpg)
When Python is processing a logical expression, it
evaluates the expression from left to right because of the definition of "and", if x is less than 2, the expression x >= 2 is False and so the whole expression is False regardless of whether (x/y) > 2 evaluates to True or False
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ww615qbnrdwt9pmgrlb.png)
The first and the second examples did not fail because in the first calculation y was non zero. In the second one the first part of these expressions x >= 2 evaluated to False so the (x/y) was not even executed due to the short-circuit rule and there was no error. The third calculation failed because Python was evaluating (x/y) and y was zero, which causes a runtime error.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uuk4exfd70mv8qtehw83.png)

When Python detects that there is nothing to be gained by evaluating the rest of a logical expression, it stops and does not do the computations for the rest of the expression. In this case, since the first evaluation is false the whole expression will also be false regardless
![Spongebob heading out meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pokkpy7thdm2sbcb55tx.jpg)

This is what "short-circuiting" the evaluation means.
This seems like a fine point and this clever technique is called the guardian pattern

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/her9jlty4wbgqeivimrt.jpg)
I asked OpenAI's chatGPT to write a ballad about Open source tech 😂
Tags: opensource, webdev, github, python
Published: 2022-12-03 21:04:02

Normally I mostly write about everything [Medusa](https://medusajs.com/) related, but could not help sharing this one. 

Also, used OpenAI for the cover photo 😉

---

_In the world of technology,
Where innovation knows no bounds,
A new way of building rose,
With a philosophy that astounds._

_Open source, the name it bears,
A community united,
Sharing knowledge and skills,
To create tools that excite._

_From Linux to WordPress,
And countless projects in between,
Open source tech has flourished,
A force that cannot be seen._

_No longer bound by profit,
Or the will of just a few,
Open source gives us all,
The power to create anew._

_With open source, we are free,
To use, modify, and share,
A world of possibilities,
A future beyond compare._

_So let us sing its praises,
And join the open source movement,
Together we can build,
A future that's worth the toil._

_A future that's bright and bold,
A future that's ours to hold,
A future that's open and free,
A future that's meant to be._
5 Scenarios When a Low-code Platform Fails to Work Properly
Tags: lowcode, beginners, webdev
Published: 2022-12-03 20:53:15

An application structure that is supposed to be the most typical low-code limit. Few application patterns, such as choose, conclude, or compare, is supported by almost all low-code tools. It saves time for programming and frees up the developer’s routine from handling many common files and records in tasks to his project manager, but it also limits the application’s functionality.

So, real-world low-code solutions, like Retool, Bubble, Webflow, or even Builder Studio do not work with the programming language updates; after all, they override them. The fact that only one person can work on it slows the development process and puts the project’s velocity at a risk seems to be a new world in the development cycle. Relying on tabular or drag-and-drop functionality is a similar restriction.

Five simple scenarios where LCDP doesn't work is [here](https://flatlogic.com/blog/5-scenarios-when-a-low-code-platform-fails-to-work-properly/).
Urgent Orthopedics and Trauma Care
Tags: urgent, orthopedic, care, trauma
Published: 2022-12-03 20:51:50


Urgent Orthopedics and Trauma Care provides specialized care to patients with musculoskeletal injuries or conditions affecting bones, muscles, ligaments, tendons, and joints that are not considered life-threatening but still require immediate medical attention. Urgent Orthopedics and Trauma Care patients no longer have to seek treatment at a regular emergency room with no or limited specialized care or experimenting with remedies that may only exacerbate the problem.
**Walk-In Care for Patients of All Ages**
Urgent Orthopedic Care expert healthcare providers can manage orthopedic injuries , adults, and children ages two and up. If a patient does require follow-up care, they will have immediate access to board-certified physicians.
*https://urgentorthopedicscare.com/*
Top 10 Visual Studio Code Extensions you should use as a web developer
Tags: vscode, programming, webdev, career
Published: 2022-12-03 20:01:52

Here are ten top Visual Studio Code extensions that you might find useful as a web developer:

1. Live Server: This extension allows you to run a local development server with live reloading, so you can see your changes in the browser as you make them.
2. Prettier: This extension automatically formats your code according to a consistent style, saving you time and helping you to avoid common coding errors.
3. ESLint: This extension checks your code for errors and potential problems, and provides suggestions for how to fix them.
4. Debugger for Chrome: This extension allows you to debug your JavaScript code using the Chrome DevTools directly from within Visual Studio Code.
5. IntelliSense for CSS class names in HTML: This extension provides autocomplete suggestions for CSS class names in your HTML files, making it easier to style your pages.
6. Auto Close Tag: This extension automatically adds closing tags to your HTML and XML elements, saving you time and reducing the chance of coding errors.
7. GitLens: This extension provides enhanced Git integration, including advanced history and blame information, code lens, and more.
8. Path Intellisense: This extension provides autocomplete suggestions for file paths in your code, making it easier to navigate your project and avoid errors.
9. Project Manager: This extension allows you to easily switch between different projects and save your workspace layout, so you can quickly pick up where you left off.
10. Color Picker: This extension provides a color picker that you can use to easily select and insert colors in your CSS files.

Overall, these are just a few examples of useful Visual Studio Code extensions for web development. There are many other extensions available, and the specific ones you use will depend on your preferences and the specific needs of your project.
How to negotiate when getting a job offer
Tags: webdev, javascript, beginners, programming
Published: 2022-12-03 19:55:21

Negotiating when getting a job offer can be a challenging but important part of the hiring process. Here are a few tips for negotiating effectively when you receive a job offer:

- Research and understand the market value for the position you're being offered. This will help you to determine a reasonable range for your salary and benefits and will give you a basis for making your case.

- Be prepared to justify your request for higher compensation. This might include highlighting your relevant experience and skills, demonstrating your value to the company, or providing examples of your achievements and successes.
 
- Be open and transparent about your salary and benefits expectations. Be clear and specific about what you're looking for, and be prepared to explain why you believe you're worth it.
 
- Be willing to compromise and be flexible. While you want to get the best deal possible, it's important to remember that the negotiation is a two-way process. Be open to discussing different options and alternatives, and be prepared to make concessions if necessary.

- Follow up and keep the conversation going. After the initial negotiation, be sure to follow up with the hiring manager to confirm the details of the offer and to address any outstanding issues. This will help to ensure that both you and the company are on the same page and that the offer is fair and reasonable.

Overall, negotiating when getting a job offer can be a challenging but important part of the hiring process. By following these tips, you can increase your chances of getting the compensation and benefits you deserve.
How to Install Unity ML-Agents Release 20 on Mac
Tags: unity3d, mlagents, machinelearning
Published: 2022-12-03 19:52:54

---
title: How to Install Unity ML-Agents Release 20 on Mac
published: true
description: 
tags: unity, mlagents, unity3d, MachineLearning
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-03 19:45 +0000
---

Mac OS X 12.2.1, M1 Macbook Pro

Here are the steps I did:

* Add the package by URL: git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_20

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iqo5ehu3dpwc6ptbn7q5.png)

* Setup conda environment in your Unity's project folder
```
conda create -n unity-mla python=3.9.7 -y
conda activate unity-mla
conda config --add channels pytorch
conda install pytorch torchvision -c pytorch
conda install grpcio h5py -y
pip install mlagents==0.30.0 -q
```

* Run mlagents-learn
```
mlagents-learn --help
```

* Run through this tutorial:

https://github.com/Unity-Technologies/ml-agents/blob/release_20_docs/docs/Learning-Environment-Create-New.md
Car "BnB" - API Documentation
Published: 2022-11-05 01:07:27

baseUrl =_"http://localhost:3001/"

**Note:**
To access the API you need to sign_up as a user and use the Authorization’s Bearer token to access the other end-points

## API End-points

### User end points
#### <u>Sign-up a user</u> 

> baseUrl/users
  Method: Post
parameter : `{ user: { name: "Freeman", password: "your password" }}`

Once you make this request and it is successful, a **Bearer token** is generated in the response Header - Authorization. 
Copy the Bearer token and paste it in the header section of any end-point request with key - **Authorization**, this will authorize all other request to other end-points as the current user.

#### <u>Sign in a user</u>

> baseUrl/user/sign_in
Method: post
parameter : `{ user: { name: "Freeman", password: "your password" }}`
A Bearer token is also generated once tis request is successfull.

#### <u>Log out user</u>
> baserUrl/user/sign_out
method: delete

Copy the Bearer token from the Signed in user and set it as the value of the Authorization key in the request header.

### Car End points
#### <u>Create Car</u>

> baseUrl/cars
method: post
parameter: ```{ car: { brand: 'Lexus', model: 'RX 350', year_released: '2021', featured_image: 'your image string link', specifications: 'Your specs' } } ```
**_requires token as well_**

#### <u>List all Cars</u>
>baseUrl/cars
method: get
**_requires token as well_**

#### <u>Delete car</u>
> baseUrl/cars/:id
method: delete
parameter is the `id` of the car. 
**_requires token as well_**

### Reservation Endpoints
#### <u>Create Reservation</u>
> baseUrl/reservations
Method: post
Parameter: ``` { city: "Port Harcourt", date: "2022-12-03", car_id: 2, user_id: 9 }```
**_requires token as well_**

#### <u>List All Reservations by current user</u>
> baseUrl/reservations
Method: get
**_requires token as well_**

#### <u>Delete reservation </u>
> baseUrl/reservations/:id
Method: Delete
Parameter is the `:id` of the reservation to be deleted.
**_requires token as well_**


### Thank you for using this API
Stars API ⭐🌟
Tags: python, flask
Published: 2022-12-03 19:13:40

Stars API , get all stars in universe at one place .



_This is the latest version of Stars-API . [version- 2]_

This Stars API is made by [Junaid](https://www.abujuni.dev) . It also includes images .
![demo1](https://i.ibb.co/3fgSsfz/2846f3d21b0c.png)
_Star Data by [Junaid](https://www.abujuni.dev) ._

**Stars API is Now online at https://starsapi.abujuni.dev (or) https://stars-api.onrender.com .**

## Index

- [Stars Data API](#star-data-api)
- [Star Data Search API](#star-data-search-api)
- [Star Images Search API](#star-images-search-api)
- [Installation](#installation)

## Star Data API
![demo1](https://i.ibb.co/3fgSsfz/2846f3d21b0c.png)
_Star Data by [Junaid](https://www.abujuni.dev) ._

Index page is the API which shows all stars in json format , every star data is in a array format .

```
http://127.0.0.1:5000/
```

_Tip : This API is easy to make a flatlist react app ._

## Star Data Search API
![demo3](https://i.ibb.co/cDnL3WT/01ed951737e5.png)


```
http://127.0.0.1:5000/stars?name=Proxima Centauri
```

or

```
http://127.0.0.1:5000/stars?name=sun
```

**Return**

```
{"data":{"Distance":1.5813e-05,"Gravity":274.2691614596,"Mass":1.0,"Radius":1.0,"Star_name":"Sun"},"message":"Success !"}
```

## Star Images Search API

![demo2](https://i.ibb.co/r6dT5SS/49d466e80992.png)

```
http://127.0.0.1:5000/stars-img?name=Proxima Centauri
```

or

```
http://127.0.0.1:5000/stars-img?name=sun
```

**Return**

```
{"img_url":"http://images-assets.nasa.gov/image/PIA18906/PIA18906~thumb.jpg","message":"Success !"}
```

## Installation
{% embed https://github.com/junaidcodingmaster/Stars-API %}
- Go to this repo(given above), download the latest version of Stars-API as Zip.
- Extract zip file and open terminal in that extracted folder.
- Install all requirements using -> `pip install -r requirements.txt`
- Than type -> `flask run`
- heyy ! , Star API is running at http://127.0.0.1:5000/


## Where is the API ?
Stars API is hosted at https://starsapi.abujuni.dev or https://stars-api.onrender.com

---

**Made By [Junaid](https://www.abujuni.dev) .**
Solving day 03 of Advent of Code 2022 in JavaScript
Tags: challenge, adventofcode, javascript, video
Published: 2022-12-03 18:37:45

---
title: Solving day 03 of Advent of Code 2022 in JavaScript
published: true
description: JavaScript walkthrough of Advent of Code 2022 (day 03)
tags: challenge, AdventOfCode, javascript, video
series: Advent of Code 2022 in Javascript
---

{% youtube nFD8ZessRro %}
Create a CLI script in your NextJS project
Tags: nextjs, cli
Published: 2022-12-03 18:33:26

You put everything you need in your NextJS project: pages, code, tests, stories... Some of these components come out of the box, like pages. You can add the others easily with Jest, Storybook... you name it.

Sometimes you wish you would also have some scripts you can call from the command line. From such a script, you could reuse the app code you already wrote and also take advantage of the app environment. For example, the Prisma schema and database connection.

There are no scripts folder in a NextJS app by default, so let's build it! We are going to use tsx, which will handle everything for us.

From your NextJS app, install tsx:

```
yarn add -D tsx
```

Create `scripts/my-script.ts`:

```
console.log("Hello, NextJS+CLI");
```

Alright, this is just another Hello World script. But here you can use import to access your existing NextJS code from `src` or other directories. Your app environment is available too.

Declare your script in `package.json`:

```
...
"scripts": {
  ...
  "my-script": "tsx scripts/my-scripts.ts"
}
```

Et voilà! Your script is ready to shine:

```
yarn my-script
```

That was fairly easy thanks to tsx!
Top Sites for Education and Career Enhancement
Tags: webdev, programming, datascience, tutorial
Published: 2022-12-03 18:28:01

➢ ► FREELANCING
➢(http://www.fiverr.com/
➢http://www.upwork.com/
➢http://www.odesk.com/
➢http://www.elance.com/
➢http://www.99designs.com/
➢http://www.freelancer.com/
➢http://www.guru.com/
➢http://www.peopleperhour.com/
➢http://www.freelanced.com/
➢http://www.ifreelance.com/

)
➢ ► CAREER
➢https://www.linkedin.com/
➢https://www.indeed.com/
➢https://www.naukri.com/
➢https://www.monster.com/
➢https://www.careercloud.com/
➢https://www.dice.com/
➢https://www.careerbuilder.com/
➢https://www.jibberjobber.com/
➢https://www.glassdoor.com/index.html

➢ ► RESUME
➢https://zety.com/
➢https://www.resumonk.com/
➢https://www.resume.com/
➢https://www.visualcv.com/
➢https://www.cvmaker.com/
➢https://resumup.com/
➢https://resumegenius.com/
➢https://www.resumebuilder.com/
➢http://www.resumebaker.com/
➢https://enhancv.com/

➢ ► INTERVIEW PREPARATION
➢https://www.ambitionbox.com/about-us
➢https://www.acetheinterview.com/
➢https://www.geeksforgeeks.org/
➢https://leetcode.com/
➢http://www.gainlo.co/
➢https://careercup.com/
➢https://coder.com/careers
➢https://interviewup.blogspot.com/
➢https://www.livecareer.com/resources/inter
views/prep/interviewbest-blog
➢https://www.indiabix.com/

➢ ► FREE ONLINE EDUCATION
➢https://www.coursera.org/
➢https://www.edx.org/
➢https://www.khanacademy.org/
➢https://www.udemy.com/
➢MIT OpenCourseWare
(https://ocw.mit.edu/index.htm) (Free
Online Course Materials)
➢https://online.stanford.edu/
➢https://www.codecademy.com/
➢(https://github.com/pamoroso/free-python-books)
Learn Python for free
TIL: Disabling introspection in prod for Absinthe
Tags: elixir, graphql, todayilearned, absinthe
Published: 2022-12-03 18:22:21

Recently I had the opportunity to study security best practices for GraphQL. One security recommendation that stood out as low-hanging fruit was disabling GraphQL introspecting for your API in production. GraphQL libraries I have used for Ruby and JavaScript made doing this very easy, so I was expecting the same thing with the Absinthe library in Elixir. It then surprised me that disabled introspection in Absinthe was documented, and every more confusing to figure out how.
 
Luckily after some web searching, [I stumbled upon a Gist made by the community with middleware to disable introspection](https://gist.github.com/afhammad/16fc3592bad2d89959d31ac60115e5b9). So for my own implementation, I decided to make it simpler and disable introspection entirely if you are not in the development environment. Check it out.

```elixir
defmodule MyAppWeb.Schema.Middleware.AuthorizedIntrospection do
  @moduledoc """
  Disable schema introspection outside of development
  """
  @behaviour Absinthe.Plugin

  @impl Absinthe.Plugin
  def before_resolution(exec) do
    if Enum.find(exec.result.emitter.selections, fn %{name: field_name} ->
         Macro.underscore(field_name) == "__schema" && Mix.env() != :dev
       end) do
      %{
        exec
        | validation_errors: [
            %Absinthe.Phase.Error{message: "Unauthorized", phase: __MODULE__}
          ]
      }
    else
      exec
    end
  end

  @impl Absinthe.Plugin
  def after_resolution(exec), do: exec

  @impl Absinthe.Plugin
  def pipeline(pipeline, _exec), do: pipeline
end
```
Advent.js🎅🏼| Reto #3: ¿Cuántas cajas de regalos puede llevar Papá Noel?
Tags: javascript, typescript, adventofcode, spanish
Published: 2022-12-03 18:12:46

## [¿Cuántas cajas de regalos puede llevar Papá Noel?](https://adventjs.dev/es/challenges/2022/3)

Tienes una caja de regalos de Navidad que Santa Claus quiere entregar a los niños. **Cada regalo está representado por una cadena**. Santa Claus tiene un trineo que puede llevar un **peso limitado**, y cada regalo dentro de la caja tiene un peso que es igual al número de letras en el nombre del regalo.

Santa Claus también tiene una lista de renos que pueden ayudarlo a entregar los regalos. Cada renos tiene un **límite de peso máximo** que puede llevar. El límite de peso máximo de cada reno es **igual a dos veces el número de letras en su nombre**.

Tu tarea es implementar una función `distributeGifts(packOfGifts, reindeers)` que recibe una caja de regalos y una lista de renos y devuelve el número máximo de cajas de estos regalos que Santa Claus puede entregar a los niños. **Las cajas de regalos no se pueden dividir**.

```js
const packOfGifts = ["book", "doll", "ball"]
const reindeers = ["dasher", "dancer"]

// el pack de regalos pesa 4 + 4 + 4 = 12
// los renos pueden llevar (2 * 6) + (2 * 6) = 24
// por lo tanto, Santa Claus puede entregar 2 cajas de regalos

distributeGifts(packOfGifts, reindeers) // 2
```

Cosas a tener en cuenta:

* Las cajas de regalos no se pueden dividir.
* Los nombres de los regalos y los renos siempre serán mayores que 0.


Completa el reto!

---

Puedes seguir a @midudev y estar pendiente de los retos de Advent.js 

{% twitter 1597965996383412225 %} 

---

Mi solución:


{% jsitor https://jsitor.com/embed/pUjf5GTIAs %}
Advent of Code Day 3
Tags: adventofcode, elixir
Published: 2022-12-03 18:12:31

### Links

- [Intro](https://dev.to/sethcalebweeks/advent-of-code-2022-in-elixir-34i8)
- [Problem Statement](https://adventofcode.com/2022/day/3)
- [Code](https://github.com/sethcalebweeks/advent-of-code-2022/blob/main/lib/Day03.ex)

### Highlights

- As in most programming languages, strings are represented as binary code points in Elixir. The `?` operator can be used to match on a range of characters, and the `<<>>` can be used to get the code of a string.
- For the first part, I split each line in half and checked to see if each item in the first half was in the second half using a reduce. As soon as a match is found, the value is calculated and replaces the accumulator. Any subsequent calls to reduce simply return the accumulator as is if it is already an integer.
- For the second part, I chunked the lines by three. For each group of three, I got rid of duplicates within each sack and flattened all three into a single list. Then I calculated the frequencies of each character and found the character with a frequency of three.

```elixir
defmodule Day03 do
  use AOC

  def value(code) when code in ?a..?z, do: code - 96
  def value(code) when code in ?A..?Z, do: code - 38

  def part1 do
    input(3)
    ~> String.split("\n")
    ~> Enum.map(fn sack ->
      middle = div(String.length(sack), 2)
      {first, second} = String.split_at(sack, middle)
      first
      ~> String.to_charlist()
      ~> Enum.reduce(false, fn
        _, acc when is_integer(acc) -> acc
        char, _ -> String.contains?(second, <<char>>) && value(char)
      end)
    end)
    ~> Enum.sum
  end

  def part2 do
    input(3)
    ~> String.split("\n")
    ~> Enum.chunk_every(3)
    ~> Enum.map(fn chunk ->
        chunk
        ~> Enum.flat_map(&Enum.uniq(String.to_charlist(&1)))
        ~> Enum.frequencies()
        ~> Enum.find(fn {_, freq} -> freq == 3 end)
        ~> fn {char, _} -> value(char) end
      end)
    ~> Enum.sum
  end

end
```
Flowcharts
Tags: cpp, beginners, learnwithmitul, programming
Published: 2022-12-03 18:07:59

Flowchart allows you to break down any process into smaller steps and display them in a visually appealing way. It helps beginners to understand without writing complex problem. Programmers often use it as a program-planning tool to solve a problem. It makes use of symbols which are connected among them to indicate the flow of information and processing.
**Flowchart Components**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tk0xlq1vlh1fa9evswd.png)
The oval shaped box denotes the start and end of an object. 

The parallelogram shaped box denotes terminal which read/print a value.

And the square shaped box denotes process which assigns a certain value.

The diamond shaped box denotes condition. It makes a decision based on a certain condition.

The arrow denotes from where you started and where you ended.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v945ap2oirvtw1oxhfie.png)



 **Example**

Question: Draw a flowchart to find the greatest number among the 2 numbers.

Solution:

Algorithm:

1. Start 

2. Input 2 variables from user

3. Now check the condition If a > b, goto step 4, else goto step 5.

4. Print a is greater, goto step 6

5. Print b is greater

6. Stop
after completing the process it gives out the value