teleren/devto huggingface dataset:
Como exportar grandes conjuntos de dados para CSV no Laravel?
Tags: laravel, programming, beginners, braziliandevs
Published: 2023-06-29 13:40:53

## Exportar grandes conjuntos de dados no Laravel pode ser desafiador, pois você precisa estar atento aos limites de memória e tempo de processamento.

Exportar grandes conjuntos de dados no Laravel pode ser desafiador, pois você precisa estar atento aos limites de memória e tempo de processamento.

Você viu esta mensagem de erro ao exportar grandes conjuntos de dados no Laravel?
`Allowed memory size of 134217728 bytes exhausted (tried to allocate 20971520 bytes)`

Este foi um problema com o qual lutei por muito tempo usando o pacote [Laravel Excel](https://laravel-excel.com/) até encontrar [spatie/simple-excel](https://github.com/spatie/simple-excel), o que torna isso muito fácil.

O exemplo abaixo exportará uma lista de usuários para um CSV de forma rápida e eficiente sem esgotar a memória. Usei esse método com mais de 200 mil registros gerando um arquivo CSV de mais de 30 MB em poucos minutos.

```php
<?php

namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use Spatie\SimpleExcel\SimpleExcelWriter;

class UserExportController extends Controller
{
    public function export()
    {
        $writer = SimpleExcelWriter::streamDownload('users.csv');
        $query = User::orderBy('created_at');
        
        $i = 0;
        foreach ($query->lazy(1000) as $user) 
        {
            $writer->addRow($user->toArray());

            if ($i % 1000 === 0) {
                flush(); // Flush the buffer every 1000 rows
            }
            $i++;
        }

        return $writer->toBrowser();
    }
}
```
Analyzing SassC::SyntaxError in Ruby on Rails 7.0
Tags: ruby, rails, sass, webdev
Published: 2023-06-29 13:24:11

I was running a up to date Ruby on Rails 7.0 project using cssbundling-rails. The project was in production for several months. After pushing the code to Continuous Integration (CI) using GitHub Actions it failed with an error:

```
$ sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules
Done in 3.38s.
rails aborted!
SassC::SyntaxError: Error: "var(--ts-pr-min)" is not a number for `max'
        on line 18581:18 of stdin, in function `max`
        from line 18581:18 of stdin
>>   padding-right: max(var(--ts-pr-min), var(--ts-pr-clear-button) + var(--ts-
   -----------------^
```

It was not failing on development machine. What was wrong?

Keep on reading [Analyzing SassC::SyntaxError in Ruby on Rails 7.0](https://qameta.com/posts/analyzing-sassc-syntax-error-in-ruby-on-rails-7-0/)
Top 10 best GitHub repos for beginners Programmers
Tags: webdev, javascript, programming, beginners
Published: 2023-06-29 13:06:45



🍎 **FreeCodeCamp**: https://lnkd.in/gTEiMxFP

🍎 **100 Days Of ML Code**: https://lnkd.in/gAMqhE42

🍎 **Data Science by Siraj Raval**: https://lnkd.in/gEdJSieJ

🍎 **The Algorithms:** https://lnkd.in/gyvQqg-x

🍎 **Project based learning by Tuvtran**: https://lnkd.in/gAhGZx7b

🍎 **JavaScript Algorithms**: https://lnkd.in/g-cVfgXs

🍎 **You Don't know JS**: https://lnkd.in/g4fKu_67

🍎 **30 Days of JavaScript**: https://lnkd.in/gkiKRbEp

🍎 **Public APIs**: https://lnkd.in/gQYPv7WR

🍎 **Coding Interview University**: https://lnkd.in/gmu5ezCr
Obsidian sync using git
Published: 2023-06-29 12:45:13


- Create repo in GitHub
- Clone in directory where you want it (this is for PC)
- And in terminal, just make first commit and push. So plugin in Obsidian can do those easily next time.

# Windows/Linux

- Set up ssh keys

- Install https://github.com/denolehov/obsidian-git
Community plugin in obsidian (obsidian://show-plugin?id=obsidian-git)

- Configure plugin.. like username and email, but if there is ssh in OS, then no need to set up anything else.

--------

# Android

- Create empty vault
- Install same plugin on phone.
- Create git token: 
Minimal permissions required are
"Read access to metadata"
"Read and Write access to contents and commit status"


- Under the "Authentication/Commit Author" section, fill in the username on your git server and your password/personal access token.

- Exit plugin settings, open command palette, choose "Obsidian Git: Clone existing remote repo".

You just use http way of cloning in github (so it have .git at end of url.. )

Overide 

- Then you can add username and email, to be synced...

--------

In plugin settings, add it to be synced every 1 minute.
No notifications.
Auto backup after file change
Auto pull interval 1 minute
Pull updates on startup to be On 
Push on backup to be On 
Pull changes before push to be On 

------------


[Docs](https://publish.obsidian.md/git-doc/Start+here)
FaceBook Like Clone With Source Code
Tags: javascript, vue, webdev, programming
Published: 2023-06-29 12:34:12

I'd like to share my work with you, and what you choose to do with it is completely up to you. Without any further delay, here are the links:

Source Code: https://store.brojenuel.com/l/face-book-clone-look-alike-using-vuejs

Demo: https://facebook-clone-nu-ecru.vercel.app/

Screen Shots:

![facebook clone image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ishhutomoqv2pww35l4d.png)

![facebook clone image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8gfrgrrtxex5sdt5hkzd.png)

![facebook clone image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0amynu1k0anxm3wc1jtj.png)

![facebook clone image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fcbastipq310wz3s3ji.png)

![facebook clone image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/280j0c5sjtdy7nrzrygz.png)


have a nice day! ✊😁
Deploy a .NET Core App on Ubuntu
Tags: devops, webdev, cloud, dotnet
Published: 2023-06-29 12:22:03

To deploy a .NET Core application on Ubuntu, you can follow these general steps:

Prepare the Ubuntu Server: Set up a clean Ubuntu server with the necessary dependencies. Install .NET Core Runtime and any other required dependencies for your application. You can follow the official Microsoft documentation for detailed instructions on installing .NET Core on Ubuntu.

Build Your Application: On your development machine, build your .NET Core application using the appropriate build commands for your project. Typically, you would use the dotnet build or dotnet publish command to generate the necessary files for deployment.

Transfer Files to Ubuntu: Once your application is built, transfer the application files to your Ubuntu server. You can use various methods such as SCP, SFTP, or Git to transfer the files from your local machine to the Ubuntu server.

Configure and Start the Application: SSH into your Ubuntu server and navigate to the directory where you transferred the application files. Make sure the main application executable (e.g., yourapp.dll or yourapp) is present. You may need to mark the executable as executable using the chmod +x command.

Run the Application: To start your .NET Core application, use the dotnet command followed by the name of the main application executable. For example, dotnet yourapp.dll or dotnet yourapp. This will start the application and make it accessible on the specified port.

Setup Reverse Proxy (optional): If you want to expose your application on a specific domain or port, you can set up a reverse proxy using a web server like Nginx or Apache. This step is optional but can provide additional features such as SSL termination, load balancing, and improved security.

Remember to ensure that your Ubuntu server is properly secured with firewall settings, user permissions, and other necessary measures to protect your deployed application.

These steps provide a general guideline for deploying a .NET Core application on Ubuntu. The exact process may vary depending on your specific application requirements and infrastructure setup.
SvelteKit Fetch and POST
Tags: javascript, api, sveltekit
Published: 2023-06-28 07:59:17

Is there a limit for Fetch to post or is there something else that is causing it to fail for a form?


I am not posting code, as I do not want solutions. I have put in a parameter to use Axios for a post of a form for a personal profile (about 20 fields) which works.  When I attempted to use Fetch for the same form, it does not seem to hit the server but it gets validation messages back that it does not have any of its fields. It does not appear to hit the API route. But when I switch to Axios, it works.

I suspect there is something happening in Sveltekit before the fetch call is made, as the response is instant. Maybe the validation rules are cached by Laravel?  Maybe something else is happening.

Application/Json POST requests via fetch work. This is a form request using a Content-Type: 'application/x-www-form-urlencoded' - via fetch it is failing.  Via axios, it works.

As I have a workaround, this is more of a question to see if others have experienced form POST fails using fetch to an api backend, and if so, if Axios solved the issue?  If it is not just programmer blindness to the obvious, I may be missing headers for fetch that Axios is defaulting to, or similar.  If I see a solution so I can just use fetch, will post it.
SSH to a Linux server from Windows 11
Tags: windows
Published: 2023-06-29 12:00:00

 ![SSH to a Linux server from Windows 11](https://www.techielass.com/content/images/2023/05/SSH-to-a-Linux-server-from-windows-11.png)

Connecting to a Linux server is a secure method.  In the past I have used tools such as PuTTY to connect, but I’ve recently started to use [OpenSSH](https://www.openssh.com/?ref=techielass.com).

In this tutorial I will walk you through the process of installing OpenSSH on your Windows 11 machine, and then show you how to SSH to a Linux server using OpenSSH.

## What is OpenSSH?

OpenSSH is a tool that can help you remotely sign-in to computers using the SSH protocol.  It encrypts all traffic between the client and the server to avoid eavesdropping, hijacking of the connection and other attacks.

OpenSSH is developed by developers of the [OpenBSD Project](https://www.openbsd.org/?ref=techielass.com) and is available under a BSD-style licence.

## OpenSSH on Windows 11

With the latest builds of Windows 10 and Windows 11 the OpenSSH client is installed by default.  It will be located in the directory _C:/windows/system32/OpenSSH_.  

You can check it is installed by opening **Settings** , and selecting **Apps**

![SSH to a Linux server from Windows 11](https://www.techielass.com/content/images/2023/05/ssh-apps.png)
_Windows Settings - Apps_

Then select **Optional Features**

![SSH to a Linux server from Windows 11](https://www.techielass.com/content/images/2023/05/ssh-step1.png)
_Windows Settings - Apps - Optional Features_

Now search for OpenSSH under **installed features**

![SSH to a Linux server from Windows 11](https://www.techielass.com/content/images/2023/05/ssh-search-1.png)
_Windows Settings - Apps - Optional Features_

## SSH to a Linux server using OpenSSH and a key file

To connect to a Linux server using OpenSSH here are the steps you need to follow.

Open up your terminal prompt (I am using [Windows Terminal](https://www.techielass.com/tag/windows-terminal/))

Navigate to the directory where you have stored your private key file

Type in the connection string:

<!--kg-card-begin: markdown-->
```
ssh -i "webserver-keypair.pem" ubuntu@ec2-52-12-77-76.us-west-2.compute.amazonaws.com

```
<!--kg-card-end: markdown-->

And hit enter

💡

_Remember to change the key pair file name and connection string to suit your environment and server. _

You may get a prompt asking you to confirm the authenticity of the server and key file, if you are happy to proceed type in _yes_ and hit enter.

After a few seconds you should see the welcome message confirming you have logged onto the server.

![SSH to a Linux server from Windows 11](https://www.techielass.com/content/images/2023/05/ssh-connect.PNG)
_Connecting to a Linux server with SSH_

## Logoff

Once you are finished you can type _logout_ to end the connection.

## Conclusion

Having OpenSSH built into the latest Windows builds makes it really easy to SSH into your Linux servers without having to install another tool.    
  
Have a go and let me know your thoughts!
Empowering Success: The Transformative Impact of Building Software
Tags: softwareengineering, beginners, productivity, saas
Published: 2023-06-29 11:57:44

Did you know that businesses that invest in building software are 2.5 times more likely to experience rapid growth and outperform their competitors?

In a landscape where innovation and efficiency are key differentiators, businesses that harness the power of custom software solutions gain a substantial competitive advantage. From increased efficiency and productivity to enhanced customer experiences and scalability, here you will explore 10 compelling reasons why building software is absolutely vital for achieving lasting business success.

10 Reasons Why Building Software is Vital for Business Success
1) Increased Efficiency and Productivity
2) Customized Solutions to Meet Unique Business Needs
3) Enhanced Data Management and Decision Making
4) Improved Customer Experience and Satisfaction
5) Scalability and Adaptability for Business Growth
6) Competitive Advantage in the Digital Age
7) Cost Savings and Return on Investment
8) Enhanced Collaboration and Communication
9) Data Security and Confidentiality
10) Future-proofing Business Operations

Curious to dive deeper?

Continue your journey towards unrivaled business success by reading the full blog here! Explore the 10 compelling reasons why building software is vital for your organization's growth, efficiency, and competitive edge.

From turbocharging efficiency to outshining competitors, we've got 10 rock-solid reasons why software is your secret weapon.

Get ready to uncover the secrets to thriving in the digital age: https://bit.ly/3rb4pX0

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

[Guide To Software Product Development By Experts [eBook]](https://www.aceinfoway.com/ebook/software-product-development-guide?utm_source=HP-EB-Software&utm_medium=HP-EB-Software)
My Tuples in C# note to self
Tags: csharp
Published: 2023-06-29 11:51:45

Everytime i just temporary need to send some data from one method to another i'm running into the issue, "I don't want to create a class just for this, can't just send some anonymous method of some sort".

And each time I'm struggling with Tuples. The worst thing is that it's so hard to search for "where i used it before" since it doesn't really have name to search for.

And that is why i'm writing this now.


```csharp
var myListOfTuple = row.SomeTable
    .Select(o => new { o.UserId, o.User.Number, o.User.AnotherNumber })
    .AsEnumerable() 
    .Select(o => (UserId: o.UserId, Number: o.Number, AnotherNumber: o.AnotherNumber))
    .ToList();

DoStuff(myListOfTuple);

public int DoStuff(List<(Guid userId, int Points, int SecurityLevel)> myTupleList) {

var things = myTupleList.Where(x => x.Number > 5 && x.UserId != 1234);

}

```
SEO Secret Sauce | Hacking to the top of Google
Tags: webdev, html, beginners, ux
Published: 2023-06-29 11:51:35

**Disclaimer - this was originally written for LinkedIn so I kept things short. I am more than happy to expand on any of the points which I have made and if this is popular I will go further in depth with some of the tricks I have learned in 13+ years experience in the SEO Sphere**

For **SEO & UI ** to 🔥𝘀𝘁𝗮𝗻𝗱 𝗼𝘂𝘁 🔥you really need some secret sauce (wow that's a cheesy) - I'm going to go into a bit of detail with mine. Guess it won't be so secret anymore but it might help you, my connections and hopefully as a result the wider web. If you have any simple hacks that you use please drop a comment at the bottom.

First, I will say that SEO is not about link building onsite or offsite. It is about organic networking and connections, and that often gets mixed up.

## Networking & Mobile SEO

For a business of any size, local SEO is important. Even if you are purely online, having a maps presence will help - Alphabet/Google, for example, use their correlation between good maps presence and higher rankings to keep user experience metrics high, and as a result, often maps can be a way of hacking to the top listing for high traffic & high competition keywords.
But it goes far beyond this.

A lot less talked about is how Alphabet uses all the data that they collect when 73% of phone users set up their Android account beyond being sold. With such a massive chunk of an already huge market, Google has near-free rein to use data as they will. A lot of this goes to internal product improvement. Did you know that website bookmarks are a direct ranking factor (at least for Google News)?

Similar to liking a video, this is a democratic way of Alphabet letting users voice what they like and dislike. Particularly useful when blogging, if you only focus on having a reactive site, you are missing out on a huge number of visitors.

## Conclusion

This is such a deep rabbit hole that, for brevity, I will just say that if you aren't using declarative HTML5 markup and have taken a user-first approach to your SEO and web design strategy, you are haemorrhaging money. If you want me to expand on anything or send references, just comment or drop me a message
How Profitable Are Food Trucks?
Tags: business, beginners, news, startup
Published: 2023-06-29 11:47:14

Food trucks have become a ubiquitous sight on the streets of cities worldwide, offering a diverse array of delicious cuisine conveniently on the go. From gourmet burgers and tacos to artisanal ice cream and fusion dishes, these mobile eateries cater to diverse tastes and have gained immense popularity. 

However, potential food truck owners often wonder about the profitability of this business model. In this article, we explore the factors that contribute to the profitability of food trucks and shed light on their financial prospects.

The Profitability Factors:

Lower Overhead Costs: One of the key advantages of food trucks is their relatively low overhead costs compared to traditional brick-and-mortar restaurants. Rent and utility expenses are significantly reduced, and a smaller staff can be employed. This cost-saving allows food truck owners to allocate more resources towards high-quality ingredients and innovative menus.

Flexibility and Mobility: 

Food trucks have the advantage of mobility, allowing operators to relocate to different areas based on demand. They can participate in festivals, events, and even catering services, maximizing their exposure and potential customer base. This flexibility enables food truck owners to adapt quickly to changing market trends and capitalize on emerging opportunities.

Growing Popularity: 

Food trucks have captured the imagination of food enthusiasts and have become a cultural phenomenon. The unique dining experience, combined with the allure of discovering new flavors, attracts a loyal customer base. Social media platforms and food truck finder apps have played a significant role in connecting hungry customers with their favorite mobile eateries, further boosting the popularity of food trucks.

Food Truck Finder Apps:

[Food truck finder apps](https://www.apurple.co/food-truck-finder-apps/), such as Roaming Hunger and StreetFoodApp, have revolutionized the way people locate and engage with food trucks. These apps provide real-time information about the location, operating hours, and menus of nearby food trucks. For food truck owners, these apps offer invaluable visibility and the opportunity to attract new customers. Customers can explore a variety of cuisines, find food trucks closest to their location, and leave reviews to help others make informed choices. The convenience and accessibility of these apps have undoubtedly contributed to the success and profitability of food trucks.

Conclusion:
While profitability varies based on location, concept, and execution, food trucks have proven to be a lucrative business for many entrepreneurs. The lower overhead costs, mobility, and growing popularity of food trucks contribute to their potential profitability.
auto load .env กัน
Published: 2023-06-29 10:20:10

หนึ่งในวิธีที่จะทำให้เรา dev ได้สะดวกขึ้นคือการทำให้พฤติกรรมของ app เราที่ run บนเครื่องมีความเหมือนกับที่ run บน production ให้ได้มากที่สุด ซึ่งหนึ่งในเรื่องนี้ก็คือการ load ค่า configurations ซึ่งความคุ้นเคยในอดีต หลายๆคนจะชินกับการใช้ config file ต่างๆ ไม่ว่าจะเป็น yaml, tomal หรืออื่นๆก็ตาม

แต่พอเอาขึ้น production จริงส่วนใหญ่เราก็ใช้ค่าใน env ซึ่งเป็นคำแนะนำจาก [12factors](https://12factor.net/) นั่นเอง

ยกตัวอย่างเวลาผมเขียน Go ในอดีตก็เคยใช้ viper เข้ามาช่วยอยู่พักหนึ่ง เพราะมันยืดหยุ่น ให้สามารถใช้ค่า config จาก file ก็ได้ หรือใช้จาก env ก็ได้ใน code ชุดเดียวกัน แต่ เอาเข้าจริง พฤติกรรมมันก็ต่างกันโดยสิ้นเชิง เพราะถ้าเราไป copy example ของ viper มาใช้ตรงๆ ก็จะพบว่า ถ้าเราไม่โยน config file เข้าไปใน dockerfile มันจะ run ไม่ขึ้น เรามาดู code ตัวอย่างกัน

```go
viper.SetConfigName("config") // name of config file (without extension)
viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name
viper.AddConfigPath("/etc/appname/")   // path to look for the config file in
viper.AddConfigPath("$HOME/.appname")  // call multiple times to add many search paths
viper.AddConfigPath(".")               // optionally look for config in the working directory
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
	panic(fmt.Errorf("fatal error config file: %w", err))
}
```

code นี้มันจะ panic เมื่อไม่เจอ config file ซึ่งถ้าเราอ่านมันเข้าใจ เราก็แค่แก้มัน ไม่ให้มัน panic ก็ได้ แต่อย่างไรก็ดีมันก็จะทำให้ พฤติกรรมของ code ที่ทำงานบนเครื่องเรา กับที่ทำงานบน production จริงต่างกันอยู่ดี

วันนี้ก็เลยอยากชวนมาใช้ .env file แทน ซึ่งจำเป็นจะต้องใช้คู่กับ [direnv](https://direnv.net/)

เริ่มต้นเราก็ install ตามคู่มือกันก่อน และผมก็เลือกใช้ HomeBrew เนื่องจากผมใช้ Mac

> brew install direnv

จากนั้นก็ไป hook ตามที่คู่มือบอก ซึ่งผมใช้ zsh ก็เอาบรรทัดนี้ไปวางใน .zshrc

```sh
eval "$(direnv hook zsh)"
```

ทีนี้โดยปกติ `direnv` จะทำงานคู่กับไฟล์ `.envrc` โดยเมื่อวางไว้ที่ directory ใดก็ตาม เราก็จะต้องทำการ allow ให้ direnv ยอมโหลดค่าจากไฟล์นี้ก่อนด้วยคำสั่ง

```sh
direnv allow
```

แต่เนื่องจากโดยปกติเรามักจะคุ้นกับการใช้ไฟล์ `.env` กันมากกว่า แต่ถ้าจะให้ `direnv` รู้ว่าเราจะใช้ `.env` แทน ก็จำเป็นจะต้องทำ config กันก่อน โดยเราจะทำไว้ที่ระดับ global กันไปเลย จะได้ไม่ต้องมาทำมันบ่อยๆ

ให้สร้างไฟล์ไว้ที่ `.config/direnv/direnv.toml`

แล้วใส่เนื้อหานี้ลงไป

```toml
[global]
load_dotenv = true
```

เมื่อทำครบทุกขั้นตอนแล้ว หลังจากนี้ เวลาเราจะ dev อะไรก็ตาม แล้วต้องการใช้ค่า env เป็น configurations เราก็เพียงแค่สร้างไฟล์ .env วางไว้ใน directory นั้น เช่น

```sh
PORT=8080
LOG_LEVEL=INFO
```

และเมื่อมีการแก้ไขไฟล์นี้ หรือสร้างไฟล์นี้ขึ้นมาใหม่ เราก็ต้องทำการ allow มันด้วยคำสั่ง

```sh
direnv allow
```

หลังจาก allow มันแล้ว ตราบเท่าที่ไฟล์นี้ไม่มีการแก้ไขใดใด มันก็จะ auto load ค่าใน .env มาให้เราทุกครั้งที่เราเข้าไปทำงานใน directory นั้นๆ ทีนี้ใน code ของเรา ก็แค่เรียกค่า config มาจาก env ได้โดยตรง แล้วก็จะทำให้ code ที่รันบนเครื่องเรา กับบน prodution ทำงานแบบเดียวกันได้แล้ว
HTML Styles
Tags: webdev, javascript, beginners, html
Published: 2023-06-29 11:41:21

HTML is primarily used to define the structure of the web page While Cascaded style sheets (CSS) are a language that is used for the presentation of HTML Pages.

Using CSS in HTML, we can change colors, fonts, and other kinds of formatting on a web page. There are many different ways to include CSS in an HTML page. We will see a simple way to apply CSS Rules in the HTML Document.

For More details  visit : https://realmediums.online/html-styles/