teleren/devto huggingface dataset:
Using SQLite with Python
Tags: python, database, sqlite, programming
Published: 2023-11-26 12:43:43

{%youtube cOHoopqt7Mc%}

In this guide, we will explore the usage of the sqlite3 module in Python 3. SQLite, a self-contained, file-based SQL database, comes pre-packaged with Python, eliminating the need for additional installations.

Throughout this tutorial, I'll cover the essential steps, including establishing a connection to a SQLite database, creating a table within the database, inserting data into the table, and performing operations to retrieve and update information.
Java Threads: Tips and Tricks with Examples
Tags: java, programming, tutorial, learning
Published: 2023-11-26 12:42:14

#### Examples:

1. **Thread Creation:**
   - Use `Runnable` interface for thread creation to promote better design.
   ```java
   class MyRunnable implements Runnable {
       public void run() {
           // Your thread logic here
       }
   }
   
   Thread myThread = new Thread(new MyRunnable());
   myThread.start();
   ```

2. **Thread Safety:**
   - Synchronize critical sections to avoid data inconsistency.
   ```java
   class Counter {
       private int count = 0;

       public synchronized void increment() {
           count++;
       }
   }
   ```

3. **Thread Join:**
   - Use `join()` to wait for a thread to finish its execution.
   ```java
   Thread t1 = new Thread(() -> {
       // Your thread logic
   });
   
   t1.start();
   t1.join(); // Main thread waits for t1 to finish
   ```

4. **Thread Pools:**
   - Utilize `ExecutorService` for managing thread pools.
   ```java
   ExecutorService executor = Executors.newFixedThreadPool(5);
   
   for (int i = 0; i < 10; i++) {
       executor.execute(new MyRunnable());
   }
   
   executor.shutdown();
   ```

5. **Atomic Operations:**
   - Use `Atomic` classes for atomic operations to avoid race conditions.
   ```java
   AtomicInteger atomicInt = new AtomicInteger(0);
   
   atomicInt.incrementAndGet();
   ```

6. **Thread Interruption:**
   - Gracefully handle thread interruption.
   ```java
   while (!Thread.interrupted()) {
       // Your thread logic
   }
   ```

7. **Thread Local:**
   - Utilize `ThreadLocal` for thread-specific data.
   ```java
   ThreadLocal<SimpleDateFormat> dateFormat = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd"));
   
   String formattedDate = dateFormat.get().format(new Date());
   ```

8. **Thread Priority:**
   - Use thread priority cautiously, as it may not be honored on all platforms.
   ```java
   myThread.setPriority(Thread.MAX_PRIORITY);
   ```

9. **Volatile Keyword:**
   - Use `volatile` keyword for variables accessed by multiple threads to ensure visibility.
   ```java
   private volatile boolean flag = false;
   ```

10. **ExecutorService Shutdown:**
    - Gracefully shut down the `ExecutorService`.
    ```java
    executor.shutdown();
    try {
        if (!executor.awaitTermination(500, TimeUnit.MILLISECONDS)) {
            executor.shutdownNow();
        }
    } catch (InterruptedException e) {
        executor.shutdownNow();
        Thread.currentThread().interrupt();
    }
    ```

Remember to handle exceptions, and always be mindful of potential deadlock situations when working with threads in Java.

### Read more Visit git repository

https://github.com/Pankaj-Str/Learn-JAVA-SE/tree/main/Day_59_Threading
Kubernetes 101 Workshop
Published: 2023-11-26 12:27:26

Are you new to Kubernetes and looking to gain a solid understanding of its core concepts? Do check out this recorded 4 hours workshop on Kubernetes for beginners!


{% youtube i0d5ta83c-k %}


In this intensive workshop, we cover Pod101, Service101, Deployment101, Network Policy101 and much more… providing you with a comprehensive overview of these fundamental components of Kubernetes.


In this workshop, you learn the basics of Kubernetes architecture and how to create, manage, and scale containerised applications using Pods, Services, Deployments, Network Policies etc. You also gain hands-on experience through practical exercises and real-world examples, allowing you to apply your newly acquired knowledge in a practical setting.

Whether you are a developer, operations engineer, or IT professional, this workshop is designed to give you a solid foundation in Kubernetes, one of the most popular container orchestration platforms in the world.

## Any Prereq?

No prior experience with Kubernetes is required, making this workshop perfect for beginners who are looking to dive into the world of Kubernetes and containerisation.

## Topics:

— [Pod101](https://github.com/collabnix/kubelabs#pods101)
— [Service101](https://github.com/collabnix/kubelabs#services101)
— [Deployment101](https://github.com/collabnix/kubelabs#deployment101)
— [ReplicaSet101](https://github.com/collabnix/kubelabs#replicaset101)
— [Scheduler101](https://github.com/collabnix/kubelabs#scheduler101)
— [StatefulSet101](https://github.com/collabnix/kubelabs#statefulsets101)
— [DaemonSet101](https://github.com/collabnix/kubelabs#daemonset101)
— [Jobs101](https://github.com/collabnix/kubelabs#jobs101)
— [Ingres101](https://github.com/collabnix/kubelabs#ingress101)
— [RBAC101](https://github.com/collabnix/kubelabs#rbac101)
— [Service Catalog101](https://github.com/collabnix/kubelabs#service-catalog101)
— [Cluster Networking101](https://github.com/collabnix/kubelabs#cluster-networking101)
— [Network Policies 101](https://github.com/collabnix/kubelabs#network-policies101)
— [Monitoring101](https://github.com/collabnix/kubelabs#monitoring101)
— [Security101](https://github.com/collabnix/kubelabs#security101?0)
— [Logging101](https://github.com/collabnix/kubelabs#logging101)
— [Helm101](https://github.com/collabnix/kubelabs#helm101)

Do check out this exciting 4 hour non-stop workshop and take your first step towards mastering Kubernetes! Don’t miss out on this opportunity to learn from experienced Kubernetes practitioners and connect with fellow beginners in the Kubernetes community.
更改IP地址指令
Published: 2023-11-26 12:23:24

要更改CentOS 7的IP地址，可以按照以下步骤进行操作：

1. 打开终端或通过SSH连接到CentOS 7服务器。

2. 使用root权限或具有sudo权限的用户执行以下命令来编辑网络配置文件：
   ```
   sudo vi /etc/sysconfig/network-scripts/ifcfg-<interface_name>
   ```
   其中 `<interface_name>` 是你要更改IP地址的网络接口的名称，比如 `eth0`。

3. 在打开的文件中，找到并修改以下行来更改IP地址：
   ```
   BOOTPROTO=static
   IPADDR=<new_ip_address>
   NETMASK=<new_netmask>
   GATEWAY=<new_gateway>
   ```
   将 `<new_ip_address>` 替换为新的IP地址， `<new_netmask>` 替换为新的子网掩码， `<new_gateway>` 替换为新的网关地址。

4. 保存文件并关闭编辑器。

5. 重启网络服务以使更改生效：
   ```
   sudo systemctl restart network
   ```

6. 验证新的IP地址是否生效，可以使用以下命令之一：
   ```
   ip addr show <interface_name>
   ```
   或者
   ```
   ifconfig <interface_name>
   ```
   其中 `<interface_name>` 是你更改的网络接口的名称。

请注意，更改IP地址可能会导致网络连接中断，因此请确保你在进行更改之前有备份并可以通过其他方式访问服务器，以防万一出现问题。
FCM notification with Laravel
Tags: laravel, php, firebase, node
Published: 2023-11-26 12:15:24

In the fast-paced world of technology, instant communication is key. Elevate your Laravel experience by integrating Firebase Cloud Messaging (FCM) notifications into your blog system.

**Why FCM?**
FCM ensures your users receive timely updates directly on their devices. From new comments to post interactions, keep your audience engaged and informed.

**What to Expect:**

- **Swift Communication**: FCM enables real-time notifications, ensuring your users are in the loop.
- **User Engagement**: Enhance the user experience with immediate alerts on their devices.
- **Easy Integration**: Follow our step-by-step guide in the [FCM Notification branch](https://github.com/mazimez/laravel-hands-on/tree/fcm-notification-part-1).

**Why Wait?**
Seize the opportunity to captivate your audience with seamless and instant communication. Integrate FCM notifications now and stay ahead in the Laravel game.

Check out the [FCM Notification branch](https://github.com/mazimez/laravel-hands-on/tree/fcm-notification-part-1) for a quick implementation guide.

Revolutionize your Laravel blog experience. It's time to notify, engage, and captivate!
Surfacehcm
Tags: webdev
Published: 2023-11-26 11:53:28

Surfacehcm - Địa điểm uy tín mua bán các sản phẩm công nghệ: Máy tính Microsoft Surface, phụ kiện công nghệ chính hãng, uy tín, giá tốt nhất thị trường, cam kết hàng luôn có sẵn.

Surfacehcm
SĐT: 0932.938.980
Email: surfacehcm.vn@gmail.com
Website: https://surfacehcm.vn/
Địa chỉ: 339/52 Lê Văn Sỹ, Phường 13, Quận 3, TP.HCM
Map: https://maps.app.goo.gl/o36E6mT3EWF7yfYM8

#surfacehcm
#surface_hcm
#hcm_surface
#microsoft_surface_hcm
#microsoft_surfacehcm

https://www.youtube.com/@surfacehcmvn
https://www.facebook.com/surfacehcm
https://www.linkedin.com/in/surfacehcm/
https://twitter.com/surfacehcm
https://www.tumblr.com/surfacehcmvn
https://www.instagram.com/surfacehcm.vn/
https://500px.com/p/surfacehcmvn
https://orcid.org/0009-0000-2388-9082
https://www.flickr.com/photos/surfacehcm/
https://www.quora.com/profile/Surfacehcm
https://independent.academia.edu/surfacehcm
https://www.behance.net/surfacehcmvn
https://www.pinterest.com/Surfacehcm/
https://soundcloud.com/surfacehcm
#bán_surface_pro_hcm
#surface_pro_hcm
Laravel package to integrate telegram bot api
Tags: laravel, telegram, telegrambot, api
Published: 2023-11-26 11:33:21

_Hello. My name is Milly, and I've been writing Telegram bots for a few years now. I used to write Telegram bots in PHP without any libraries. When I had to make a website, I learned about laravel and realized that Laravel has everything. I just lacked a library to work with the Telegram API in Laravel and decided to develop it myself._

## [Laragram](https://github.com/Mirmuxsin/laragram): a Laravel package to integrate the Telegram bot API

Features

- It has every method of Telegram bot API that is fully documented.
![Methods](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vice28vfc9to9bu67rgb.png)
- Update-objects, which are easy to handle, are documented too.
![Objects](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92sx8se6cmufj71a0xsn.png)
- FSM Routing
![FSM Routing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g0fnezduf86gv3ep2fu0.png)

### Now let's try to install it and send hello world.
First, install the Laragram package, and make sure that the database connection settings are correct!
`composer require milly/laragram`

Then run these commands to publish assets and config
`php artisan vendor:publish --provider="Milly\Laragram\LaragramServiceProvider"`

Add your telegram bot token to .env
`TELEGRAM_BOT_TOKEN=123456789:XXXXXXXXXXXXXXXXXXXXXXXXXXX`

Run migration to be able to use FSM-Routing
`php artisan migrate`

And we are ready to use telegram methods. Let's test the basic sendMessage method:

```php
use \Milly\Laragram\Laragram;

Laragram::sendMessage(
    'your_telegram_id',
     null,
    'Hello world'
);
```

When you run this code, you should get the message 'Hello world' from your telegram bot (you should have started the bot before). And that's it. Isn't it easy?

You can check out the full documentation from on github: https://github.com/Mirmuxsin/laragram
One Minute: BurmillaOS
Tags: oneminute, burmillaos, docker, virtualmachine
Published: 2023-11-26 11:29:42

BurmillaOS is a minimal Linux distribution for hosting Docker containers on virtual machines. BurmillaOS is pure containers!

**Based On**: [RancherOS](https://rancher.com/docs/os/v1.x/en/)
**Concept**: [Everything is Docker](https://www.docker.com)
**Architecture**: [System Docker and user Docker layers](https://github.com/burmilla/os/blob/master/howitworks.png)
**Advantages**: Small attack surface, fast boot, fast container startup
**Compatibility**: [Docker Compose](https://docs.docker.com/compose/) (Optional)
**Platform**: x86-64
**License**: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
**Website**: https://github.com/burmilla/os
**Documentation**: https://burmillaos.org

**PS**: Testable on Apple Silicon MacOS via [UTM](https://github.com/utmapp/UTM) (Deactivate `UEFI Boot` and use `virtio-vga` display card emulation)
Day 4
Tags: html, 100daysofcode, odinproject, español
Published: 2023-11-26 05:13:16

#Dia 4 
 
Termine con el primer proyecto de odin , que es una simple web en html sin css. Solo para poner en practica, los conceptos aprendidos. Manejar tag básicos, títulos, link agregar imágenes y crear otras paginas y poder realizar los vínculos correspondientes. De ha momento el sitio no tiene nada de css solo estructura y algunas imágenes. 
 Dejo a continuación el link de github para que vean el proyecto..
 Gracias a los que mira o leen y se toman el tiempo. Saludos. 


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

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

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

#Day 4
Due to time constraints, I hadn't been able to start with the 4th day of programming. Although I read a bit the day before yesterday and yesterday, I couldn't practice coding. I completed the first project from Odin, which is a simple HTML webpage without CSS. It's just to put into practice the concepts I've learned – handling basic tags, titles, linking, adding images, creating other pages, and making the corresponding links. At the moment, the site has no CSS, only structure and some images.

I'm providing the GitHub link below for you to check out the project. Thanks to those who take the time to look or read. Greetings.

**github code repo!!**

 [link](https://github.com/DavidBordalecu/receta.git)
please help
Tags: react, threejs, webdev, javascript
Published: 2023-11-26 11:28:04

I’m having some trouble using 3d objects (.gbl/.gltf), I’m using three js and tailwinds;
I got the spotlight, the pointlight, the primitive (object, scale, position, rotation), and the canvas (frame loop, shadows, dpi, camera, gl)orbitcontrols, I still have no idea why isn’t it working on the page is just white and nothing showing up
Weekly Challenge 244
Tags: perl, python, theweeklychallenge
Published: 2023-11-26 11:20:39

Each week Mohammad S. Anwar sends out [The Weekly Challenge](https://theweeklychallenge.org/), a chance for all of us to come up with solutions to two weekly tasks. My solutions are written in Python first, and then converted to Perl. It's a great way for us all to practice some coding.

[Challenge](https://theweeklychallenge.org/blog/perl-weekly-challenge-244/), [My solutions](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-244/sgreen)

## Task 1: Count Smaller

### Task

You are given an array of integers.

Write a script to calculate the number of integers smaller than the integer at each index.

### My solution

This is a one-liner in Python

```python
solution = [sum(1 for j in ints if j < i) for i in ints]
```

Breaking it down:

* `for i in ints` iterates through the supplied list, assigning each value to the variable `i`.
* `sum(1...)` will count the number of elements that satisfy the condition.
* `for j in ints` creates an inner loop, assigning each value to the variable 'j'.
* Finally `j < i` will only count the elements where the value in the inner loop is lower than the outer loop.

As Perl does not provide an easy way for double loops, I create a separate function to calculate the values less than a number, and then use the map function to iterate through each value.

```perl
sub less_than($i, $ints) {
    return scalar( grep { $_ < $i } @$ints );
}

my @solution = map { less_than( $_, \@ints ) } @ints;
```

### Examples

```bash
$ ./ch-1.py 8 1 2 2 3
4, 0, 1, 1, 3

$ ./ch-1.py 6 5 4 8
2, 1, 0, 3

$ ./ch-1.py 2 2 2
0, 0, 0
```

## Task 2: Group Hero

### Task

You are given an array of integers representing the strength.

Write a script to return the sum of the powers of all possible combinations; power is defined as the square of the largest number in a sequence, multiplied by the smallest.

### My solution

For this task, I create a function called `calculate_power` that returns the square of the largest number multiplied by the smallest number.

```python
def calculate_power(numbers):
    min_int = min(numbers)
    max_int = max(numbers)
    return max_int ** 2 * min_int
```

In the main function, I create a loop called `length` which goes from 1 to the length of the supplied list. For each `length`, I compute all combinations. Thankfully Python has a combination function in [itertools](https://docs.python.org/3/library/itertools.html).

```python
for length in range(1, len(ints)+1):
    power += sum(calculate_power(c) for c in combinations(ints, length))
```

Perl's combination function comes from the [Algorithm::Combinatorics](https://metacpan.org/pod/Algorithm::Combinatorics) module.

```perl
foreach my $len ( 1 .. $#ints+1) {
    my $iter = combinations(\@ints, $len);
    while (my $c = $iter->next) {
        $power += calculate_power($c);
    }
}

```
### Examples

```bash
$ ./ch-2.py 2 1 4
141
```
Just starting out
Tags: webdev, edx, beginners, tutorial
Published: 2023-11-26 11:13:22

Hi guys! 

I'm joining the community as a beginner and thought a great way to do it would be to post frequently and document my journey. Hoping this helps me and anyone else that's just starting out.

I'm just about to start a Front-End Web Development bootcamp with Ed.X

Let me know if you've done this before and I'd be super grateful for any advice or top tips!

Nicole
43. Sunday Assignment 2 day and thinking of computing visionaries (Day 41)
Published: 2023-11-26 11:09:36

This is what I achieved today:

- Re-potted my plants (30 mins)
- Began my assignment 2 which is due in 2 week's time (4 hours)
- Meal prep for the next few days (90 mins)
- Set up my new Amazon Echo Pop and Alexa (45 mins)
- Tidy up the desktop cables with some cable management items (60 mins)
- Meditation (90 mins)
- Set up a new smart plug (30 mins)
- Write this blog (30 mins)

So, I spent 7 hours doing stuff and 4 hours studying. Not ideal but that is how it is.

Assignment 2 is not web design focused but more on the theoretical aspects of computing and then a little bit of Python theory. But today I avoided any Python work and focused on just the essay writing for these topics:

- HTTP & HTTPS
- TCP
- Markup Languages
- Data Packets
- IP Addresses
- Routers & Routing
- Domain & DNS

There's more but the above is what I was able to manage today.

I surprised myself that I wasn't overwhelmed with the technical jargon of these topics! Luckily, the material available online and from course notes were simple in nature and easy to grasp.

But all these reading and writing got me thinking.

The evolution of the World Wide Web stands as a testament to the brilliance and dedication of the engineers who crafted its foundational technologies. Delving into the intricate world of computer, electronics, and electrical engineering, I couldn't help but marvel at the ingenuity behind the seamless transmission of data across global computer networks. The sheer complexity of the tech stack they constructed is awe-inspiring, showcasing the remarkable capabilities of human intelligence. Their solutions to the myriad challenges encountered along the way paint a picture of relentless innovation and determination.

However, what's most fascinating is that this journey is far from over. Despite the incredible advancements achieved, the internet and computing continue to surge forward, evolving with each passing moment. The perpetual race toward more sophisticated solutions persists, promising a future where technology will undoubtedly reach unprecedented heights. As I reflect on their accomplishments, I find myself eagerly anticipating the opportunity to contribute to these ongoing discoveries. Here's to the pioneers who paved the way and to the exciting prospects that lie ahead in the ever-evolving landscape of technology.

*Time*: 10:00 PM. Sunday is done. Time to bed. Busy work week and evening coding study ahead.
Placeholder Maintainer
Tags: hack23maintainer
Published: 2023-11-26 11:02:51

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a maintainer. Is this your first Hacktoberfest, or have you maintained in others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Project
<!-- Tell us about the repository that you hosted. What processes did you set up to review and merge pull requests? Feel free to embed your GitHub repo by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your project goals changed since publicly maintaining it? -->
afterRender and afterNextRender phases
Tags: angular
Published: 2023-11-26 11:00:00

The [afterRender and afterNextRender](https://angular.dev/guide/components/lifecycle#afterrender-and-afternextrender) functions introduced in Angular v16.2 can now specify a phase option.

Angular uses this phase to schedule callbacks to improve performance.

There are 4 possible values, and they run in the following order:
• **EarlyRead**: When you need to read the DOM before writing to the DOM.
• **Write**: Needed if you want to write to the DOM, for example, to initialize a chart using a third-party library.

• **MixedReadWrite**: Default, but should be avoided if possible to use a more specific phase.
• **Read**: Recommended if you only need to read the DOM.

I think we should be able to use Read and Write in most cases. EarlyRead and MixedReadWrite degrade performances, so they should be avoided if possible.

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

---

Let's get connected! You can find me on:
- Medium: https://medium.com/@nhannguyendevjs/
- Dev: https://dev.to/nhannguyendevjs/
- Substack: https://nhannguyendevjs.substack.com/
- Linkedin: https://www.linkedin.com/in/nhannguyendevjs/
- X (formerly Twitter): https://twitter.com/nhannguyendevjs/
Home Project 2 @ Spartaa Coding Club
Published: 2023-11-26 10:57:24


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fpki9vi3xkcotp0xair4.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cy9skvd693lyqvhybed0.png)
Hello!
Tags: introduction, c9dn
Published: 2023-11-26 10:33:43

### Some info

I'm Shlok(Known as C9DN online). I'm a programmer who's also going to be making a blog.

I'm not the best with grammer rules. While I do try to check my work before publishing, I make mistakes. If you notice something, please comment letting me know, so I can fix this issue.

### This is a coding blog

Dev.to is a coding website, and I'm a programmer. This blog will be focused on programming, and will generally avoid other stuff. 

This also means I'll be using programming notation like:

```py
print('hello world')
```


### Schedule

I try to work on a schedule. I'll be posting every Sunday at 3:30PM.

### A bit of a warning

I tend to "yap" a lot. I'll attempt to keep things short and to the point in these blog posts, but I cannot guarantee that will happen.

Also, this blog may go into some complicated topics. If you have any questions, let me know.

Lastly, Be kind. These comments are a safe space to learn. Avoid disrespect.

>  Constructive Criticism is great, but criticise ideas, not people


I guess that's all. I'll see you all next week. Till then, stay safe.


_Make sure to follow me so you know right when I post_