teleren/devto huggingface dataset:
How to Create a Trigger at Posedge and Negedge of a Sine Wave in Verilog
Tags: verilog, trigger, posedge, negedge
Published: 2023-08-13 19:06:11

Verilog is a hardware description language widely used in the field of digital design. It allows software developers to describe and simulate electronic systems. One common task in Verilog is creating triggers at posedge and negedge of a signal. In this article, we will explore how to create triggers at posedge and negedge of a sine wave in Verilog.

Before we dive into the details, let's have a quick refresher on what posedge and negedge mean. In Verilog, posedge refers to the positive edge of a clock signal, while negedge refers to the negative edge of a clock signal. These edges are important for synchronizing and triggering events in digital systems.

Now, let's get down to business and create a trigger at posedge and negedge of a sine wave in Verilog. We will start by generating a sine wave using a lookup table. Here's a simple example:

`module sine\_wave ( input wire clk, output wire sin\_out ); reg \[7:0\] sine\_table \[0:255\]; initial begin // Initialize the sine table for (int i = 0; i < 256; i = i + 1) begin sine\_table\[i\] = $sin(2 * $pi * i / 256); end end always @(posedge clk) begin // Your trigger logic here // This block will be executed at every posedge of the clock signal sin\_out <= sine\_table\[i\]; end endmodule`

In this example, we have a module called sine\_wave with an input wire clk representing the clock signal and an output wire sin\_out representing the sine wave. Inside the module, we have a reg \[7:0\] sine\_table, which is a lookup table containing the values of the sine wave. We initialize the sine\_table in the initial block using a loop.

The interesting part is the always @(posedge clk) block. This block is triggered at every posedge of the clock signal. Inside this block, you can add your trigger logic. In this example, we simply assign the value of the sine wave at index i to the sin_out signal.

That's it! You have successfully created a trigger at posedge of a sine wave in Verilog. If you want to create a trigger at negedge, you can use the always @(negedge clk) block instead.

Now, let's wrap up this article with a quick summary. We have learned how to create triggers at posedge and negedge of a sine wave in Verilog. By using the always @(posedge clk) and always @(negedge clk) blocks, we can synchronize and trigger events in our digital systems. So go ahead and have fun creating triggers in Verilog!

### References:

*   Verilog HDL: A Guide to Digital Design and Synthesis by Samir Palnitkar
*   Verilog by Example: A Concise Introduction for FPGA Design by Blaine Readler
blockchain data is hard to find, but we're making it easily accessible @chainparser.
Tags: blockchain, data
Published: 2023-08-13 18:54:09

blockchains are designed to be write-optimized, in a way that anybody with access to an RPC node can create and broadcast transactions. reading data from domain-specific chains like bitcoin can be fairly simple because you're expecting to work with only one type of transaction. 

however, it gets trickier when you're reading data from general purpose blockchains like ethereum and solana. we've seen indexers like [the graph](thegraph.com) and [flipside](https://flipsidecrypto.xyz/) provide platforms where one can easily query on-chain data using basic SQL or GraphQL.

for people who cannot write SQL or GraphQL to read on-chain data, there are two options. the first option is to rely on data analysts who post insights on twitter and other social platforms daily. this is great, as the data is transformed and served to the crypto community right at their doorstep. however, there's one problem with this way of information dissemination; it is not tailored to each user's need. 

the second approach is to visit an information hub like [etherscan](https://etherscan.io/) or [defillama](https://defillama.com/). these are great sources to understand what is actually happening on-chain but it still takes some amount of skill to be able to find the right data.

therefore, as i have realized over 2 years of data analysis within the crypto space, there is no centralized data hub for blockchain data that is easily accessible. in short, on-chain data is hard to find, and the space is desperately in need of a user-friendly one-stop shop for tailored on-chain data. 

[chainparser](https://chainparser.com/) is a tool that makes blockchain data simple and easily accessible. our goal is to build a one-stop shop, so that anyone can find the information they need, regardless of their technical knowledge.

to be sure that we're building the right product, we've targeted people with little to no idea of blockchains or where to find on-chain data. we believe that these are the people who are most in need of a tool like chainparser.

i sternly believe that [chainparser](https://chainparser.com/) has the potential to make a significant impact on the blockchain community. by making on-chain data simple and easily accessible, we can help to bring more people into the fold and accelerate the adoption of blockchain technology.
VVCARES SINGAPORE
Published: 2023-08-13 18:30:28

Website URL    :    [https://vvcares.com](https://vvcares.com)

Business Name : VVCARES SINGAPORE

Business Description :

Roofing, Waterproofing Contractor in singapore.

- Best flat roof waterproofing

- Roof leak repairing

- Roof waterproofing singapore

- Waterproofing specialist singapore

- Roof waterproofing cost

- Roof top water leakage

- Roof leaking from inside / outside

- Wire mesh installation

- Roof Gutter installation / Gutter replacement
Create Your First Laravel User
Tags: laravel, webdev, beginners, php
Published: 2023-08-13 18:29:03

---
canonical_url: https://seankegel.com/create-your-first-laravel-user
---

This is a quick tip to get that first user created in your application so you can login and start testing things out.

You just installed a new Laravel application, you configured the database, and ran migrations.

```shell
php artisan migrate
```

Now you go to your site and realize you don’t have a user to login with yet. So your first thought is to just create a user manually in the database itself. However, the `password` column is used to store a hashed password. It should never store a plaintext password. If you attempt to put a plaintext password in the database, you still aren’t able to login because Laravel is trying to compare the password you entered on the login screen to a hashed value.

So, how can we fix this?

The easiest way I’ve found is to use [Tinker](https://laravel.com/docs/10.x/artisan#tinker). Tinker is an extremely helpful REPL for Laravel that comes out of the box. To run it, just use Artisan:

```shell
php artisan tinker
```

Once in Tinker, we can use the User model just like in our application to create a user.

```php
User::create([
 'name' => 'Sean',
 'email' => 'sean@example.com',
 'password' => Hash::make('password')
]);
```

Below is the sample output of doing just this:

```shell
Psy Shell v0.11.20 (PHP 8.2.8 — cli) by Justin Hileman
> $user = User::create(['name' => 'Sean', 'email' => 'sean@example.com', 'password' => Hash::make('password')]);
[!] Aliasing 'User' to 'App\Models\User' for this Tinker session.
= App\Models\User {#6288
    name: "Sean",
    email: "sean@example.com",
    #password: "$2y$10$PjLdDohJMjtm2M08RBcgWOhvxZnAN1L1eMyCE2/G4ye7V9Ua9qeWS",
    updated_at: "2023-08-13 18:06:19",
    created_at: "2023-08-13 18:06:19",
    id: 1,
  }
>
```

The most important part of this is the password. We do not want to store it as plaintext and if we do, it won't actually work. So we need to hash the password using Laravel’s Hash facade:

```php
Hash::make('password');
```

When using a starter set like [Laravel Breeze](https://laravel.com/docs/10.x/starter-kits#laravel-breeze), login is handled for you automatically. However, if you ever need to check a password against the hash, you can use the following:

```php
Hash::check('password', $hashedPassword); // returns true or false
```

To read more about hashing passwords in Laravel, take a look at the [documentation](https://laravel.com/docs/10.x/hashing#hashing-passwords).

You can even customize the types of hashes that facade will create by adjusting the number of rounds the algorithm uses or switch the algorithm altogether from `bcrypt` to `Argon2`.
Why am I working on The Drive AI
Tags: productivity, ai, webdev
Published: 2023-08-13 18:23:21

Before answering the question, let's start with the problem.

1. Our files are scattered everywhere.
I send files via Gmail to friends, upload them to Slack and Discord for work, and store personal documents in Google Drive and on my local machine. I even have tons of notes in OneNote. Finding a specific file, like my 2 a.m. thoughts, becomes a challenge. Was it in OneNote or Google Docs? And if it's in Google Docs, which of the hundreds of folders? Maybe I sent it to a friend via email or even Discord?
This problem is magnified in teams where files are constantly sent across members, making search and management a daunting task. In a large company, it's common to send the same file multiple times to the same employee simply because they couldn't find it.

2. Inefficient use of stored information.
In one way or another, we all have a vast internal knowledge base. Most internet users store files in storage systems like Google Drive, Obsidian, or Notion. But we often don't make good use of these stored knowledge bases. Consider this scenario: I'm struggling to solve a complex Calculus question. I have my Calculus book, which contains information on how to solve such problems. Even if it doesn't have the answer to the specific question I'm working on, it has the steps, rules, and information needed to solve it. Why can't I simply ask my book for the steps that would lead me to the solution? Additionally, if I want to write an article about the Amazon forest and have related materials in my Google Drive, why can't I use them to help write the article?

These are the two main problems we are trying to solve at The Drive AI. First, we aim to be a Dropbox for your knowledge base. Users can simply upload or sync documents to create a structured repository of information. Currently, you must manually manage these documents into files and folders, but our goal is to automatically organize them by content. For example, all content related to music theory would be found in one specific folder.

We treat each folder as a knowledge base, a single source of truth to draw information from. So, if you forgot what notes are in Misolydian mode, you can simply ask the music theory knowledge base. Sure you can search the internet for notes in Misolydian mode, but the core idea holds for internal teams and personal documents. Imagine an emergency at a company, and you need to find information on what protocols to follow in the face of an emergency.

With access to this knowledge base, we can tackle the second problem. We can use those files while reading to understand concepts better, search over them to quickly find information, and write new content with sources drawn from them.

This is what we are working on at https://thedrive.ai

Full article here: https://thedrive.ai/publish/ebfb16a7d2cfde880df194bfd72178c2:9f7272e3919e859c34e796679a9206b896594e0834888db4a18ee7b50cda83407c011872e6dff7dae582bdc83996e386
Azure DevOps CODEOWNERS
Tags: azure, devops, productivity, ado
Published: 2023-08-13 18:19:44

So the other day I came across GitHub's [CODEOWNERS feature](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) and I really liked it. I searched for the same in Azure DevOps but couldn't find something remotely close to it. Then my entrepreneur spirit waked up and I decided to make it myself :)

But first, what is "CODEOWNERS"?

## CodeOwners Feature
Some facts:
1. When working on a multiservice monorepo, it's very common to have different programmers working on the same repo on different features.
1. The programmer who wrote the feature is probably the one that knows best about it.   
1. Some other programmer will probably "touch" that code sometime in the future (bugfix for example).
1. You want the Pull Request to be as professional and as short as possible.

Thus, CodeOwners came to live.

CODEOWNERS is a simple idea, each feature/service in the monorepo has an owner. A developer who "owns" that feature, knows it the best and can be held responsible, in a positive way, of that feature.
The CODEOWNERS feature in GitHub is just an easy way of enforcing that the owner will become a reviewer, automatically.

## In GitHub
To make use of this feature you just need to create a file named "CODEOWNERS" in the root of the repository and add, as they show in the [example](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax), the owners of the services.
From now on every pull request that is opened will be automatically assigned to the owners.
As the CODEOWNERS file is also gitted, changes to it will also be PR'd.

## In Azure DevOps
There's branch protection in Azure DevOps but it's not as powerful as CodeOwners.
I've created a simple Docker Container that adds this feature to your Azure DevOps project and works the same way.
It can also notify the owner via RocketChat :)

You can see the code [here](https://github.com/javitolin/CodeOwners) and download the image from the [Docker Hub](https://hub.docker.com/r/javitolin/codeowners)

Hope you like it! 
I'm open for more ideas to add and make Azure DevOps better!
Java Jackson JSON: How to Handle Custom Keys?
Tags: java, json, jackson, pojo
Published: 2023-08-13 18:04:54

Java Jackson JSON: How to Handle Custom Keys?
---------------------------------------------

JSON (JavaScript Object Notation) has become the de facto standard for data interchange in web applications. It provides a lightweight and human-readable format to represent data structures. When working with JSON in Java, the Jackson library is a popular choice due to its powerful features and ease of use.

In most cases, JSON keys follow a specific naming convention, such as camelCase or snake_case. However, there may be situations where you need to handle custom keys that do not conform to these conventions. This article will guide you through the process of handling custom keys using Jackson JSON in Java.

### 1\. Using @JsonProperty Annotation

The `@JsonProperty` annotation allows you to map a JSON property to a Java field or method. By default, it uses the field or method name as the JSON key. To handle custom keys, you can specify the desired key as the value of the `@JsonProperty` annotation.

 

    
    public class CustomKeyExample {
        @JsonProperty("myCustomKey")
        private String myField;
        
        // Getter and setter methods
    }
    

 

In the above example, the JSON key "myCustomKey" will be mapped to the `myField` field in the Java object.

### 2\. Using a Custom Key Deserializer

If you have more complex requirements for handling custom keys, you can create a custom key deserializer. A key deserializer allows you to customize the mapping of JSON keys to Java fields or methods.

 

    
    public class CustomKeyDeserializer extends KeyDeserializer {
        @Override
        public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException {
            // Custom logic to handle the key mapping
            return key;
        }
    }
    

 

To use the custom key deserializer, you need to register it with the Jackson `ObjectMapper` instance.

 

    
    ObjectMapper objectMapper = new ObjectMapper();
    SimpleModule module = new SimpleModule();
    module.addKeyDeserializer(Object.class, new CustomKeyDeserializer());
    objectMapper.registerModule(module);
    

 

With the custom key deserializer in place, you can handle custom keys in a flexible and customizable way.

### Conclusion

Handling custom keys in JSON using Java Jackson is straightforward. You can use the `@JsonProperty` annotation to map JSON properties to Java fields or methods. For more complex scenarios, you can create a custom key deserializer to have full control over the key mapping process. With these techniques, you can easily work with JSON data that may not conform to the usual naming conventions.

### References:

*   [Jackson GitHub Repository](https://github.com/FasterXML/jackson)
*   [Baeldung - Jackson Tutorial](https://www.baeldung.com/jackson)
*   [Oracle - Jackson Documentation](https://www.oracle.com/java/technologies/javase-jackson.html)
Free Monads for smart optimized code
Tags: functional, webdev, database
Published: 2023-08-13 17:42:13

One of the most annoying and complex problem to solve is database querying. When your request is not a simple read or write, it becomes quite complicated to be fully optimal.

Most of the time, it's due to technical constraints (e.g. a library used makes multiple independent requests instead of batching them somehow).

What if we could eliminate the problem altogether?

My proposed solution? Turn your whole application logic into Free Monad program.

Introducing Free Monads: cool monads that help building eDSL.

The whole idea is that you make sort of "programs" that are really blueprints for an execution. What makes it extremely interesting is that you can evaluate the same program differently, it's the evaluator that dictates how things work, not the program. The program only has the "shape" of the instructions.

How is that different from interfaces in OOP you might ask? It's simple, with interfaces you're still operating at a value level. With Free Monad, you're operating at an operation level.

In a way, you can think of Free Monad programs as a sort of weird AST, and evaluators as visitors.

Here's the proposed pseudo code:

```php
function runApp($request) {
  $program = new AppProgram($request);
  try {
    $dbEvaluator = new DbAppEvaluator();
    $queryData = $dbEvaluator->evaluate($program);
    $responseEvaluator = new ResponseEvaluator($queryData);
    return $responseEvaluator->evaluate($program);
  } catch($e) {
    $errorHandlerEvaluator = new ErrorHandlerEvaluator($e);
    return $errorHandlerEvaluator->evaluate($program);
  }
}
```

How cool would that be?

Things like `Database::connect()` wouldn't actually give you a connection object back, but a handle to an operation that has been added to the sequence of the program.

Thing like `Query::table("x")->select("*")->where($cond)` wouldn't immediately query to the database, but be an handler. Then the database evaluator would get all the queries, optimize them, and do as little work as possible.

A whole framework designed like that would eliminate a lot of poor design choices or bad coding practices that lead to poor performances.
My First Python Project
Tags: codenewbie, codecademy, python, chess
Published: 2023-08-13 17:40:48


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

As my final project in the Codecademy CS101 course, I've written a terminal chess game in python called [simple_chess](https://github.com/LRVSweet/simple_chess).  It presents the user with a simple chessboard visualization in the terminal.  Play proceeds as players enter their moves into the terminal and the program updates the visualization with the new moves and removes captured pieces.  When a player decides to end the game, they type "end game" into the terminal on their turn and receive a pgn printout of their chess game.

The program is still rudimentary and does not check moves for legality, detect checks and checkmates, or support special moves such as en passant, castling, or pawn promotion.  Adding these features will certainly be on my to-do list if I return to this project in the future.

A key principle that I learned as I worked on this project is the power of object oriented programming.  Initially I defined classes for each type of chess piece but the chessboard itself was managed with a series of dictionaries and lists.  As I started to work on a chessboard visualization system, it occurred to me that I could also define a square class for squares on the chess board.  This greatly simplified the visualization system.  I haven't gone back through the code that I had written previously to update all features that involve locations on the chessboard to use the square objects, but that will also be on my to-do list should I return to the project in the future.

Creating simple_chess was an enjoyable challenge and a great learning experience for me.  I'm excited to see what's next!
DAY 71 - Minimum Bit Flips to Convert Number
Tags: leetcode, coding, algorithms, beginners
Published: 2023-08-13 17:20:15

Hey Guys! Today we are on the 71st day and we are going to  solve another bit manipulation problem.

---


## Question: [Minimum Bit Flips to Convert Number](https://leetcode.com/problems/minimum-bit-flips-to-convert-number/)

## Problem Description

_Given two integers `start` and `goal`, both representing binary numbers, the task is to determine the minimum number of bit flips required to convert `start` to `goal`._

---

### _Example 1:_

> **Input:** start = 10, goal = 7
> **Output:** 3
> **Explanation:** The binary representation of 10 and 7 are 1010 and 0111 respectively. We can convert 10 to 7 in 3 steps:
> - Flip the first bit from the right: 1010 -> 1011.
> - Flip the third bit from the right: 1011 -> 1111.
> - Flip the fourth bit from the right: 1111 -> 0111.
> It can be shown we cannot convert 10 to 7 in less than 3 steps. Hence, we return 3.


---

## Intuition: Bit Manipulation

- The problem can be solved using bit manipulation techniques.
- Perform a bitwise XOR operation between the start and goal integers.
- The XOR result will have 1s at the positions where the bits need to be flipped.
- To count the differing bits, repeatedly clear the rightmost 1 bit in the XOR result.
- Use the operation temp &= (temp - 1) to clear the rightmost 1 bit in the binary representation of temp.
- Each iteration of the clearing operation represents one differing bit that needs to be flipped.
- The total number of iterations directly gives the minimum number of bit flips required to convert start to goal.

---

## Example Run

Let's take an example to understand the approach better:

- Suppose `start` is `1101` and `goal` is `1010`.
- The XOR of `start` and `goal` is `0111`, which has three set bits.
- We need to flip the bits at positions 1, 2, and 3 to transform `start` into `goal`.

---

## Code:

```cpp

class Solution {
public:
    int minBitFlips(int start, int goal) {
        int temp = start ^ goal; // XOR to identify differing bits
        int cnt = 0;

        while (temp > 0) {
            temp &= (temp - 1); // Clear the rightmost 1 bit
            cnt++;
        }

        return cnt;
    }
};

```


## Complexity Analysis

| Complexity  | Analysis |
|-------------|-------------|
| Time        | O(log N)    | 
| Space       | O(1)        |