teleren/devto huggingface dataset:
Clipboard API and Angular
Tags: typescript, angular, webdev
Published: 2024-02-02 15:10:25



In this article, I will show you how to display an image copied directly into your application using Ctrl+V.
Configuration in the Template

In your template, you will create a div that listens to the (paste) event. This event will be triggered when the user performs a CTRL+V, and it defines an area in your application where users can paste content:

```
<div style="height: 500px; width: 500px;" (paste)="onPaste($event)" >

      <img *ngIf="imageSrc" [src]="imageSrc" alt="Pasted Image">

  </div>
```

Processing Clipboard Data

This will provide you with a ClipboardEvent, in which you can find everything that has been copied, be it text, an image, a PDF file, etc. Here, I will filter based on the MIME type of the file to ensure it is indeed an image. However, you can also paste other file types like a Word or PDF file directly into an <input type=”file”>, for example, using Ctrl+V.

```
public onPaste(event: ClipboardEvent): void {

    const clipboardData = event.clipboardData;

    if (clipboardData) {

      const items = clipboardData.items;

    // Check if there is at least one item and if the first item is an         image

      if (items.length > 0 && items[0].type.indexOf('image') !== -1) {

// Attempt to retrieve the image file from the clipboard item

        const blob = items[0].getAsFile();

        if (blob) {

          const reader = new FileReader();

          reader.onload = (event: ProgressEvent<FileReader>) => {

            if (event.target)

            // Setting the component's imageSrc property to the base64 data URL of the image

              this.imageSrc = event.target.result as string;

          };

          reader.readAsDataURL(blob);

        }

      }

    }

  }
```

 Remember to declare your imageSrc as public:

```
  public imageSrc = "";
```

Global Listening on the Document

You also have the option to set up global listening on the entire document, not just on a div, in this manner:

```
constructor(@Inject(DOCUMENT) private document: Document) { }

  ngOnInit() {

      this.document.addEventListener('paste', this.onPaste.bind(this));

  }
```

This way, no matter where the focus is, you can retrieve the file.
Sloan's Inbox: Any advice for a web dev who is considering a career in cybersecurity?
Tags: discuss, webdev, security, cybersecurity
Published: 2024-02-08 11:45:00

Hey folks! Sloan, DEV Moderator and mascot. I'm back with another question submitted by a DEV community member. 🦥

For those unfamiliar with the series, this is another installment of Sloan's Inbox. You all send in your questions, I ask them on your behalf anonymously, and the community leaves comments to offer advice. Whether it's career development, office politics, industry trends, or improving technical skills, we cover all sorts of topics here. If you want to send in a question or talking point to be shared anonymously via Sloan, that'd be great; just scroll down to the bottom of the post for details on how.

Let's see what's up this week...

### Today's question is:

> I'm early in my career and considering changing focus from web development to cybersecurity. I've been thinking about it because I'd like to get a secure job with a potential pay increase, and it seems to be a good way to differentiate myself from other devs. I'm just worried that I'm not going to enjoy it and that it could be a distraction. Does it sound like a good decision to explore cybersecurity? Likewise, has anybody made any similar moves before from web development to cybersecurity? If so, I'd really love to hear any advice you have.
>

Share your thoughts and let's help a fellow DEV member out! Remember to keep kind and stay classy. 💚

---

*Want to submit a question for discussion or ask for advice? [Visit Sloan's Inbox](https://docs.google.com/forms/d/e/1FAIpQLSc6wgzJ1hh2OR4WsWlJN9WHUJ8jV4dFkRDF2TUP32urHSAsQg/viewform)! You can choose to remain anonymous.*
Learning Clojure Part 1
Tags: beginners, programming, tutorial, clojure
Published: 2024-02-02 22:55:17

After being persisted by my friends to learn Clojure, I finally caved and now we are here. I am not an expert going into this i am in fact as clueless as a beginner with experience mainly in java and python. SO please feel free to correct any mistakes i may have made  

## What is Clojure
For those people who don't know, Clojure is a functional programming language that runs on JVM (java virtual machine). It is described as a dynamic general purpose language, and every feature is supported at runtime. What this means is that you can run commands at run time and we will get to know this better over the course of the series. 

## How to get Clojure running
There are many ways to do this for different operating systems and i suggest you go look at some videos, or articles suited to your operating system to get Clojure running. Usually you would need:

- Leiningen, which is a build system for Clojure
- A JDK, as Clojure runs on JVM
- A IDE, in my case i use IntelliJ, not for any particular reason, simply because I do all my java in it

## Actually writing some code
Now to the fun bit, coding. It would be worth noting that i am following tutorialspoint.com for learning, so you can always check them out if you ever don't understand anything. Also we write Clojure in a .clj file. 

# Hello World
What better way to start than writing a hello world prompt:

`(ns clojure.examples.hello
   (:gen-class))
(defn HelloWorld []
   (println "Hello World"))
(HelloWorld)`

This is one way to do it, and I think that will explain the basics well. 
'defn' is how we define a function, and in functional programming, functions play a pretty big role, but we will come onto that later. 
Our 'HelloWorld' function is defined to print the statement "Hello World". To call the function we simply put call it in a pair of parenthesis.

Of course we could simply do something like 
`(ns clojure.examples.Main
  (:gen-class))
(println "hello world")`

But i feel like this is not giving the right feel for Clojure from what I have seen, as it's true capabilities lie in it's functional side.

# Prefix notation
There is just one more thing that I would like to touch upon in this article and that is prefix notation. This simply means that operators are placed before operands, two examples below:
`(+ 1 2)
(str "Hello" "World")`

In the first line we are simply doing: 1 + 2, but in prefix notation we put the '+' first . You can think of the '+' being the function and the 1 and 2 being it's 1st and 2nd parameters respectively.

It is the same for the second line. We are simply using the str operator to concatenate (add strings to make one big string) the two strings given , which can also be considered as parameter

## Conclusion 

Well that is it for today. I hope that my explanation of the basics was good enough peak your interest and I hope that you will join me in this journey. Please feel free to help me through the comments if you are already experienced at this. Thank you and until next time.
What I Learned This Week - Week 2
Published: 2021-09-26 15:40:43

## NOTE:
I'm posting my personal journey of participating in a boot camp, as a person who recently seriously started to learn programming. So it might not contain useful information at the moment. But hopefully, after four months, I will post things that are encouraging to aspiring developers, with current posts as evidence of how much I have grown since the beginning.

## About learning
It's been two weeks since the boot camp started, and I feel like I have learned a lot more this past two weeks than what I have learned on my own for the past several months, although it was on and off. 

My motivation for joining the boot camp was to put myself in an immersive learning environment with people who are also motivated. I've tried self-learning, but no matter how much I was diligent, I realized my learning progress can't be as fast as someone who learns in a community with wealth of information and with people who are very motivated. After all, humans are social creatures and we learn from one another. 

Before joining the boot camp, I did some due diligence on the boot camp by reading blogs from people who have participated in previously, and I sensed that the teaching quality might not be as good as I hoped it would be. (I was quite right. Rather than explaining why and how things work the way they work, their teaching style is more like "Don't try to understand. Just do it.") 

But despite the shortcoming, I am quite pleased with how much I have learned and progressed over the past two weeks. Because of the assignments' deadlines and of the other people who are working hard in the same space (well, a virtual space. We are learning in a metaverse called a "gather town." We each have our own avatar and communicate via web cams), I push myself more than when I was learning alone. For any shortfall of the learning materials, I google it, and apparently, one of the virtues of being a good developer is being good at googling. 

They say "If you want to go fast, go alone. If you want to go farther, go together." (Not sure about the origin. Some say it's an African proverb.) 

So, I think I made the right decision.
React
Tags: react, reactnative, javascript
Published: 2024-02-03 04:27:49

**¿Que es React?**
Es una biblioteca de Javascript para construir interfaces de usuario en web o movil.
- React es declarativo y esta basado en componentes.
- Es universal, ya que se ejecuta tanto como de lado del servidor y cliente, permitiendonos reutilizar el mismo codigo.
- En 2013 se volvio de codigo abierto.
- Pertenece a Meta(Facebook, Whatsapp)
- Creado en 2012 por Jordan Wolk, ya que era muy dificil trabajar con formularios.
- Evita ataques por XSS(intento de ainyeccion de codigo).

**¿Por que aprender React?**
1. Es el framework mas demandado del mundo.
2. Te permite desarrollar aplicacion de escritorio, web y moviles.
3. Mantenimiento activo.
4. El aprendisaje es mas facil si sabes otro framework.
5. Los cambios en React son mas facil de inplementar.
6. Una gran comunidad.

**Preguntas tipicas de React**
https://www.reactjs.wiki/

**Documentacion**
https://es.react.dev/learn
My Space Projects
Tags: webdev, javascript, programming, react
Published: 2024-02-08 14:35:55

https://car-showcase-r.vercel.app/
https://my-dictionary-beta.vercel.app/
https://cyrpto-verse.vercel.app/
https://imdb-movie-delta.vercel.app/
https://gpt-ui-eta.vercel.app/
https://tech-arion.vercel.app/
https://nike-clone-kappa-silk.vercel.app/
https://techarionspacecenter.netlify.app/
Harnessing the Power of CSS Variables: A Comprehensive Guide
Tags: css, cssvariables, webdev, modularstyles
Published: 2024-02-08 15:50:34

Introduction:
CSS variables, denoted by property names prefixed with -- (double dash), offer a flexible and efficient way to manage and reuse values across stylesheets. Also known as custom properties, CSS variables allow developers to define and apply dynamic values that can adapt to various contexts. In this guide, we'll explore the syntax, usage, and benefits of CSS variables, demonstrating their versatility in creating modular and maintainable styles.

### Understanding CSS Variables:

CSS variables, represented by custom property names prefixed with --, provide a mechanism for storing and reusing values throughout a stylesheet. These variables can be dynamically updated and applied using the `var()` function.

### Syntax:

```css
--variable-name: value;
```

### Example:

```css
:root {
  --primary-color: #16f;
  --secondary-color: #ff7;
}

.element {
  background-color: var(--primary-color);
  color: var(--secondary-color);
}
```

### Benefits of CSS Variables:

#### 1. Reusability and Consistency:
   - CSS variables enable the definition of reusable values, promoting consistency across stylesheets.
   - Centralizing commonly used values as variables simplifies maintenance and ensures uniformity in design.

#### 2. Dynamic Updates:
   - CSS variables can be dynamically updated using JavaScript, allowing for real-time adjustments based on user interactions or system states.
   - This dynamic behavior enhances flexibility and responsiveness in web design.

#### 3. Scoped and Cascading:
   - CSS variables are scoped to the elements they are declared on and participate in the cascade.
   - This scoped nature enables granular control over variable values, facilitating targeted styling adjustments.

### Usage Example:

```html
<div class="container">
  <div class="box"></div>
</div>
```

```css
:root {
  --box-color: #16f;
}

.box {
  width: 100px;
  height: 100px;
  background-color: var(--box-color);
}

.container:hover {
  --box-color: #ff7; /* Dynamically update box color on hover */
}
```

### Conclusion:

CSS variables, or custom properties, offer a powerful and flexible approach to managing stylesheets in web development. By leveraging CSS variables, developers can enhance maintainability, promote consistency, and enable dynamic styling adjustments, contributing to a more efficient and adaptable design workflow.
Cogno-Cravings desvela una solución innovadora
Published: 2024-02-08 21:15:47

Las fiestas navideñas, aunque alegres, suelen desencadenar problemas de salud relacionados con el estrés. Una importante estadística de la [Alianza Nacional de Enfermedades Mentales](https://despertarperu.com) destaca que el 64% de las personas sufren depresión navideña, agravada por el estrés económico, emocional y físico. [CognoCravings](https://diariodelpacifico.com) aborda estos retos ofreciendo un método innovador para contrarrestar los efectos del estrés navideño sobre la salud.
Worbler AI on the iOS App Store! 🚀
Tags: webdev, ai, ios, discuss
Published: 2024-02-11 19:15:59

## Hey Everyone! 
It's Noel here, President and Co-creator of [Worbler AI!](https://apps.apple.com/us/app/worbler-ai/id1601684407)
We’re in our early days so I’m getting in touch with new users to learn more about what piqued your interest and how you might use the new [Worbler AI iOS app! ](https://apps.apple.com/us/app/worbler-ai/id1601684407)That being said, **content creators, video editors & AI enthusiasts,** give Worbler AI a try and let us know if you love it as much as we do!
The exhaustive Manual for Settling my SBC global email is not working Difficulties: Investigating and Viable Arrangements
Tags: sbcglobalmails, mysbcglobalemail
Published: 2024-02-09 06:32:07

Find a definitive manual for beating difficulties with your **[SBC Global Email](https://sbcglobalmails.com/)**. This complete manual proposals inside and out investigating methods and gives viable answers to guarantee a consistent email insight. Jump into an abundance of knowledge intended to easily determine troubles, engaging you to explore and determine issues. Whether confronting specialized errors or looking for suitable game plans, this comprehensive manual is your go-to asset for dominating my SBC global email is not working investigating. Lift your email insight with reasonable tips and arrangements custom-made to upgrade proficiency and dependability.
Superdense Coding-Math & Implementation
Published: 2024-02-09 07:01:41



For classical communication there is a limit on how much information can be send with a given number of bits. We can send no more than n bits of information using n bits. However, there are ways that we can push the boundary which are not possible classically. Hence, we can use superdense coding using quantum computer.

**Definition:** 

> It is a procedure that allows someone to send two classical bits to another party using just a single qubit of information.

Here we will use 4 types of gates while implementing this procedure.


1. **H gate** -> This puts a qubit into superposition.
2. **X gate** -> X|0> -> |1> & X|1> -> |0>
3. **CX gate** -> It takes two qubits one is control and another is target. If the control bit is 0 , it does nothing to the target qubit, otherwise if the control bit is 1, X gate is applied on target qubit. 
4. **Z gate** -> It only change the phase of a qubit when it is in |1> state i.e, Z|0> -> |0> , Z|1> -> -|1>

The procedure is implemented as follows,



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/056r9uelk2m96wyygrjg.jpg)

For keeping track , we have put 4 track point here , namely W1,W2,W3,W4.

Now let's see how this procedure works mathematically,




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

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


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


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


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

Now let's see its coding part, here we will use Qiskit for the implementation,

```
from qiskit import QuantumCircuit,Aer,execute

qc_3rd_party = QuantumCircuit(2,2)

qc_3rd_party.h(1)

qc_3rd_party.cx(1,0)


message_list = ['00', '01', '10', '11']

qc_Alice = QuantumCircuit(2,2)

for msg in message_list:
    
    if msg[-2]=='1':
        
        qc_Alice.z(1)
        
    if msg[-1]=='1':
        
        qc_Alice.x(1)
    
    qc_Bob = QuantumCircuit(2,2)
    
    qc_Bob.cx(1,0)
    
    qc_Bob.h(1)
    
    qc_Bob.measure([0,1],[0,1])
    
    complete_qc = qc_3rd_party.compose(qc_Alice.compose(qc_Bob))
    
    backend = Aer.get_backend('qasm_simulator')
    
    print(f'For message = {msg}\n')
    
    count = backend.run(complete_qc).result().get_counts()
    
    print(count,"\n")
    
    qc_3rd_party.data=[]
    
    qc_Alice.data=[]
    
    qc_Bob.data=[]
        

```

The output of the code is ,


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6epzwueihfznfowlo0di.png)
How to Backup and Restore a PostgreSQL Database
Tags: postgres, database
Published: 2024-02-09 07:18:24

When dealing with substantial amounts of data, protecting against potential data loss stemming from hardware failures, software glitches, or human errors becomes crucial. This ensures the preservation and accessibility of critical information, a concern not limited to regular databases but extending to cloud services such as Heroku, Amazon S3, and Azure. Therefore, being able to create a backup and effectively restore it when necessary is essential.

This article contains a comprehensive guide on backing up and restoring PostgreSQL data and schema using a command line and a user-friendly GUI tool — dbForge Studio for PostgreSQL. Here, you will discover carefully selected theoretical material designed to broaden your knowledge on the subject, complemented by practical examples to provide you with a hands-on learning experience.

Let’s get it started!
https://blog.devart.com/postgresql-backup.html
More than 500!!!
Published: 2024-02-09 09:47:15

🎉 Thank You for 500+ Followers on LinkedIn! 🙌
🚀 Huge thanks to each of you for your support and engagement. Let's keep enjoying, connecting, learning, and growing together! 🌟 #Milestone #Gratitude #LinkedInCommunity #growth #support #thanks #500
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1ouspdzv44e1z0yenna.jpg)
Can Mydukaan.com Bare Metal Transition Truly Save Costs?
Tags: baremetal, costsaving, aws, transition
Published: 2024-02-09 10:15:23

Mydukaan.com's transition to Bare Metal servers aims to reduce costs, but its effectiveness remains uncertain. Initially burdened by high expenses on AWS, Mydukaan.com sought a more economical solution without sacrificing performance.

The move to Bare Metal holds promise for significant cost savings, potentially boosting the platform's financial efficiency. However, the transition poses challenges such as increased complexity and upfront investment requirements.

Mydukaan.com must carefully handle these obstacles to ensure the transition delivers the expected cost benefits. Despite uncertainties, the shift to Bare Metal aligns with Mydukaan.com's goal of providing an affordable solution for small businesses.

By optimising infrastructure for cost-efficiency, Mydukaan.com aims to enhance its operational sustainability and competitive edge.

As the transition progresses, the true impact on costs will become clearer, determining the success of Mydukaan.com's Bare Metal strategy.

**Read more: [Mydukaan.com’s 70% Cloud Cost Reduction with Bare Metal**](https://www.linearloop.io/blog/cost-efficient-server)
Node.js Modules and npm
Published: 2024-02-09 15:10:05

# Node.js Modules and npm

Node.js is a powerful, open-source JavaScript runtime environment that allows developers to write server-side applications using JavaScript. One of the key features of Node.js is its modular approach, which helps in organizing code into reusable components known as modules.

In this guide, we will explore the concepts of Node.js modules and npm (Node Package Manager) and learn how to use them effectively in your projects.

## What are Node.js Modules?

Modules in Node.js are self-contained pieces of code that can be imported or exported for reusability. These modules help break down larger applications into smaller, manageable chunks, making development faster and more maintainable.

To create a module in Node.js, you simply need to define a file with ".js" extension containing your desired functionality. For example, let's say you want to create a module called "utils" with various utility functions:

```javascript
// utils.js

function add(a, b) {
  return a + b;
}

function subtract(a, b) {
  return a - b;
}

module.exports = {
  add,
  subtract
};
```

In the above example, we have defined two functions (`add` and `subtract`) inside `utils.js`, and then exported them using the `module.exports` statement for other parts of our application to consume.

## Using Modules in Your Application

Once you have created your module(s), you can easily import them into your main application file using the `require()` function. Let's assume our main application file is called "app.js":

```javascript
// app.js

const utils = require('./utils');

console.log(utils.add(5, 3)); // Output: 8
console.log(utils.subtract(10
Hotels in New Cairo City
Tags: hotel, cairo
Published: 2024-02-10 02:09:27

New Cairo City offers travelers a diverse and enticing array of hotels, providing options to suit every taste and budget. From luxurious boutique accommodations to modern and budget-friendly choices, the city boasts a vibrant hospitality scene catering to tourists and visitors from around the world. Explore the city's hidden gems, discover top-rated hotels, and relax in your ideal lodging at one of New Cairo's accommodation options.

[https://thevilla604.com/rooms/](https://thevilla604.com/rooms/)