teleren/devto huggingface dataset:
Create cross-platform desktop apps using Fiber and GO!
Published: 2023-04-21 10:45:39

---
title: Create cross-platform desktop apps using Fiber and GO!
published: true
description: How to create desktop apps using Fiber web framework and GO.
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-04-20 11:33 +0000
---

As a web developer learning another skill just to make a desktop app is time consuming. There are a few go packages which help you build a desktop ui using html/css/js. I found are [wails.io](https://wails.io/), [gioui](https://gioui.org/) and other packages very interesting. But, since I've already build a web app in [Fiber](https://gofiber.io/) I looked for a way to use the same code in the desktop app.

I created [fiberwebgui](https://github.com/ClimenteA/fiberwebgui) to solve this issue.

This small package just starts the Fiber server and the Chrome* browser in app mode. Doing this allows you to use [Fiber](https://github.com/gofiber/fiber) go web framework to create a desktop application using html/css/js, go html templates, vue, react etc anything you would use to create a website.

## Install

```bash
go get -u github.com/ClimenteA/fiberwebgui
```

## Usage

```go
package main

import (
	"github.com/ClimenteA/fiberwebgui"
	"github.com/gofiber/fiber/v2"
)

func main() {

	app := fiber.New()

	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("Hello, World 👋!")
	})

	fiberwebgui.Run(app)
	// or initial width/height
	// fiberwebgui.RunWithSize(app, 800, 600)
}

```

## Distribution

Here are some CLI go commands for cross-platform executables.

Windows 64bit:
```bash
GOOS=windows GOARCH=amd64 go build -ldflags -H=windowsgui -o dist/myapp.exe main.go
```

Linux 64bit:
```bash
GOOS=linux GOARCH=amd64 go build -o dist/myapp main.go
```

Mac 64bit:
```bash
GOOS=darwin GOARCH=amd64 go build -o dist/myapp main.go
```

Of course, modify these commands as needed for your specific hardware.

The source code can be adapted to be used with other go web frameworks, just fork it and modify as needed. 

You can find the source code here: https://github.com/ClimenteA/fiberwebgui.
Top Manufacturing ERP Trends in 2023 | Manufacturing Trends
Tags: manufacturingtrends
Published: 2023-04-21 10:28:04

Digitization is transforming manufacturing businesses with the adoption of intelligent automation, business connectivity solutions, and many other advanced technologies. Explore top [manufacturing trends](https://techierocket.com/manufacturing-trends-in-2023/) to watch for in 2023 and how to leverage them.
F# Orleans reminder grain
Tags: dotnet, orleans, fsharp
Published: 2023-04-21 09:04:51

This is a simple example of how we set up reminder grains in Orleans and f#.

[Here's](https://github.com/PiotrJustyna/road-to-orleans/tree/main/1b) the code so you can follow along

## Grain interface

```
type IYourReminderGrain =
    inherit IGrainWithStringKey
    inherit IRemindable
    
    abstract member WakeUp : unit -> Task
```

We have 2 important parts here that will be implemented in the grain.

- `IRemindable`: This forces us to implement the `ReceiveReminder` function. This is where the logic we want to execute each time the reminder gets triggered.
- `WakeUp` : This activates the grain so we can set up the reminder

## Grain implementation

```
type YourReminderGrain() =
    inherit Grain()
    interface IYourReminderGrain with
        member this.WakeUp() = Task.CompletedTask
        member this.ReceiveReminder(reminderName, status) =
            Console.WriteLine(reminderName, status)
            Task.CompletedTask
        
    override _.OnActivateAsync(cancellationToken:CancellationToken) = 
        let _periodInSeconds = TimeSpan.FromSeconds 60
        let _dueInSeconds = TimeSpan.FromSeconds 60
        let _reminder = base.RegisterOrUpdateReminder(base.GetPrimaryKeyString(), _dueInSeconds, _periodInSeconds)
        base.OnActivateAsync(cancellationToken)
```
There are 2 important parts here
- Implement the `IYourReminderGrain` : The `WakeUp` is simple as we do not want to do anything here. `ReceiveReminder` contains our logic. What we want to execute on every trigger of the reminder. Here we are simply writing the reminder name to the console.
- Overriding `OnActivateAsync` : This is where we register the reminder and specify at what interval it should trigger at. `_periodInSeconds` specifies the time between triggers and `_dueInSeconds` specifies how long to wait until the first trigger

## Kicking off the reminder grain
In this example I do this by adding a hosted service `GrainActivatorHostedService`.

This is responsible for retrieving the reminder grain from the `IGrainFctory` and calling the `WakeUp` grain function

```
let! _ =
    _client
        .GetGrain<IYourReminderGrain>(Guid.NewGuid().ToString())
                    .WakeUp() 
```

That's it. To run the app just run 

```shell
> sh run-silo-local.sh
or
> sh run-silo-docker.sh
```

You can also run it in your IDE or VS Code devcontainers

To verify everything is working correctly:

* Dashboard: http://localhost:8081
* Dashboard if running with Docker http://localhost:3000

This is part of the road-to-orleans project. Check it out

{% embed https://github.com/PiotrJustyna/road-to-orleans %}
Boost your ASP.NET Application's Performance: Tips and Techniques
Tags: webdev, aspdotnet, performance, programming
Published: 2023-04-21 10:09:43

Are you looking for ways to speed up your ASP.NET application? If so, you're not alone. Improving application performance is a common challenge for many developers. We'll explore some tips and techniques for boosting your ASP.NET application's performance.

- **Use Caching:** ASP.NET provides several caching mechanisms, including in-memory caching, output caching, and data caching.
- **Optimize Images:** Use tools like Photoshop or online image compressors to optimize your images.
- **Use a Content Delivery Network (CDN):** By using a CDN, you can improve your application's performance and reduce the load on your server.
- **Minify CSS and JavaScript:** Use tools like YUI Compressor or Google Closure Compiler to minify your files.
- **Use Asynchronous Programming:** Use async/await keywords in C# to perform asynchronous operations.
- **Optimize Database Queries:** Use Entity Framework or LINQ to SQL to write optimized queries.
- **Use a Profiler:** You can use profiling tools like ANTS Performance Profiler or dotTrace to measure your application's performance and identify areas that need improvement. 
- **Use a Faster Web Server:** Configure IIS to use HTTP compression and caching to reduce the load on your server.
- **Use Compression:** Use GZipStream or DeflateStream classes in ASP.NET to compress your response data.

By following these best practices and optimizing your code, once can significantly improve the performance for their ASP.NET application.

Reference from [Software Development Company](https://dexoc.com/blog/how-to-speed-up-asp-dot-net-applications)
Simple Improvements and Testing of a Rails Controller
Tags: rails, rspec, testing, ruby
Published: 2023-04-21 10:09:27

Simple case how to improve your controller in a Rails application

### Step 1. Route to the main page

First I want to check `#root` route of an App

I go to `config/routes.rb` and see

```ruby
Rails.application.routes.draw do
  root to: 'root#index'
end
```

### Step 2. Checking the controller

I visit the controller `app/controllers/root_controller.rb`

```ruby
class RootController < ActionController::Base
  def index
    @mailto = "hello@company.com"
    @blogs = Blog
             .published
             .limit(10)
  end
end
```

### Step 3. How to Improve

I see a way to improve the controller. I want to move numbers and strings in constants.

**Rule:** Do not keep `Magic numbers` in your code. Always move it constants!

```ruby
class RootController < ActionController::Base
  MAIN_EMAIL = "hello@company.com"
  INDEX_BLOGS_COUNT = 10

  def index
    @mailto = MAIN_EMAIL
    @blogs = Blog
             .published
             .limit(INDEX_BLOGS_COUNT)
  end
end
```

### Step 4. Adding tests

In my app test environment is already set up. I will just improve existed tests a bit.

```ruby
require 'rails_helper'

RSpec.describe RootController type: :controller do
  describe 'Constants' do
    it "has expected INDEX_BLOGS_COUNT" do
      expect(RootController::INDEX_BLOGS_COUNT).to eq 10
    end

    it "has expected MAIN_EMAIL" do
      expect(RootController::MAIN_EMAIL).to
        eq("hello@company.com")
    end
  end

  describe '#index' do
    let!(:published_blogs) { create_list :blogs, 3, :published }

    before do
      get :index
    end

    it do
      expect(response).to render_template(:index)
    end

    it do
      expect(assigns(:blogs).map(&:id)).to
        match_array(published_blogs.map(&:id))
    end

    it { expect(assigns(:mailto)).to eq RootController::MAIN_EMAIL }
  end
end
```

### Step 5. Running the test case

```bash
bundle exec rspec spec/controllers/root_controller_spec.rb
```

That is it!
Happy Coding!
Listing the Globally Installed NPM Packages
Tags: webdev, node, npm, beginners
Published: 2023-04-21 09:35:20

![Photo by [Carl Raw](https://unsplash.com/@carltraw?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/photos/m3hn2Kn5Bns?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)](https://cdn-images-1.medium.com/max/10750/1*euyZGDxaNgUcgMFeZc2N-Q.jpeg)

When working with Node.js, you may install various NPM packages globally to use them across multiple projects. Over time, you may forget which global NPM packages are on your system.

In this article, we’ll explore how to list the global NPM packages on your system with code samples.

-----

## Listing the Global NPM Packages

To list the installed global NPM packages, you can use the following command in your terminal:

    # List the installed global NPM packages
    npm list -g --depth 0

This command will display the list of global NPM packages installed on your system.

* -g or --global: The option to list global packages on your system.

* --depth 0: The option to limit the depth of the dependency tree to zero. This will only list the top-level packages without their dependencies.

-----

## Listing the Global NPM Packages with Details

To list the installed global NPM packages with details, such as the version number and location, you can use the following command:

    # List the installed global NPM packages with details
    npm list -g --depth 0 --long

This command will display the list of global NPM packages installed on your system along with their version number and installation location.

* --long: The option to display additional information about each package, including its version and the location of its files on disk.

-----

## Checking the Version of a Global NPM Package

To check the version of a specific global NPM package, you can use the following command:

    # Check the version of a specific global NPM package
    npm list -g <package_name>

Replace <package_name> with the name of the global NPM package you want to check.

    npm list -g create-react-app

-----

## Conclusion

Listing the global NPM packages on your system is a simple process that can help you keep track of the NPM packages installed on your system.

Remember to periodically check the list of global NPM packages to keep your system up-to-date and avoid any conflicts or issues with your projects.
HOW TO DEPLOY A HIGH AVAILABLE CLUSTER AT AWS OPENSEARCH USING TERRAFORM
Published: 2023-04-21 09:26:59

Hi, devops fans
If you are interested at how to deploy HA OpenSearch cluster at AWS in details using terraformm then welcome to series of articles related to it:


   

-  [TERRAFORM OPENSEARCH MODULE PART 1](https://sergiiblog.com/terraform-opensearch-module-part-1/)
-  [TERRAFORM OPENSEARCH MODULE PART 2](https://sergiiblog.com/terraform-opensearch-module-part-2/)
-  [TERRAFORM OPENSEARCH MODULE PART 3](https://sergiiblog.com/terraform-opensearch-module-part-3/)
-  [APPLY TERRAFORM OPENSEARCH MODULE, DOMAIN ENDPOINT AND 
   OPENSEARCH DASHBOARD](https://sergiiblog.com/apply-terraform-opensearch-module-domain-endpoint-and-opensearch-dashboard/)

Have a pleasant reading :)
New York City Launches Charge Ready NY Program to Build Electric Vehicle Charging Hubs Across the City
Published: 2023-04-21 09:20:07

[Tresco Logistics Private Limited](https://www.trescologistics.com/) : The New York City government has announced the launch of a new program to build electric vehicle (EV) charging hubs across the city. The initiative aims to encourage the adoption of electric cars by making charging more convenient and accessible for city residents and visitors.

The program, called "Charge Ready NY," will invest $250 million over the next five years to install thousands of Level 2 charging ports in public locations such as parking lots, curbsides, and municipal buildings. The program will also provide incentives to private companies and landlords to install charging stations in their properties.

The initiative is part of the city's larger efforts to reduce greenhouse gas emissions and combat climate change. According to the Mayor's Office, transportation is the largest source of carbon emissions in the city, and switching to electric cars is one of the most effective ways to reduce emissions.

The first charging hubs are expected to be installed in the coming months in neighborhoods across the city, including the Bronx, Brooklyn, Manhattan, Queens, and Staten Island. The charging ports will be available for use by all EV drivers, regardless of their vehicle make or model.

The Charge Ready NY program is part of a broader effort by the state of New York to build out EV infrastructure. Governor Kathy Hochul recently announced a goal to have 10,000 charging ports installed across the state by the end of 2021. The state is also offering incentives and rebates to encourage residents to switch to electric cars.

The move towards electric vehicles and EV infrastructure is a growing trend in cities and states across the US and around the world. As more people adopt electric cars, it's important to ensure that charging is accessible and convenient, and programs like Charge Ready NY are an important step towards that goal.
Rounding errors in JavaScript
Tags: webdev, javascript, learning, node
Published: 2023-04-21 09:16:00

JavaScript uses the IEEE-754 floating-point representation, which is a binary representation, that is capable of exactly representing fractions like 1/2 and 1/8. This is great and all, but the fractions we most commonly use are decimal ones, such as: 1/10 and 1/100.

Numbers in JavaScript have a lot of precision but the problem is that  floating point representations cannot exactly represent numbers like 0.1 or 0.01. They can very closely approximate decimal numbers, but the fact that numbers like these can't be exactly represented can lead to problems.

Example:
```js
let x = .3 - .2;
let y = .2 - .1;
x === y              // => false: They are not the same
x === .1             // => false: .3 - .2 !== .1
y === .1             // => true: .2 - .1 === .1
```

Because of rounding errors the approximations of `x` is not exactly the same as the approximations of `y` . They are very very close to each other, but not the same!
Also it's important to note that this problem is not specific to JavaScript, it affects all of the languages that use binary floating-point numbers.
Family Lawyer In Mississauga
Published: 2023-04-21 09:12:36

Are you looking for [family lawyer in Mississauga](https://www.kslegal.ca/family-lawyer-mississauga.html) ? If so then contact Barrister Kiran Salooja for family matters. Her Qualified team of lawyer will assist you with solutions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lagkwchv4wj6hk0htzwy.png)
Best School Management Software for 2023
Published: 2023-04-21 09:11:24

The school staff has to execute various repetitive, tedious and manual tasks daily for smooth operations. The [best school management software](https://technologycounter.com/school-management-software) will have automation integrated into the system to automate most of the repetitive and tedious processes. As a result, your team can focus on another valuable task to increase the productivity of your team.   

The cloud-based school management solution with LMS will help to create learning modules. It will help to automate the learning experience and result in higher productivity of your teams.    


Better Student-Teacher Collaboration: 
Every learning institute should have a seamless collaboration between the students and teachers. Hence every school must create an environment wherein the teachers are easily accessible. The [top 10 school management software](https://technologycounter.com/school-management-software) in India will help students to access the students with ease.  Better collaboration between teachers and students will help to drive the best from the students as per their skillsets.
MacOS: notify when the terminal command is finished
Tags: macos, bash, zsh
Published: 2023-04-21 09:04:17

---
title: MacOS: notify when the terminal command is finished
published: true
tags: 
  - macos
  - bash
  - zsh
cover_image: https://strdr4605.com/mac-os-notify-when-the-terminal-command-is-finished.jpg
canonical_url: https://strdr4605.com/mac-os-notify-when-the-terminal-command-is-finished
---

After reading [A decade of dotfiles](https://evanhahn.com/a-decade-of-dotfiles/) I wanted to create a similar bash function to `boop`.

And here it is:


```bash
# ~/.zshrc
# ...rest of zshrc
,notify () {
  local last_exit_status="$?"
  if [[ "$last_exit_status" == '0' ]]; then
    osascript -e "display notification \"Done\" with title \"Good\" sound name \"Fonk\""
  else
    osascript -e "display notification \"Exit code: $last_exit_status\" with title \"Bad\" sound name \"Ping\""
  fi
  $(exit "$last_exit_status")
}
```

It uses [osascript](https://ss64.com/osx/osascript.html) to execute the AppleScripts that pushes the notification.  
According to [stackoverflow](https://stackoverflow.com/questions/67406491/osascript-how-to-pass-in-a-variable/67413043#67413043) 
this is not the best way to pass bash variable to osascript, 
but I did not understand how to do it for my use case and as I use `last_exit_status` there should be no problem.

usage:

```bash
npm run test;,notify
```

I prefix the function name with a comma to faster search for it when doing `;,<Tab>`.

You can test it with `(exit 0);,notify` and `(exit 1);,notify`.

![notify good](https://strdr4605.com/notify-good.png)
![notify bad](https://strdr4605.com/notify-bad.png)
Active Record Validations
Published: 2023-04-21 09:02:28

One of the key features of Ruby on Rails is its powerful Active Record ORM (Object Relational Mapping) layer, which abstracts away the details of database access and allows you to work with your data in a more object-oriented way. One of the most important features of Active Record is its support for validations, which allow you to ensure that the data stored in your database is always consistent, accurate, and valid.

What are Active Record Validations?

Active Record validations live on the model layer of Rails, which is structured on the MVC architecture. They are a way to check that the data stored in your database is always valid and consistent. They allow you to define rules or constraints on the data, and then check that those rules are being followed whenever you try to save or update an object to the database. For example, you might want to ensure that a user's email address is unique, or that a blog post's title is at least 5 characters long.

Active Record provides a wide range of built-in validation helpers that make it easy to define these rules. Some of the most common validation helpers include:

- presence: ensures that a field is not empty or nil
- uniqueness: ensures that a field is unique across all records in the table
- numericality: ensures that a field is a number
- length: ensures that a field is a certain length
- format: ensures that a field matches a certain regular expression

When are Active Record Validations Run?

Active Record validations are run automatically whenever you try to save or update an object to the database using the save, create or update methods. When you call one of these methods, Active Record first checks that all the validations defined for the object pass. If any of the validations fail, the operation is cancelled and the object is not saved to the database.

For example, let's say you have a User model with a name field that must be present. You might define a validation like this:

```
class User < ApplicationRecord
  validates :name, presence: true
end
```

Now, if you try to save a User object without a name, like this:

```
user = User.new
user.save!
```

The save method will return false, indicating that the object was not saved, and, by using the bang version of save, an exception will be raised and the errors object on the User object will contain an error message indicating that the name field must be present. The same is true for the bang version of create and update. 

In addition to running validations when you save an object, you can also manually trigger validations on an object by calling the valid? method. This method runs all the validations for the object and returns true if all validations pass, or false if any of them fail.
 
For example:

```
User.create(name: "Jane Johnson” ).valid?
=> true
User.create(name: nil).valid?
=> false
```

In short, if you're new to Ruby on Rails like I am, learning how to use Active Record validations is essential. By mastering this feature, you'll be able to build more robust, secure, and user-friendly applications that store consistent and valid data.