teleren/devto huggingface dataset:
Twitter snowflake approach is cool
Tags: webdev, twitter, design
Published: 2022-12-25 12:55:32

Twitter snowflake approach is cool
==================================

I was researching a solution to generate unique IDs and I liked the Twitter snowflake approach. These are my notes about this approach.

What is Twitter’s snowflake approach?
-------------------------------------

It is a solution to generate unique IDs in distributed systems. Twitter uses this approach in Tweets, DM’s, Lists and etc.

*   IDs are unique and sortable
*   IDs include time. (ordered by date)
*   IDs fit 64-bit unsigned integers.
*   Only numerical values.

**Sign bit (1 bit):** Reserved bit (It is always 0). This can be reserver for future requests. It can be potentially used to make the overall number positive.

**Timestamp(41 bit):** Epoch timestamp in a millisecond (Snowflake’s default epoch is equal to Nov 04, 2010, 01:42:54 UTC)

**Machine ID(10-bit):** accommodates 1024 machines

**Sequence number(12-bit):** It is a local counter per each machine and increments by 1. The number reset to 0 in every millisecond. Theoretically, a machine can support a max of 4096 (2¹²) new IDs per second.

Advantages & Disadvantages of the Twitter Snowflake Approach
------------------------------------------------------------

*   It is 64-bit long, it is half the size of UUIDs
*   Scalable (it can accommodate 1024 machines)
*   Highly available (Each machine can generate 4096 unique IDs each millisecond)
*   Some of the UUID versions do not include a timestamp. In this case, Twitter Snowflake has a sortable advantage.
*   Design requires Zookeeper (disadvantage)
*   The generated IDs are not random like UUIDs. Future IDs can predictable.
*   The maximum timestamp that can be represented in 41 bits is (~ 69 years). Need a solution after this :)

Usage Notes
-----------

*   Discord uses snowflakes, with their epoch set to the first second of the year 2015.
*   Instagram uses a modified version of the format, with 41 bits for a timestamp, 13 bits for a shard ID, and 10 bits for a sequence number.
*   Mastodon’s modified format has 48 bits for a millisecond-level timestamp, it uses the UNIX epoch. The remaining 16 bits are for sequence data.

References
----------

*   [https://en.wikipedia.org/wiki/Snowflake\_ID#cite\_note-8](https://en.wikipedia.org/wiki/Snowflake_ID#cite_note-8)
*   [https://medium.com/double-pointer/system-design-interview-scalable-unique-id-generator-twitter-snowflake-or-a-similar-service-18af22d74343](/double-pointer/system-design-interview-scalable-unique-id-generator-twitter-snowflake-or-a-similar-service-18af22d74343)
*   [https://blog.devgenius.io/7-famous-approaches-to-generate-distributed-id-with-comparison-table-af89afe4601f](https://blog.devgenius.io/7-famous-approaches-to-generate-distributed-id-with-comparison-table-af89afe4601f)
Development Skills for 2023
Tags: cpp, beginners, opensource, discuss
Published: 2022-12-25 11:17:07

- Python Proficiency
- C++ Proficiency
- Android Proficiency
- Machine Learning
- HCI / UX Research
- Game Development
- Databases
- Systems Programming
- FPGAs
- Front-end Development
- Back-end Development
- Tensorflow/PyTorch
Fields to Explore in 2023
Tags: webdev, javascript, beginners, programming
Published: 2022-12-25 11:15:46

- Algorithms and Complexity
- Security and Cryptography
- Natural Language Processing
- Programming Languages and Compilers
- Computer Systems & Networking
- Applied Machine Learning
- AI for Programming
- Human Computer Interaction / Technology for Development
- Software Development and Engineering
- Reinforcement Learning
- Computer Vision
2389. Leetcode Solution in cpp
Tags: cpp
Published: 2022-12-25 10:59:05

```cpp
class Solution {
public:
    vector<int> answerQueries(vector<int>& nums, vector<int>& queries) {
              sort(nums.begin(), nums.end());
              vector<int> ans;
        
              for(int i = 0; i < queries.size(); i++) {
                  int q = queries[i];
                  int sum = 0;
                  int count = 0;
                  
                  for(int j = 0; j < nums.size(); j++) {
                        sum = sum + nums[j];
                        if(sum > q) break;
                        count++;
                  }
                  
                  ans.push_back(count);
              }
        return ans;
    }
};
```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/longest-subsequence-with-limited-sum/
Hello everyone! Need help
Published: 2022-12-25 10:37:36

I'm at the end of my training in full-stack web and mobile development (Springboot, angular, ionic and flutter) and my final project is to make a generic survey tool so I need help to guide me in this project which is dear to my heart but also very complex!
Your suggestions and opinions are welcome!


Hello, I have made some progress in my project such as the specifications that tells us the tools that will be used as Angular for the dashboard and ionic for users and the timeline that gives us a deadline of January 20, 2023.

This is the projet manager i use : 
https://trello.com/invite/b/o4RaJ2bt/ATTI1c021c34a3caf3da4315a900007b9201C5AF0632/mon-projet
I also did a little in the use case, class and sequence diagram.
System Design for Software Development
Tags: webdev, programming, python
Published: 2022-12-25 10:18:41

System design is the process of planning and organizing the components of a software system in a way that meets the requirements of the users and the business. It is a critical step in the software development process, as it determines the overall structure and functionality of the system.

There are several key considerations to keep in mind when designing a software system, including:

Functionality: What does the system need to do? What are the specific features and capabilities that it needs to have in order to meet the needs of the users and the business?

Scalability: How will the system need to grow and change over time? Will it need to handle increased workloads or new features?

Reliability: How important is it that the system be reliable and available? What are the consequences of the system going down or experiencing errors?

Security: How important is it that the system be secure? What are the risks of the system being compromised, and how can those risks be mitigated?

Performance: How important is it that the system be fast and responsive? What are the performance requirements for the system, and how can those requirements be met?

To design a software system, you will need to consider these and other factors, and then determine the best way to organize and structure the system to meet those needs. There are many different approaches to software system design, including monolithic architecture, microservices architecture, and event-driven architecture, among others.

Once you have decided on the overall structure of the system, you will need to design the individual components and how they will work together. This may involve creating detailed specifications and diagrams, such as class diagrams and sequence diagrams, to help you visualize the relationships between the different components.

Finally, you will need to test the system to ensure that it meets the requirements and performs as expected. This may involve creating test cases, running simulations, and performing other types of testing to ensure that the system is stable and reliable.

In conclusion, system design is a critical step in the software development process, and it requires careful planning and organization to ensure that the system meets the needs of the users and the business. By considering the functionality, scalability, reliability, security, and performance of the system, you can design a software system that is effective and efficient.
Markdown-ImageLocalize
Tags: markdown, tool, python
Published: 2022-12-25 09:48:31

Project url:[Img_link_to_local_markdown](https://github.com/YellowAndGreen/Md-ImgLocalize)

This is a python script that scans all the markdown files of a folder looking for images links, 
and substitutes the urls of the markdown files for local file names, 
and download the images.

# Why?🛠️
Offline markdown files are a reliable way to store and organize information.
When copying from the web the text is copied directly, but images are copied as links.
If the link expires in the future, or you are offline, you lose the information.
It would be great to have every picture added as a link downloaded to local storage.

# Features⭐
+ Support both `<img>` and `![]()` labels.
+ Add more options to custom the behaviors(e.g. whether to modify source markdown files).
+ Download images in Async mode, which performs well to decrease exec time:

    |  vanilla code   | async code  |
    |  ----  | ----  |
    | 28.420s  | 5.236s |
+ Support loop traversal of markdown files.


# Usage🚀
1. Install Python on your computer.
2. Clone this Repo `git clone https://github.com/YellowAndGreen/Md-ImgLocalize.git`.
3. Install aiohttp `pip install aiohttp` .
4. Change to the Repo's directory and run `python main.py --md_path=[md_path]`:
    + specify `md_path` as your markdown files directory
    + use `--log` to save log file
    + use `--modify_source` to modify source markdown files directly, this option create image folders under markdown file directory



## What image extensions are searched?
Png, jpg, jpeg, gif, bmp, and svg, because these are the ones Obsidian currently supports. 

Feel free to add more if you need, editing this portion of the regex  pattern "png|jpg|jpeg|gif|bmp|svg".

## Feel free to submit a Pull Request or Issues😃!
Blockchain Version : Evolution from Currency to DApps
Published: 2022-12-25 09:36:47

Hi there !! , I just started learning **Blockchain** and it's my new **year resolution** to become **Blockchain Developer in 2023** .

In this article I will share the **versions of Blockchain** . If you want to know more about Blockchain please refer my **first blog** :
[Introduction to Blockchain](https://dev.to/jagroop2000/blockchain-starting-of-new-journey-5970)

**Evolution of Blockchain from Version 1 to 3 are described below :**


**BLOCKCHAIN 1.0 [ CryptoCurrency ] :**
In 2005 ,Hal Finney was firstly introduced the concept of Creating Money through solving computational problems.

He firstly introduced the concept of  Cryptocurrencies.Here, he implemented the distributed ledger technology and this ledger allow financial transactions based on Blockchain Technology.

**Example :**
Bitcoin is the example of Blockchain 1.0 [ Currency] and It is popularly known as Cash of Internet.

Also, This type of Version is permissionless as any participant will perform valid transaction of Bitcoin. 

**BlockChain 2.0 [ Smart Contracts]**
The new Version of BlockChain come because there is a problem in version 1.0 which was Mining of BitCoin was Wasteful and there was also lack of Scalability of Network in it. So this problem is improved in Version 2.0. In this version, the BlockChain is not just limited to Cryptocurrencies but it will extend up to Smart Contracts.

Thus, Small Contracts are Small Computer’s which live in the Chains of Blocks. These Small Computer’s are  free computer programs that executed automatically, and check the condition defined earlier like facilitation, verification or enforcement and reduce transactions cost efficiency.

In BlockChain 2.0,  BitCoin is replaced with Ethereum. Thus, BlockChain 2.0 was successfully processing high number of Transactions on Public network rapidly.

**BlockChain 3.0 [DApps]**
After Version 2.0, new version was introduced which includes DApps which is known as Decentralized Apps. A DApp is like a conventional app, it can have frontend written in any language that makes calls to its backend, and its backend code is running on decentralized Peer-To-Peer Network. It makes use of decentralized storage and communication which can be Ethereum Swarm etc.

There are many decentralized Applications like BitMessage, BitTorrent, Tor, Popcorn, etc.


So, that's for this Blog.  I will surely add Blogs for Blockchain from now so that whenever I need Revision I will use these blogs. Also it will help others to gain knowledge from these blog.
If anyone is Blockchain Expert or also learning Blockchain feel free to add more content in comments.
Which for-loop is the fastest in JavaScript?
Tags: javascript, performance, node, loop
Published: 2022-12-25 09:35:46


I was curious to see how fast loops perform in JS after seeing a similar post for C#, so I wrote a quick script to check. 

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

For this test, I tried four different for-loop syntaxes, where each loop was simply incrementing a counter variable 10^8 times, and each loop ran five times to get an average time. Here are the results:

- for-of: 1616.2 milliseconds
- forEach: 1488.6 milliseconds
- for loop (with index): 282.4 milliseconds
- for loop (with cached array length): 278.8 milliseconds

Interestingly, for very small arrays (< 10^3 elements) it does not really make a difference. However, for 10^3 to 10^6 size, the result is a bit surprising.

Results for 1000 iterations:
```javascript
{
  "forOf": 0.2,
  "forLoop": 0,
  "forEach": 0,
  "forLoopCached": 0
}
```

Results for 100,000 iterations:
```javascript
{
  "forOf": 5.4,
  "forLoop": 2,
  "forEach": 0.4,
  "forLoopCached": 0.6
}
```

So when it comes to <10^6 arrays, the classic `forEach` seems to be just fine.

I personally used to use the for-of (slowest) syntax because it seemed like the easiest one, well now we know which one I'm going to start using!

Here is the script: https://github.com/siddiqus/useful-scripts/blob/master/for-loop-benchmark.js

P.S. Happy Holidays everyone!
How to Monitor your k8s Persistent Volume Usage
Tags: k8s
Published: 2022-12-25 08:38:30

One of the most critical workloads is the one that has a Persistent volume (PV), PV resources belong to the cluster and exist independently of pods. Any disks and data represented by a PV continues existing even as the cluster changes and pods are deleted and recreated.

It's critical because you want always to make sure this PV always has enough space, you always need to do an analysis and take the right decision, what do you have today and what should be the volume size to meet the future requirements?


Today we will talk about the easy way to see PV utilization which will make you in the right position to take the right decision. 

## Using Prometheus To Monitor Your PV

One of the most common ways to monitor your K8s resources is to use Prometheus, and Grafana has a very nice dashboard to visualize that.

And here are the steps That you need to follow.

- Deploy and install Prometheus Using the Prometheus Stack helm chart from [here](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack)

- Once you have this ready for your cluster install Grafana from Grafana helm chart from [here](https://github.com/grafana/helm-charts/tree/main/charts/grafana) 

- The last step is to use the Mixin dashboard to visualize the usage of PV, you can get it from [here](https://github.com/kubernetes-monitoring/kubernetes-mixin)

- Now you will have a very nice dashboard that you can have a quick look into it and take your decision. 

![Image description](https://a.dailytask.co/images/tasks/ZYX2sJziOENotQXfc1cs7VJrIamKw53o35D101oQ.png)

Very cool, but what about if I don't have monitoring and I still want to make the right decision, here the 2nd solution come. 

## PV Utilization Using Kubectl-df-pv

A very cool kuectl plugin that you will install and start using to see the utilization of your PV. 

1. Install [Kubectl-df-pv](https://github.com/yashbhutwala/kubectl-df-pv) Plugin using krew. 

```
curl https://krew.sh/df-pv | bash
# . ~/.bashrc   # run if you use bash shell
# . ~/.zshrc    # run if you use zsh shell
```

2. After installing it use this command to see the utilization of the PV. 

```
kubectl df-pv
```

3. The result will be something like the following.

![Image description](https://a.dailytask.co/images/tasks/bFP2V5eveRc6z551N5pGjIZ5dwMlbwYZZUKnyxGR.png)

Very cool, now you can see the utilization of your PV and take the right decision.

-------
> Hope that can help you and see you next time 

- Follow me on the following network to get the new blogs in time.
-  [Linkedin](https://www.linkedin.com/in/ahmedmahmoudzidan/) 
-  [Twitter](https://twitter.com/zidanahmed2020)
What the most unusual versioning did you hear?
Tags: discuss, architecture, versioning, design
Published: 2022-12-25 08:33:23

For example:

> Donald Knuth's legendary TeX typesetting system uses a version number that, as of version 3, converges to π by adding another digit at each release: 3.14159265…. This signifies how the system is getting closer to perfection. Similarly, the Metafont system converges to e: 2.7182818….
What is the perfect Christmas for a Web developer ?
Tags: webdev, beginners, programming
Published: 2022-12-25 08:29:09

Got up early, I'm one of those who took 10 minutes (in theory, but more than this in fact) to check something inside code before starting the day. 
It's stronger than me not to let go of my computer 😪.

And you ? 
Merry Christmas 🎄✨️
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2022-12-25 08:00:22

---
title: "A Quick 10-Second Programming Joke For Today"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258eb1a429.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Why was the developer's family upset with them at dinner?

___A:___ They forgot to git squash before going home
 -->
VARIABLES OZGARUVCHI
Published: 2022-12-25 07:51:09

VEREBALS YOKI OZGARUVCHI
#
python
Ozgaruvchi bu bir narsani qiymati berish degam manoni anglatadi.Ozgaruchini a yoki b qisqa qilib etganda lyuboy haqrifda belgilasa bolad.Ozgaruvchini belgilaganda bza int va str dan foydalanishimiz kere.
Day 10: Transcription with 3 lines of Python
Tags: python, tutorial, 100daysofcode, challenge
Published: 2022-12-25 07:50:27

Amazon Transcribe, Google Speech-to-Text, Azure Cognitive Services, IBM Watson, AssemblyAI, DeepGram, Speechmatics, and Rev, …all provide APIs to transcribe audio files. So why should you care about Picovoice Leopard? Just for the [Free Tier](https://picovoice.ai/pricing/)? Nope! We have more reasons:

- **Private**: Voice data is processed on-device
- **Accurate**: [Backed by an Open-Source Benchmark](https://picovoice.ai/docs/benchmark/stt/)
- [Compact and Computationally Efficient](https://github.com/Picovoice/speech-to-text-benchmark#rtf) 
- **Cross-Platform**: [Runs on Linux, macOS, Windows, Android, iOS, Raspberry Pi, and NVIDIA Jetson](https://picovoice.ai/docs/leopard/)
- **Hyper-customizable**: [Self-service UI to customize models](https://picovoice.ai/docs/leopard/#customizations)
- **You can get started with 3 lines of code!**

Let's get started!
---
**1- Install**
Install Leopard from a terminal:
```
pip3 install pvleoparddemo
```

**2- Try it**
Grab your free AccessKey from [Picovoice Console](https://console.picovoice.ai/) and run the microphone demo from the terminal:
```
leopard_demo_mic --access_key ${YOUR_ACCESS_KEY}
```

**3- Build**
Create an instance of Leopard:
```
from pvleopard import *
o = create(access_key=${YOUR_ACCESS_KEY})
```

Transcribe an audio file:
```
transcript, words = o.process_file(${YOUR_AUDIO_FILE_PATH})
print(transcript)
```

_Enjoy!_
7 super cool AI tools worth checking out
Tags: ai, machinelearning, webdev
Published: 2022-12-25 07:47:33

We're very close to 2023 and we all expect an explosion of AI-based tools in the new year and for a good reason. If like me, you're a big fan of these technologies and how they can 10X our productivity, you can find a list of 7 tools in this domain in this post.

> Did you know that you can implement your ***web apps***, ***APIs***, ***websites***, *or* ***landing pages*** *with or without coding on* [***DoTenX***](https://dotenx.com/) *for free? Make sure to check it out and even nominate your work to be showcased. DoTenX is* ***open-source*** *and you can find the repository here:* [*github.com/dotenx/dotenx*](http://github.com/dotenx/dotenx)*.*

---

Now, let's take a look at our list.

1. **ChatGPT** ([https://chat.openai.com/](https://chat.openai.com/))
    
    Launched by OpenAI in November 2022, ChatGPT is a chatbot. It is created on top of the GPT-3.5 family of big language models from OpenAI, and it has been enhanced using supervised and reinforcement learning methods.
    
2. **Jasper AI** ([https://www.jasper.ai/](https://www.jasper.ai/))
    
    Jasper is an exceptionally powerful and intuitive AI copywriter that uses machine learning and artificial intelligence to create natural text and copy for blog articles, advertisements, social media posts, marketing emails, and other types of content.
    
3. **Midjourney** ([https://midjourney.com/](https://midjourney.com/))
    
    The independent research lab, Midjourney, offers the Midjourney Bot, which you can use to generate images by describing the image. You can seed the tool by using initial images to make sure the final result is closer to what you want.
    
4. **Dall.E 2 (**[https://openai.com/dall-e-2/](https://openai.com/dall-e-2/))
    
    DALL·E 2 is another AI system based on deep learning techniques, developed by OpenAI, that can create realistic images and art from a description in natural language.
    
5. **Synthesia** ([https://www.synthesia.io/](https://www.synthesia.io/))
    
    Synthesia is an AI video creation platform that helps you create videos from plain text in minutes. You can provide the text and choose any of the multiple characters or accents.
    
6. **Murf** ([https://murf.ai/](https://murf.ai/))
    
    Murft is a versatile AI voice generator tool to convert text to speech. Murf makes it simple to produce voiceovers for explainer videos, product demos, e-learning videos, audiobooks, and podcasts with its user-friendly interface and 120+ voices.
    
7. **Jenni AI** ([https://jenni.ai/](https://jenni.ai/))
    
    Jenni is an AI writing assistance you can use especially with blogs, essays, or emails.
    

What tools or platforms would you add to this list?