teleren/devto huggingface dataset:
Laravel Custom Blade Directive
Tags: laravel, blade, custom
Published: 2022-05-31 14:01:54

Hi there folks,

Today, I would like to talk about the laravel custom blade directives. You would have probably seen @if, @endif which are called directives.

In this post, I would help you to create your own directives and their limitations and use-cases that will eventually help you to make your application developments much easier.

We will got through the example directive here. First create a provider with artisan.

`php artisan make:provider BladeServiceProvider`

The path will be `app/Providers/BladeServiceProvider`
```
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;

class BladeServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}

```

## @print(object)

In the boot function of the provider we have just created.

```
Blade::directive('print', function ($payload) {
     return "<?php 
       echo'<pre>';
       print_r($payload);
       echo'</pre>'; 
     ?>";
});
```

We can then use this directive as `@print($any_object_or_array)` in any blade template.
If this directive don't work or display then the issue lies with the cache. You have to purge the view cache or you can run `php artisan optimize:clear` to purge all cache of any type.

This is just minimal implementation and use-case of blade-directives.

## Limitations & Issues

The main issue you will encounter with the results of this custom-directive is of cache. If you don't make these to be dynamic in-nature. Then laravel cache engine nullified your generic-behaviour of your directive.

`Blade::directive('{name}', function () { return 'string_expression'})`

`{string_expression}` is an expression in string form like 
`"<?php ehco('Hello World'); ?>"`.

But if you passed something un-proccessed form of code like using another directive or laravel blade-view injection like
`return view('blade',compact($var));`.
It conflict with the cache-engine of laravel.

If you want to render the some blade template on using your directive you can code something like 
`return "<?php echo view('blade',compact('$model'))->render(); ?>";`.

If you have any query or problem that you wanna share then just ping @bilalthepunjabi in discussions.
Building a Modern React Chrome Extension with a New Framework
Tags: javascript, webdev, beginners, react
Published: 2022-05-31 13:59:14

When I first started building Chrome extensions, I was so annoyed with the boilerplate. 

It was frustrating to configure the `manifest.json`, pointing it to the correct files. You had to read at least 4 blog posts to figure out how to do it correctly. The annoyance compounded if you tried to use modern JavaScript frameworks like React. Now you needed to deal with Webpack, and figure out how that played into the `manifest.json` story. 

We decided to tackle this problem by building a framework for browser extension development called [Plasmo](https://docs.plasmo.com). It's a different way of thinking about browser extensions, and if you're used to building extensions, some things might look a bit weird.

If you want to follow along, run:

```sh
pnpm dlx plasmo init
```

Looking at the directory `plasmo init` generated, you might notice there is no `manifest.json`. 

![Plasmo directory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qg3xl8kil86s15xqkzch.png)

This is one of the key features of the Plasmo Framework -- we auto-generate the `manifest.json` so you can focus on building cool stuff rather than caring about where to point `content_scripts` to, and what the schema format should look like.

The idea is simple: you add a file called `popup.tsx` exporting a React component, and Plasmo will understand it's a popup page. It'll register it in the manifest and write the code to automatically mount the component into your popup view.

The same is true for `content.ts`, `background.ts`, and `options.tsx`. The framework understands what these files are, and automatically builds the manifest with them in mind. 

If you have multiple scripts, you can use `contents/`, `options/`, and `popups/` directories to get the same effect. 

## Key Principles:

### No manifest.json file
We strongly believe the manifest.json file is a [leaky abstraction](https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/). That's why we built the framework to generate as much of the manifest as possible. 

We've still got a bit of a way to go, but we've automated a large chunk of it out.

### It's good to have opinions

This framework is not for everybody, and that's completely okay. Our goal is not to make a framework that caters to everyone's needs. Instead, we're focusing on people who want to build production-grade extenisons using React quickly. 

If someone wanted to build a minimalist extension that used vanilla Javascript, this framework would not be for them.

### MV3 Only

Manifest version 3 is the future. Let's embrace it and build good tooling around it to enable people to build amazing products. 


## Docs
Check out our [docs](https://docs.plasmo.com) to see other cool features we have. We're constantly iterating and improving, so if you have feedback, would love to hear it!
Beginner’s guide to infrastructure management
Tags: technology, cybersecurity, news
Published: 2022-05-31 13:48:46

Information technology is the foundation of the digital world. Businesses need an impenetrable infrastructure for managing data. Which resources can fulfill these requirements?

Businesses handle market data for analyzing changing trends and keeping pace with the market. The need for infrastructure demands suitable assessments for [**database security**](https://ai-techpark.com/cyber-security/database-security/). The Information Technology department has to be aware of practices and procedures for data confidentiality.

**Information Technology pain points**

Information technology encompasses many factors affecting the business infrastructure. These include hardware and software, anti-virus software, and relatable aspects of the organization.

**IT resources**

Technology infrastructure is unlimited space for software targetting workspace data leaks, confidential information, and other trading secrets.

**Database security**

A bigger picture of the markets indicates that each business strives to protect its data. A step in this direction is auditing and reporting data breach incidences.

**Cloud Security**

Businesses rely on cloud storage for ease of access. A step in direction requires attention to cloud security. A blind eye to this can cost tons of money for the organization and lose customers in no time.

Read Full Article on Website @ [**Beginner’s guide to infrastructure management**](https://ai-techpark.com/beginners-guide-to-infrastructure-management/)
Day 3 - Initializing Smart Contract
Tags: solidity, 100daysofcode, blockchain, web3
Published: 2022-05-31 13:44:00

This is Day `3` of `30` in Solidity Series
Today I Learned About Initializing a Smart Contract in Solidity.

Smart contracts are simply programs stored on a blockchain that run when predetermined conditions are met. They typically are used to automate the execution of an agreement so that all participants can be immediately certain of the outcome, without any intermediary’s involvement or time loss. They can also automate a workflow, triggering the next action when conditions are met.

```solidity
contract ContractName {
    Statement1;
    Statement2;
}
```

It is Recommended to use Pascal case Notation for the Contract Name, you should capitalize first letter of each word in the contract name. eg - 
```
MyContract
SendFunds
MintNft
```

---
{% embed https://github.com/Envoy-VC/30-Days-of-Solidity noreadme %}
Uyarı Tanımında veya Ekran Kontrolünde Alanın Değerinin Değiştiğini Anlama
Tags: uyumsoft
Published: 2022-05-31 13:27:38

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wgs4xwdwbsbmn8gscqa.png)
Re-Deploy Your Project on heroku and firebase
Published: 2022-05-31 13:23:20

**Client side** :

First of all client side code upload in github.

`git add .
git commit -m" commit message"
git push`

then:

```javascript
npm run build
firebase deploy
```

**Server side**

First of all Server side code upload in github.

`git add .
git commit -m" commit message"
git push`

then:

```javascript
git push heroku main
```
VS Code ShortCut
Published: 2022-05-31 13:21:00

`Line move/Upper line to Lower Line move`: 

```
Alt + Up Arrow keys
```


`VS code side bar or explorer part, hide or open`: 

```
Ctrl + b  keys
```


`Make multiline in vs code`: 

```
Shift + Alt + Arrow Keys(Upper arrow/Lower arrow)
```


`Multiline editing in vs code`: 

```
Ctrl + Alt + Arrow Keys(Upper arrow/Lower arrow)
```


`How to align code in visual studio code`: 

```
Shift + Alt + f 
```


`keyboard shortcut for any task in visual studio code`: 

```
Ctrl + Shift + p 
```


`keyboard shortcut for emmet shortcut in visual studio code`: 

```
Ctrl + Space 
```


`Search file in the folder(that open in vs code) in visual studio code`: 

```
Ctrl + p 
```


`Search any text/keyword in the folder(that open in vs code) in visual studio code`: 

```
Ctrl + Shift + f 
```
How do I write a blog post?
Published: 2022-05-31 13:13:06

## In lieu of me recently writing [my new website](https://hycord.is-a.dev) I realized that I don't really know how to write a good blog post.
I know that blogging is a good thing to do as a new/young developer (I'm only _16_) but I just don't know what to write, or how to make it look good.
As you can see if you go to the link I provided, the blog post I have looks horrible, and the content isn't much better.
I just don't know how I can improve what I have going on right now.

For context: 
_I currently don't have my laptop and am working off the chrombook my school gave me, so I have to use github pages right now, I'm more so asking for basic styling tips, and what **content** I should have, over something like _
> Oh, you should add authentication so everyone can do blah blah blah
I just want some basic pointers and feedback on what I made last night lol
Thanks to anyone who takes the time to read this and respond
How does Git work?
Tags: git, gitops, devops, developers
Published: 2022-05-31 13:08:38

Git is a free and open-source version control system originally created by Linus Torvalds, who wrote [Linux](https://bpbonline.com/search?q=Linux&type=product); he released Git around 2005. Git immediately became popular among developers because it was free, open-source, and distributed, unlike the other version control systems of the time, which were SVN and CVS.

When we say Git is distributed, it means that every user or developer has their own local repository with a full history of their code on their local disk. Although this makes the initial clone of the repository slower, it has many advantages to compensate for this, like portability, privacy, and the ability to work offline. Subsequent Git operations such as commit, blame, diff, merge, and log are also faster.

Git is as much a collaboration tool as it has excellent support for branching, merging, and rewriting repository code history, which has led to many innovative and powerful workflows and tools. However, the problem with Git is that it is not so much difficult as unintuitive; learning the terms does not come easily for most people. Nonetheless, Git is the most widely used version control system in the world today and is considered the modern standard for software development.

To get to grips with Git, we need to first try to understand the opaque language and terms. Here is a basic overview of the most common Git tasks and their associated terms, which also gives us a glimpse into how Git works:

- You need to create a repository (project) with Git.
- You Clone (copy) the remote repository to your local machine.
- You then add files to your local repo (repository) and "Commit" (save) the changes.
- To advertise your local changes to the team, you Push" your changes to the main branch in the Git repo.
- You make a change to your file with a Git and commit the change.
- You Pull other people's code or changes to your local machine from the Git repo.
- You Create a branch (a new version of the code tree), make a change, and commit the change to prevent damaging the master tree.
- You Open a pull request (propose changes to the main branch).
- When the team agrees that the code is good, they Merge your branch with the main branch.

At its core, Git is a valuable code source control system, but it has changed the way we think about code. It is the inspiration behind the latest development and operations initiatives, such as code-based infrastructure and operational procedures that rely on Git as the single source of truth. Git has also inspired GitOps, which is an evolution of Infrastructure as Code (IaC) and [DevOps](https://bpbonline.com/search?q=DevOps&type=product) best practices, which are based upon Git's practice of using pull requests to verify and automate the deployment of system infrastructure. However, at the heart of Git or any other software versioning or control system is the trust in the integrity of the repository, and this requires strict access control from the ground up.

Hope this was helpful.
Trunk Based Development คือ ?
Tags: git
Published: 2022-05-31 13:02:26

ความจริงเรื่องของ TBD ไปอ่านละเอียดได้ที่ https://trunkbaseddevelopment.com/

แต่ถ้าจะลองสรุปตามความเข้าใจง่ายๆก็จะประมาณว่า มันคือวิธีที่ทีมใช้ branch เดียวในการ develop ไม่ว่าจะมีกี่ feature ก็ตามก็จะ push-pull ไปที่ branch เดียวเสมอ ในกรณีที่มี feature ไม่ได้มากนัก
ในกรณีที่มี feature เริ่มเยอะ อาจจะมีความเป็นไปได้ว่าจะมีการแตก branch ออกไปได้ แต่ก็จะทำในช่วงเวลาสั้นๆ (สั้นมากๆ) และรีบ merge กลับไปที่ branch หลัก(อาจจะทำคนเดียว และทำแค่ 1-2วัน)

นี่คือคำอธิบายสั้นๆสำหรับการทำ Trunk Based Development

ข้อดีของการทำ TBD มีหลายสิ่ง หลักๆก็คือการเลี่ยง merge hell

สิ่งที่จะตามมาจากเรื่องนี้ก็จะมีอีกหลายสิ่ง เช่น Feature Toggle เนื่องจากเราทำงานกันบน single branch การจะ release feature ใดๆ ก็ควรจะมี trigger ซึ่งต่างจาก feature branch ที่เราแตก branch ตาม feature และอาจจะทำ PR เข้ามา branch หลักเพื่อ release แต่สุดท้ายก็อาจจะหนีการทำ toggle ไม่ได้อยู่ดี

การทำงานบน branch เดียว จะเหมือนถูกบังคับให้มี feature toggle ไปโดยปริยาย ซึ่งข้อดีคือ เราจะรู้ตัวตั้งแต่แรก ว่าเรามี toggle และเราจะเทสมันอยู่เรื่อยๆด้วยซ้ำ ซึ่งข้อนี้มีข้อเปรียบเทียบเล็กน้อยระหว่าง การมาเพิ่ม toggle เมื่อยามฉุกเฉิน เช่น ทีมทีทำ feature branch มาโดยตลอด มาวันหนึ่ง merge ของทุกอย่างพร้อม release แต่ดันมีบาง feature ต้องปิดไว้ก่อน
ทีมอาจจะเลือกทำ cherry-pick เฉพาะการ toggle เข้าไป ซึ่งเป็นของใหม่ และอาจจะยังเทสไม่ครบถ้วนเข้าไป แบบนี้จะมีความเสี่ยงมากกว่าการมี toggle ตั้งแต่แรก

อีกเรื่องหนึ่งที่จะตามมาคือ คำถามและข้อโต้แย้งจากคนที่ทั้งชีวิตเคยทำแต่ feature driven แบบ branching มาโดยตลอด และพอเจอทีมที่จะผลักดัน TBD พวกนี้ก็จะพยายามดันกลับไปทำ branching ให้ได้ เพราะความไม่เข้าใจ และไม่คุ้นเคย คนพวกนี้เวลาเราเล่า TBD ให้ฟัง ก็จะทำหน้ามุ่ย แล้วก็บอกแต่ว่า เราทำไม่ถูก ของที่ถูกมันต้องแตก branch แล้ว PR สิ อันนี้บอกตรงๆ เหนื่อย!!! วิธีมันมีตั้งเยอะแยก ไม่ใช่ว่าเคยทำมาแบบเดียว แล้วมันจะมีแค่แบบเดียวซะที่ไหนน้อ

แย่กว่านั้นคือ บางบริษัทมีทีม DevOps ที่คอยกำกับการ deploy และมี framework ไว้ให้แล้ว พวกนี้ก็คุยยากเหมือนกัน เพราะการที่เรานำเสนอแนวทางอื่น เขาจะมองว่าเราไปแหกกฎเหล็กของเขา ซึ่งเป็นความผิดร้ายแรง ต้องเอาไปแก้ให้ตรงกับของที่เขาทำไว้สิ แบบนี้ยิ่งเหนื่อยกว่า

ส่วนตัวผมเคยทำงานกับทีมที่ใช้ Single Branch ยังไม่ถึง TBD แต่ก็เกือบๆละ ซึ่งทีมนี้ก็มี release ทุกๆครึ่งเดือน และทำ feature toggle มาตั้งแต่แรก 7-8 ปีมาแล้ว ก็น่าจะยังทำแบบนี้อยู่(เพราะออกมาแล้วเลยไม่รู้) ผมว่าปัญหามันก็มีบ้าง ก็ต้องแลกกับ feature branch แหล่ะเอาจริง แต่ถ้าให้เลือกเจ็บ ผมยืนยันเหมือน SM ของผมคือ จั๊ว Odd-e ว่า ผมยอมเจ็บแบบใช้ feature toggle ดีกว่าเช่นกัน

เพราะแค่ merge code ธรรมดาแล้วเจอ conflict บางรอบก็เล่นเอาเหงื่อตกกันแล้ว แล้วถ้าไป merge ทั้ง branch ทิ้งเวลาห่างกันเป็นสัปดาห์ ผมคิดว่า สวดพานยักษ์ก็ยังไม่สบายใจถ้าจะให้ผมลอง merge ดู

เพราะอย่างน้อยในหนังสือ ProGit ก็บอกตั้งแต่บทแรกๆว่า วิธีใช้ Git ที่ดีคือ merge ให้บ่อยที่สุด ผมก็เลยจะติดนิสัย  git commit ถี่มากๆ และ push/pull บ่อยมากๆ ซึ่งมันก็ตรงกับการทำ TBD ตรงนี้พอดี ที่เราทำงานบน branch เดียวเสมอ ไม่ทิ้งระยะการ merge ให้นานไป เพราะการคุยกันของ developer เราคุยกันผ่าน code  เพราะฉะนั้น ยิ่งคุยกันบ่อยยิ่งดีนะครับ


และถ้าไปจนสุดเลย การทำ TBD อาจส่งผลไปถึงการจัดทีมทำงานกันเลยทีเดียว
DevToys: A Swiss Army knife for developers
Tags: tooling, productivity
Published: 2022-05-31 12:47:59

Maybe you just know [PowerToys](https://github.com/microsoft/PowerToys#about). It's a set of utilities for power users to tune and streamline their Windows experience for greater productivity.
[DevToys](https://github.com/veler/DevToys) is more or less the same thing, but for developers.

## Introduction
Before I discovered DevToys, I was using a lot of online tools on different sites.
Of course every time I needed to remember the url of the tool, or open Notion to find my notes about the tools and I wasted a lot of times.
At the moment there a lot of tools available inside DevToys:

- Converters
  - JSON <> YAML
  - Timestamp
  - Number Base
- Encoders / Decoders
  - HTML
  - URL
  - Base64 Text & Image
  - GZip
  - JWT Decoder
- Formatters
  - JSON
  - SQL
  - XML
- Generators
  - Hash (MD5, SHA1, SHA256, SHA512)
  - UUID 1 and 4
  - Lorem Ipsum
  - Checksum
- Text
  - Escape / Unescape
  - Inspector & Case Converter
  - Regex Tester
  - Text Comparer
  - Markdown Preview
- Graphic
  - Color Blindness Simulator
  - PNG / JPEG Compressor
  - Image Converter

If you have a new idea, translate the tools in your language or other stuff, DevToys is opensource and it's open to receive Pull Requests.
You can find the repository [here](https://github.com/veler/DevToys/)

## How to install DevToys
There are several ways to install DevToys on your machine.
The easiest is download it from the [Microsoft Store](https://apps.microsoft.com/store/detail/devtoys/9PGCV4V3BK4W).

![Microsoft Store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u30mqlhka1uwsem8fzu2.png)
In this case DevToys will update itself automatically directly from the store.

Another way is to use WinGet. You need a Microsoft Store account as well, but in this case you can manage the updates with WinGet commands.
To install it from WinGet:

**winget install DevToys**

Or if you want, you can install it from Source Code, directly.

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

## Run DevToys from PowerShell
One of the feature that I love is that you can launch DevToys directly from PowerShell.
I have always a Windows Terminal open during the day and it's more quick for me to launch DevToys from there.
The command is very easy to write:

**start devtoys**

If you want to launch a specific tool, you can just add the name of the tool as parameter:

**start devtoys:?tool=jsonyaml**

You can find the name of the tools directly on the GitHub page of the project.

![DevToys PowerShell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmbq5akcinun8zcs27uv.gif)
Release 3.0 Pre
Published: 2022-04-21 04:36:30

The last two weeks for the last release, everyone's busy with other assignments and finals, and including me as well. When I envisioned 3.0 I had thought that we'd have something stable and it'd be more about putting in tests, smoothing out docs and maybe dealing with a few critical bug fixes. But, its seems that we're still trying to cram a lot of major stuff in this release. Changes that make it seem like I have to know Telescope again, as if I've never worked on it this semester. But, maybe more on this later. 

---

## Indexer tests
The last set of issues for me adding in autocomplete indexing is to [add unit tests for our `Indexer`](https://github.com/Seneca-CDOT/telescope/pull/3490). The tests might not seem like much, but ElasticSearch-mock was at it again, playing around with me for "old times sake". As I had probably mentioned blogs ago, ES-mock is rather strict with its mocking. If it doesn't like the request that it's detected, it'll complain. 

When for indexing it was trying to translate console commands to javascript, for mocking it was the other way around. Sometimes the ElasticSearch documentation aren't really that helpful either. Like the [`create` api, for example](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html), there's four possible requests. 

Anyways, I eventually found a way to deal with the horrifying `mock-not-found` error. For any future playmates of ES-mock that happen to stumble upon this blog, if you ever get that error, just console log `error.meta.meta.request`, and you'll see the correct request path that its trying to call.

It was also neat I got to play with spying on `logger` for these tests. Just remember to also `jest.clearAllMocks();` after each unit test, or the log spies will interfere with one another. 

---
## Search service README
A smaller documentation PR I did was to update the [Search readme](https://github.com/Seneca-CDOT/telescope/pull/3524). Technically its partially my fault for not having kept it up to date when I made all those changes in Search. 

I had initially wanted to do a bit more for this Search README, and maybe set the service up with a `dev` script and document in the README how it can be used. Kind of like how I had written it in a [previous blog](https://dev.to/rclee/28-update-elasticsearch-research-5dgj). In order to make it useful I'd have to know which docker images needed to be run for Search to fully function (with results). But, as I had mentioned above, quite a bit of new stuff has been merged into this last release, that I am not even sure anymore. So, maybe when things are more stable and clear, I can get back to it. 

---

On a side note, a rather cool PR that I reviewed was on a [CloudFormation template](https://github.com/Seneca-CDOT/telescope/pull/3455). I think it might be nice for future students who also work on potatoes for Telescope. Just please do remember to delete the stack when done working. 

---
## Conclusion
I have a final during the time when the release is scheduled to happen. So, all I can say now is, fingers crossed, I hope everything goes smoothly.
Have you heard about Glitch? Or colab?
Tags: tooling
Published: 2022-05-31 12:46:13

I may be late to the party here, but I've been going through [an awesome class on EdX.org on ML](https://www.edx.org/course/google-ai-for-javascript-developers-with-tensorflowjs) and for some of the exercises, we use [glitch.com](https://glitch.com/), which I had never heard of before. But it's a playground kind of site where you can put together a prototype of a JavaScript app (and perhaps other tech stacks are supported, too, but I was just using JS) and it provides a live, hosted, and sharable preview.

Another tool I learned in the process was [colab](https://colab.research.google.com/), which is similar, but is a full-blown hosted environment for Python projects.