teleren/devto huggingface dataset:
Boolean flags are sad little enums
Tags: javascript, typescript
Published: 2022-09-06 09:56:01

I was thinking today that when I was a mid experience level engineer I have found a couple of problems where I could _finally_ do something _very smart_ and use 3-state logic instead of the classic `true-false` one.

I jumped in excitedly only to lose it when I realized _"Wait, doesn't this make instead a good `enum`?"_. And then I went with a good ol' `enum` and all was well.

And now I am thinking again: wouldn't it make sense to replace as much as boolean flags with `enums` instead (or at least used named parameters).

See this example:
```javascript
jsonb_set(data, '{user, role}', {
  id: 'supervisor',
  title: 'Chat group supervisor',
}, false);
```

When you are writing this, you still remember what was the `false` for the last parameter.
I give you a weak and if you are not using this `jsonb_set` function frequently you will have no memory of it.

> We then waste time on things that could have been very clear.

### Option 1: use `enum`
```typescript
enum JsonbSetOption {
  CreateIfDoesNotExist,
  ThrowErrorIfDoesNotExist
}

jsonb_set(data, '{user, role}', {
  id: 'supervisor',
  title: 'Chat group supervisor',
}, JsonbSetOption.ThrowErrorIfDoesNotExist);
```

Basically anybody will know what this will do.

### Option 2: passing named parameters
```javascript
jsonb_set(data, '{user, role}', {
  id: 'supervisor',
  title: 'Chat group supervisor',
}, { throwErrorIfDoesNotExist: true });
```

### Option 3: split it into two functions
```javascript
jsonb_set_throw_on_update_path_missing(
  data, 
  '{user, role}',
  {
    id: 'supervisor',
    title: 'Chat group supervisor',
  }
);
```

It is up to you whichever you choose. Please don't just use random flags or else...

```javascript
receiveSalary(you, false, true, true, false, null);
```
A portal between Ruby and Go (using FFI)
Tags: ruby, go, ffi
Published: 2022-09-06 09:48:50

---
title: A portal between Ruby and Go (using FFI)
published: true
description: How to integrate Go code in Ruby
tags: ruby, go, ffi
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2d45m19oriz1xh6due4m.png
canonical_url: https://dario.cat/en/posts/portal-between-ruby-and-go/
---

Thinking about migrating some huge REST APIs from Ruby to Go, I researched how to replace the Ruby code progressively with Go code.

I ended up with a possible FFI-based prototype. The solution is to have the Ruby code load a Go library and wrap the Go functions in Ruby classes and methods.

## The Ruby side

The Ruby side is pretty straightforward. We must load the Go library and import the Go functions in Ruby classes and methods.

```ruby
require 'ffi'

module Portal
  extend FFI::Library

  ffi_lib './libexample.so'

  class Example < FFI::Struct
    # This must be completely in sync with the C struct defined in Go code.
    layout :id, :int, :prefix, :pointer
  
    def initialize(prefix, id)
      self[:prefix] = FFI::MemoryPointer.from_string(prefix)
      self[:id] = id
    end

    # This feels convoluted, but it hides the fact that our function is loaded
    # outside of the "struct mirror" class.
    def greet
      Portal.greet(self)
    end
  end

  attach_function 'greet', [Example.by_value], :void
end

ex = Portal::Example.new('C', 137)
ex.greet
```

## The Go side

The Go side is a bit more complex. We need to define a C-compatible struct and export the functions we want to use from Ruby.

The cool thing is that we can define the functions with the struct as the receiver.

```go
package main

/*
struct example {
	int ID;
	char *Prefix;
};
*/
import "C"
import "fmt"

// This declaration is just an alias to the C struct.
type Example C.struct_example

//export greet
func (e Example) greet() {
	fmt.Printf("Hello from %s-%d\n", C.GoString(e.Prefix), e.ID)
}

func main() {}
```

## The build

The build is also straightforward. We need to:

1. Compile the Go code to a shared library. This command will generate the CGO bindings.
2. Run the Ruby code.

```shell
go build -buildmode=c-shared -o libexample.so example.go
ruby portal.rb
```

## The result

If we run the code, we get the following output:

> Hello from C-137

## The benefits

The main benefit of this approach is that we can progressively migrate the Ruby code to Go. We can start by replacing part by part, until we are ready to switch to a pure Go service.

It's not only possible to replace existing Ruby code. Now we can reuse RSpec/Minitest specs to test the new Go code. Instead of going for a full rewrite with no tests, we can start by testing the new code with the existing ones.

## The (possible) drawbacks

Performance-wise this approach is not ideal. We are adding a layer of indirection. This probably adds some overhead to the calls. This is something we need to measure if applied to high-traffic services.
All about Jamstack
Tags: jamstack, javascript, api, markdown
Published: 2022-09-06 09:36:49


Hey everyone, in this blog we’ll be learning about 
- What is Jamstack?
- Benefits of Jamstack.
- Approach towards a Jamstack project.
- Jamstack site generators.

 So let's get started ✨.

## What is Jamstack? 

Jamstack is a system to build fast, lightweight web apps with minimal efforts. 

Jamstack is powered by 
- JavaScript
- APIs
- Markdown

It is a method to deliver static websites to the user with ease of development. Instead of serving dynamic content using a huge backend, dynamic parts of the websites are powered by APIs. This makes the website snappy and fast as the JavaScript shipped to the user is reduced. 

The website's static part is stored in a CDN so the website will be loaded swiftly. Using this technique we can divide our project into small islands in which we can add JavaScript to some of the island thus resulting in lighter websites. This technique is called island architecture. 


## How does Jamstack handle backend functionality? 

Backend is a piece of code that runs on a server without exposing itself to the user. So to handle the backend functionality, Jamstack uses APIs through which we can fetch and send data to the server, which will further send us the computed data.

We can make our custom APIs for niche tasks using any backend framework like ExpressJS and use them in our web apps. 

## Why should we use Jamstack?

- <b>Swiftness</b>
    - The website can be blazingly fast as the majority of the content will be statically served with minimal JavaScript shipped to the user.

- <b>Scalablity</b>
    - Since the backend/API is developed independently, scaling the website wouldn't be a tedious task, and due to the fast speed, heavy traffic can be managed smoothly.

- <b>Developer Experience</b>
    - People always give importance to the user experience (UX), but very few folks pay attention to the developer experience (DX). Using Jamstack web apps can be easily developed with a straight-forward approach.

## Approach towards a Jamstack project.

There is a very straight-forward approach to be followed while developing a project using Jamstack.

- Divide the project into islands. 
- Use HTML/CSS for static parts/islands.
- Hydrate the dynamic islands with JavaScript.
- Use APIs to build dynamic components.

## Jamstack Generators

There are a ton of generators for Jamstack. Here are some static site generators for Jamstack sites. 

- [Astro](https://astro.build/)
- [Eleventy](https://www.11ty.dev/)
- [Hugo](https://gohugo.io/)
- [Gatsby](https://www.gatsbyjs.com/) 


Thank you for reading the blog, hope it was helpful. 
Until next time 🙌🏻.
Front end developer RoadMap
Tags: opensource
Published: 2022-09-06 09:32:10

Hello David Humphrey !

My name is Maxim Nosov. I'm very excited to start this course with you. I'm taking this course because I'm willing to learn new things about open source and how software development works in real world. I'm happy with the fact that I can get real world development experience and contribute to open source projects with the help of this course.

I'm open to any projects, willing to learn new things and develop my skills in terms of software development.

Here is the Github trending repo that I've chosen: https://github.com/kamranahmedse/developer-roadmap .

I really love this project idea, because it could be quite challenging for beginners to understand what exactly do they have to learn and in what sequence to become a great developer or other IT specialist.

Furthermore, in my case, I loved the front end developer roadmap, since that's where I want to develop. I admired the interactive map with the content that describes a specific topic to learn about. Also, there are links for the resources to learn certain technology, which is very useful, so that you don't need to search the information through the whole web, everything is ready and collected here!
Artificial Intelligence Projects For Students
Tags: javascript, webdev, beginners, programming
Published: 2022-09-06 09:31:36

List of [artificial intelligence projects for students](https://takeoffprojects.com/artificial-intelligence-projects-for-students) and research at Takeoff Projects. We provide the widest and most innovative artificial intelligence projects for students. These projects on artificial intelligence have been developed to help engineers, researchers and students in their research and studies in AI based systems. 
 
Browse through our list of latest [artificial intelligence project ideas](artificial intelligence project ideas) and choose the topic that suits you best. These systems have been proposed to help humankind in various walks of life using artificial intelligence based systems.
 
Artificial intelligence is a very frequent topic for movies, books, and all other media. Did you ever wish you could make an AI of your own? Well, this article is the best way to get started.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6s2alug3749hltfm6w3h.png)
 
The term Artificial intelligence is used to define machines or computers that mimic the functions of the human mind such as learning and problem-solving. Natural language processing, computer vision, and decision-making are some of the functions expected of an advanced artificial intelligence program.

Few Artificial Intelligence Projects for Students:

- [Ecrime Identification Using Photo Matching App](https://takeoffprojects.com/project-details/ecrime-identification-using-photo-matching-app--469)
- [Medicine Helper Using Ocr](https://takeoffprojects.com/project-details/medicine-helper-using-ocr--411)
- [Face Detection Using Mobile Vision](https://takeoffprojects.com/project-details/face-detection-using-mobile-vision--394)
- [Speakjust Voice Based Control In Examination](https://takeoffprojects.com/project-details/speakjust-voice-based-control-in-examination--442)
- [Number Plate Recognition Using Ocr](https://takeoffprojects.com/project-details/number-plate-recognition-using-ocr--420)
[HELP] Open Menu on Hover
Tags: hover, menu, wordpress, css
Published: 2022-09-06 09:09:20

Hi, can someone help me. I have used this tutorial to make a vertical menu but I want to have it open on hover instead of a toggle on desktop. Any ideas how to do it? Tia

https://makedreamwebsite.com/elementor-vertical-header-with-sidebar-navigation-menu-in-wordpress/
Tips To Handle Performance And Coding Way Between Different Type Of Loop ( For, Foreach, While…)
Tags: performance, programming, computerscience, webdev
Published: 2022-09-06 08:32:30

In this article, you will learn how to use loops and how to handle it's performance.

Different Types of Loops in coding:
PS: syntax may differ between language and another but in this article, we are talking about it more in generic.

Loops are used to execute the same block of code again and again, as long as a certain condition is met. The basic idea behind a loop is to automate the repetitive tasks within a program to save time and effort.

**while** — loops through a block of code as long as the condition specified evaluates to true.

`while(condition){
    // Code to be executed
}`

**do…while** — the block of code executed once and then condition is evaluated. If the condition is true the statement is repeated as long as the specified condition is true.

`do{
    // Code to be executed
}`

while(condition);`

**for** — loops through a block of code until the counter reaches a specified number ( 10 times, 20 times, 100 times..)

`for(initialization; condition; increment){
    // Code to be executed
}`

**foreach** — loops through a block of code for each element in an array.

`foreach($array as $value){
    // Code to be executed
}`

Loop Optimization tips:

1- Consider defining the size and use it variable within the for loop:

`int size = data.size(); for (int i = 0; i < size; i++) { ... }`

2- Using Foreach or an Iterator is better and faster in performance than for loop:

`foreach($array as $value){
   // Code to be executed faster then a for loop like for(int i=0; i < size;i++){}
}`

Some tips after testing for loop speeds

- **while** loops scale the best for large arrays.

- **for...of** loops are hands down the fastest when it comes to small data sets, but they scale poorly and slow for large data sets.
- **.forEach()** is close enough that neither side should hang their hat on performance alone over the other.
- The execution time of **.forEach()** is dramatically affected by what happens inside each iteration but it's considerable fast in processing data.
- Standard **for** loops had medium speed across the board.

But after all, using for loop type might also depend on what kind or size of data you're processing from large, small amounts of data or even specific numbers like 10, 100, or 1000.

Can be found also on [Techwebies](https://www.techwebies.com/2020/08/29/tips-to-handle-performance-and-coding-way-between-different-type-of-loop-for-foreach-while/)
What is Javascript?
Tags: javascript, webdev, programming, react
Published: 2022-09-06 08:30:59


![what is javascript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yjqywghemyz8zqa9txr7.jpg)


![make web pages alive](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u47skonkmd24xsdoa98y.jpg)


![javascript engines](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/03gcw845yogz6dte4zq0.jpg)


![languages that transpile to javascript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzwwpkdywjdbfpnoazko.jpg)


![follow javascript.verse on instagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtwns423qmyfchm7a9z2.jpg)
Unconventional Hacks to reduce your AWS costs
Published: 2022-09-06 08:29:48

Click [here](https://ttnew.co/3RmKpZZ) to register for a free webinar on AWS Unconventional hacks to reduce your costs. 
CloudKeeper has helped 250+ clients to reduce their bills instantly using these hacks and their economy of scale. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tm99xgr4szt7ornzcvs.png)
 #aws #awscostoptimization #cloudbills
Battle Ready Laravel is now available!
Tags: laravel, php, webdev
Published: 2022-09-06 08:10:33

If you've been following my blog or social media for the past few months, you'll know that I've been working on a new ebook called "[Battle Ready Laravel](https://battle-ready-laravel.com)".

I've spent a huge amount of time and effort into writing it and trying to put as many tips and tricks down into writing as possible.

The book is split up into 4 sections and is over 200 pages long!

The 4 sections covered are:

- Auditing
- Testing
- Fixing
- Improving

## What's Covered in the Book?

As a freelance web developer, I'm really lucky and I get the chance to work on a lot of exciting projects. The majority of the time, the projects that I work on are existing projects and I'm brought on board to help add extra functionality, remove technical debt, add test suites, and generally improve the maintainability of the system.

In [Battle Ready Laravel](https://battle-ready-laravel.com), I've written down the exact same steps that I use when improving Laravel projects. It contains actionable advice and steps that you can use straight away in your own projects.

We'll start by learning how to use automated tools and manual methods to audit the codebase and find weaknesses and areas to improve.

You'll then learn how to write tests that increase our confidence in our code and reliability for our end users.

You'll learn how to reduce (and hopefully remove!) technical debt and fix bugs. I'll also show the most common mistakes and errors that I see in Laravel apps and show you can avoid them yourself.

By the end of the book, you should feel like a more confident developer and have a better insight into how to manage your Laravel apps to keep them efficient, testable, and maintainable! 

## Discount Codes

Let's be honest, we all love discount codes!

Battle Ready Laravel comes with up to $195 USD worth of discount codes (based on the exchange rate on the 27th June 2022) for you to use!

Thanks to the generosity of Spatie, StyleCI and Laravel Security In Depth, if you purchase Battle Ready Laravel you will get limited-edition discount codes for using with Flare, OhDear, StyleCI, and Laravel Security In Depth!

The following discounts come with the book:

- **OhDear** - €5 EUR discount for the first 3 months of new OhDear subscriptions.
- **Flare** - €10 EUR discount for the first 3 months of new Flare subscriptions.
- **StyleCI** - 20% discount for the first payment of new "Startup" or "Premium" StyleCI subscriptions.
- **Laravel Security In Depth** - 25% discount for 1 year of new Laravel Security In Depth subscriptions.

So if you're considering signing up for any of these services in the future, the book will pay for itself just from the savings you can make!

## Let Me Buy The Book!

If you're interested in buying Battle Ready Laravel, you can [click here to buy it now for $39](https://ashallen.lemonsqueezy.com/checkout/buy/0268ae55-bf4e-4cc0-bc2e-bc2b9e927d86)!
8 tips on how to find the best statistics assignment help
Tags: statisticsassignmenthelp, statisticsassignmenthelpe, domystatisticsassignment, takemystatisticsexam
Published: 2022-09-06 08:09:35

Statistics has wide application in our daily lives and hence, it is a part of major educational courses around the world. Many students find it difficult and tedious to complete their [statistics assignment help](https://www.statisticsassignmenthelp.com/). This happens due to many reasons. Submitting assignments on time is critical to scoring high grades and obtaining the credits needed to complete the degree. If you are finding it difficult to complete your statistics assignment, you may wonder if can someone [take my statistics exam](https://www.statisticsassignmenthelp.com/take-my-statistics-exam). You can always take help from websites provide online statistics assignment help.

8 tips on how to find the best statistics assignments

- Reviews and Referrals
- Experienced Tutors
- Step-by-Step Explanations 
- Plagiarism Free Assignment
- Timely Delivery
- 24×7 Live Support Team
- Pocket-Friendly Pricing
- Option to Review
A Nice Developer Joke For Today
Tags: jokes, dailydeveloperjokes, watercooler
Published: 2022-09-06 08:00:03

---
title: "A Nice Developer Joke For Today"
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, #watercooler
---

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/5e12594523a5e.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 did the process say after working in an infinite loop all day?

___A:___ I need a break.
 -->
Creating forms from reflected orm objects FLASK/ALCHEMY BLEH
Published: 2022-09-06 07:54:57

Philosophy:
We use computers to automate things, we use programming languages to automate the automation. When a framework makes you do stuff by hand either a) The framework is to put it academically "SHITTY" or it was not written with automation in mind.


Creating forms is pain, creating Database models is a pain.

We have a db objects that reflects all the tables in our DB:

`    from flask_sqlalchemy import  SQLAlchemy
    db = SQLAlchemy(flask_appinstance)
    db.init_app(flask_appinstance)
    db.Model.metadata.reflect(db.engine)`
   

then you could reflect a table from your database simply by:

`  class Table_FROM_REAL_DB(db.Model):
        __tablename__='Name_of_Tabble_In_Real_DB'`

Nou you can easily create a form that accepts data from a webpage for this very table or loads data into an html table from this very table by simply:

``
    from flask_wtf import FlaskForm
    from wtforms_sqlalchemy.orm import model_form
 instance_of_object_corrosponding_to_a_table=Name_of_Tabble_In_Real_DB()
    Form_of_Tabble_In_Real_DB = model_form(model=Name_of_Tabble_In_Real_DB, base_class=FlaskForm, db_session=db.session)`

populate it as per:
form.populate_obj(instance_of_object_corrosponding_to_a_table)

`
People who make things complicated have unresolved mental issues they do not want to deal with in real life and bring into sacred grounds of coding, they must stop touching the keyboard and find a therapist/partner/book.
Use a folder to store requirements of a project
Published: 2022-09-06 07:33:12

Hi, assuming that I'm using the following project structure:


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

Since in addition to the requirments.txt file I have some conda requirements .yml files I would like to create a folder where I can put them all. If so what would be the name of the folder according to best practices? Does it make sense to do this in your opinion?
How to create a multiple-page application with Laravel 9 and Vue 3
Tags: vue, php, javascript, laravel
Published: 2022-09-08 22:26:35

---
title: How to create a multiple-page application with Laravel 9 and Vue 3
published: true
date: 2022-09-06 07:30:18 UTC
tags: vuejs,php,javascript,laravel
canonical_url: https://blog.devgenius.io/how-to-create-a-multiple-page-application-with-laravel-9-and-vue-3-9d3026797fc2
---

[![](https://cdn-images-1.medium.com/max/2600/0*4HfJLf09eVjKQAC1)](https://blog.devgenius.io/how-to-create-a-multiple-page-application-with-laravel-9-and-vue-3-9d3026797fc2?source=rss-17217f29618a------2)

Laravel — Building Vue 3 Multiple Page Application with Vitejs

[Continue reading on Dev Genius »](https://blog.devgenius.io/how-to-create-a-multiple-page-application-with-laravel-9-and-vue-3-9d3026797fc2?source=rss-17217f29618a------2)
Beautiful Developer Portfolio 👌🔥
Tags: javascript, webdev, beginners, css
Published: 2022-09-06 07:22:13

**Portfolio**
Creating your [own portfolio](https://shahreecoder.com/) is not always an easy task. We can say that the most important thing is the projects themselves and you will definitely be right. But it is also very important how you present your projects before they are evaluated. That's why we need beautiful portfolio pages. **In order to be able not only to show our projects, but also to present them beautifully.**

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


[LIVE DEMO](https://shahreecoder.com/)
[GitHub](https://github.com/shahreecoder/portfolio)