teleren/devto huggingface dataset:
The most painful reason NULLs are evil
Tags: rails, null
Published: 2024-05-31 14:03:45

---
title: The most painful reason NULLs are evil
published: true
description: 
tags: Rails,null
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-05-31 13:50 +0000
---

I keep harping on about doing `null: false` everywhere, especially for strings and booleans, but sometimes there are sneaky exceptions for number fields, where a default of `0` does not make sense and the values will not be available for a time, some draft records etc.

You have to be extremely careful then because apparently NULLs are **not** "not equal" to anything. What do I mean?

Consider these `User` records:

```rb
id: 1, age: 20
id: 2, age: 25
id: 3, age: nil
```

How would you query for all users who are not 20?
`where.not(age: 20)`, right? Sorry to say, but User#3 will be omitted from such queries. 😫

You have two options:
* denullify the age column (may be impossible)
* tweak the query to handle the silly null edge-case:

```rb
where.not(age: 20).or(where(age: nil))
```
The art of complaining effectively
Tags: beginners, productivity, career, learning
Published: 2024-05-31 14:00:00


Marcus Aurelius said "Don't be overheard complaining…Not even to yourself". I think about this statement a fair bit. Stoics believe complaining is pointless since that is time wasted when it could be spent improving personally.

Complaining in most cases is bad. When you just complain all the time it is a major mental drain on yourself and people surrounding you. Merely complaining helps no one and breeds negativity. 

However, there are a couple of positives to complaining -
- Sometimes you just need to get things off your chest, feel better and move on. This is something you should use strategically because otherwise it can very easily fit into the previous category of mindless complaining.
- Other times, it shows that you don't believe in the status quo. For whatever reason, the current scenario isn't to your liking and you are going against the tide.

The big question here is "so what?". What you do next will likely determine the type of person you are. You know how they say "there are no wrong answers"? Unfortunately in this case there is a wrong answer. If you continue to complain, you will not inspire any confidence in people to believe or follow you. On the other hand, if you like to think of it as a way to redirect the problem towards a solution, that busts a big door of possibilities . Rather than just complain and whine about something, presenting an alternative or a solution to the situation helps bring purpose to it. Your ability to come equipped with a solution without being asked to, shows that you have initiative.

The more senior you get, the more this is imperative. Your ability to be an effective senior is predicated on spotting scenarios that are not optimal for your team or codebase coupled with a knack for identifying solutions for them. It doesn't have to be perfect. You, your peers or your boss can build on top of it and get it to a viable place.

This is not just a career-motivated tactic but a way to breed the right character. If you want to be seen as a problem solver, a go-getter, someone who can be depended on to think of the greater good - you have to come to the table with something besides just grievances. When you think about complaining, take a second to think about how you could contribute to making the situation better, either through yours or someone else's actions and you are now on the path of effective complaining.
process.nexTick vs setImmediate
Published: 2024-05-31 13:53:35

process.nextTick and setImmediate are two functions in Node.js that are used to schedule the execution of callback functions. They are similar but have different timing and use cases. Here's a breakdown of their differences along with examples:
process.nextTick

**process.nextTick**

Timing: process.nextTick schedules a callback function to be invoked in the same phase of the event loop, right after the current operation completes and before the event loop continues.

Use Case: It is useful when you want to execute a callback immediately after the current operation but before any I/O operations or timers.

**setImmediate**

Timing: setImmediate schedules a callback function to be invoked in the next iteration of the event loop, after I/O events' callbacks.

Use Case: It is useful when you want to defer the execution of a function until the current I/O events have been processed.

``` js
Example


const fs = require('fs');

console.log('Start');

// Schedule with process.nextTick
process.nextTick(() => {
    console.log('Next Tick');
});

// Schedule with setImmediate
setImmediate(() => {
    console.log('Immediate');
});

// Read a file (simulates I/O operation)
fs.readFile(__filename, () => {
    console.log('File Read');

    // Schedule another nextTick inside I/O
    process.nextTick(() => {
        console.log('Next Tick inside I/O');
    });

    // Schedule another setImmediate inside I/O
    setImmediate(() => {
        console.log('Immediate inside I/O');
    });
});

console.log('End');

Expected Output

Start
End
Next Tick
File Read
Next Tick inside I/O
Immediate inside I/O
Immediate

```

Explanation

    Initial Phase:
        console.log('Start') is executed.
        process.nextTick(() => { console.log('Next Tick'); }) schedules a callback to be executed after the current phase.
        setImmediate(() => { console.log('Immediate'); }) schedules a callback for the next iteration of the event loop.
        fs.readFile(__filename, () => { ... }) schedules an I/O operation.

    After Initial Phase:
        console.log('End') is executed.
        process.nextTick callback is executed: console.log('Next Tick').

    I/O Phase:
        File read operation completes, console.log('File Read') is executed.
        Inside the I/O callback:
            process.nextTick(() => { console.log('Next Tick inside I/O'); }) schedules another callback for the current phase.
            setImmediate(() => { console.log('Immediate inside I/O'); }) schedules another callback for the next iteration of the event loop.
        process.nextTick callback inside I/O is executed: console.log('Next Tick inside I/O').

    Next Event Loop Iteration:
        All setImmediate callbacks are executed in order: console.log('Immediate inside I/O') and console.log('Immediate').

Summary

    process.nextTick executes the callback before the next I/O event.
    setImmediate executes the callback after the current I/O events.


https://medium.com/@a35851150/interview-qustions-on-event-loop-in-js-901c567a1271
https://medium.com/@a35851150/interview-qustions-on-event-loop-in-js-901c567a1271
Securing Your Magento 2 Store: Top 12 Security Measures for Enhanced Protection
Tags: magento, security
Published: 2024-05-31 13:51:34

Securing your Magento 2 store is crucial to safeguard sensitive data and maintain customer trust. This blog outlines 12 essential security steps every store owner should implement and the role of Magento hosting in fortifying your e-commerce platform.

**1. Regular Updates:** Always keep your Magento 2 and its extensions up-to-date to protect against vulnerabilities.
h
**2. Strong Password Policies:** Implement strong password requirements for backend users to prevent unauthorized access.

**3. Two-Factor Authentication:** Enhance login security with two-factor authentication, adding an extra layer of protection.

**4. Secure Admin Path:** Change the default admin URL to a custom path to avoid easy guesses by attackers.

**5. Use Secure Connections:** Ensure that your store uses HTTPS to encrypt the data exchanged between users and the server.

**6. Backend CAPTCHA:** Implement CAPTCHA for admin logins to prevent automated attacks.

**7. File Permission Settings:** Set appropriate file permissions on your server to prevent unauthorized access.

**8. Disable Directory Indexing:** This prevents hackers from easily browsing your site's structure.

**9. Use Security Extensions:** Consider Magento security extensions that enhance protection against common threats.

**10. Backup Regularly:** Maintain regular backups of your store’s data to recover quickly in case of data loss.

**11. Choose Reliable Extensions:** Only use extensions from trusted sources to avoid introducing vulnerabilities.

**12. Magento Hosting Security:** Choose a [Magento hosting](https://devrims.com/magento-hosting/) provider that offers robust security features including firewalls, intrusion detection, and regular security audits.

Opt for managed Magento hosting that not only [Magento 2 Security](https://devrims.com/blog/magento-2-security-12-things-you-should-do/) offers enhanced security protocols but also ensures optimized performance for Magento stores. Managed hosting can handle much of the technical overhead, allowing you to focus on growing your business while keeping it secure.
Difference between Synchronous % Asynchronous
Tags: webdev, javascript, beginners, programming
Published: 2024-05-31 13:50:19

How code is executed in JavaScript falls into two main categories: synchronous and asynchronous. Understanding these two is key to writing efficient and responsive web applications.

Synchronous

Synchronous code execution happens sequentially, one line at a time. Each line of code waits for the previous line to finish before it starts. Imagine it like waiting in line at a store - you can't move forward until the person in front of you does.

Here's an example of synchronous code:

console.log("I'm first!");

let result = someFunctionThatTakesTime(); // Simulates a long-running task
console.log(result);
In this example, the first line "I'm first!" will be logged to the console, then the program will pause and wait for someFunctionThatTakesTime to finish. Once it does, the result will be logged.


Asynchronous

Asynchronous code execution, on the other hand, doesn't block the main thread. When an asynchronous operation is encountered, like fetching data from a server, the program continues to execute the next line of code. The asynchronous operation runs in the background, and when it's finished, it notifies the program through a callback function.

Here's an example of asynchronous code:

console.log("I'm first!");

fetchDataFromServer(function(data) {
  console.log(data);
});

console.log("I'm third!"); // This will be executed before data is fetched

In this example, all three lines are executed one after another. However, the fetchDataFromServer function is asynchronous. So, "I'm first!" and "I'm third!" will be logged immediately, and then the program will continue to wait for the data to be fetched. Once the data is retrieved, the callback function will be executed, and the data will be logged.

Why Asynchronous is Important

Asynchronous programming is essential for creating responsive web applications. If long-running tasks constantly block your code, your UI will become unresponsive and users will have a bad experience. Using asynchronous techniques, you can keep your UI responsive while background tasks are completed.
Powering Up #NET Apps with #Phi-3 and #SemanticKernel
Tags: englishpost, codesample, github
Published: 2024-06-03 14:57:48

---
title: Powering Up #NET Apps with #Phi-3 and #SemanticKernel
published: true
date: 2024-05-31 13:49:48 UTC
tags: EnglishPost, CodeSample, EnglishPost, GitHub
canonical_url: 
---

Hi!

# Introducing the Phi-3 Small Language Model

Phi-3 is an amazing Small Language Model. And hey, it’s also an easy one to use in C#. I already wrote how to use it with ollama, now it’s time to hit the ONNX version.

## Introduction to Phi-3 Small Language Model

The [Phi-3 Small Language Model (SLM)](https://azure.microsoft.com/en-us/blog/introducing-phi-3-redefining-whats-possible-with-slms/) represents a significant leap forward in the field of artificial intelligence. Developed by Microsoft, the Phi-3 family of models is a collection of the most capable and cost-effective SLMs available today. These models have been meticulously crafted to outperform other models of similar or even larger sizes across various benchmarks, including language understanding, reasoning, coding, and mathematical tasks.

Phi-3 models are not only remarkable for their performance but also for their efficiency and adaptability. They are designed to operate across a wide range of hardware, from traditional computing devices to edge devices like mobile phones and IoT devices. This makes Phi-3 particularly suitable for developers looking to integrate advanced AI capabilities into applications that require strong reasoning, limited compute resources, and low latency.

## C# Phi3-Labs GitHub Repository

[The GitHub repository in question serves as a practical guide for developers looking to harness the power of the Phi-3 SLM within their applications](https://github.com/elbruno/phi3-labs). It provides a set of sample projects to demonstrate how to use Phi-3 and C#.

- **LabsPhi301**. This is a sample project that uses a local phi3 model to ask a question. The project loads a local ONNX Phi-3 model using the Microsoft.ML.OnnxRuntime libraries.
- **LabsPhi302**. This is a sample project that implements a Console chat using Semantic Kernel. 
- **LabsPhi303 (Comming soon!)**. This is a sample project that uses Phi-3 Vision to analyze images. 

The repository contains detailed instructions for setting up the development environment, cloning the necessary models from Hugging Face, and installing the Phi-3 model. 

You can learn more about [Phi-3 in Hugging Face](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-onnx).

A final running application will look like this.

(![Chat demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvfgyqoq3chtn4uvbo50.gif))


Happy coding!

Greetings

El Bruno

More posts in my blog [ElBruno.com](https://www.elbruno.com).

* * *
What I will be doing for the 30 day code challenge
Tags: adhd, frontend, backenddevelopment, hacking
Published: 2024-05-31 13:46:11

-Things that I will be studying for the 30 day code challenge:
>React Framework(Frontend dev)
>Flask Framework(Backend dev)
>Ethical Hacking(Try Hack me)

-This will not be an easy challenge especially for a guy going through this with ADHD.
The Future of Networking: Trusted Digital Business Cards from the Leading Platform
Tags: digitizebusinesscards, digitizecards, businesscards
Published: 2024-05-31 13:43:23

In the digital age, networking has transformed drastically, and traditional business cards are becoming a thing of the past. Enter digital business cards, a modern, efficient, and eco-friendly way to share your professional information. If you’re looking to stay ahead in your networking game, trusted digital business cards from a leading platform like Digitize Cards are your best bet. Here’s why.
**
Why Digital Business Cards?**
Digital business cards offer several advantages over traditional paper cards. They are easy to update, eliminating the need to print new cards whenever your information changes. They are also more interactive, allowing you to include links to your social media profiles, websites, and portfolios. Additionally, they are environmentally friendly, reducing paper waste.

**Key Features of [Digital Business Cards](https://digitizecards.com/
)**
**Contact Information:** Just like traditional cards, digital business cards include your name, phone number, email address, and company name. However, they also allow you to add much more.

**Professional Photo**: A professional photo adds a personal touch and makes your card more memorable. It helps people put a face to the name.

**Job Title and Company Logo:** Clearly stating your job title and including your company’s logo helps recipients immediately recognize your role and organization.
**
Social Media Links:** You can integrate links to your professional social media profiles, such as LinkedIn, Twitter, or Instagram. This allows recipients to connect with you on multiple platforms.

**Interactive Features:** Digital business cards can include QR codes, videos, and links to your portfolio or website. These interactive elements make your card more engaging and informative.

**Personalized Message:** A brief personalized message or tagline can make your card stand out and leave a lasting impression.

**Digitize Business Cards in Pune**
For those in Pune, Digitize Cards offers a range of customizable options to create impactful digital business cards. Their platform provides easy-to-use templates and innovative features to help you design a professional and memorable digital business card. Whether you need to digitize business cards for a corporate event or personal networking, Digitize Cards in Pune has got you covered.

**Conclusion**
Digital business cards are the future of networking. They offer unparalleled convenience, interactivity, and eco-friendliness. By leveraging a trusted platform like Digitize Cards, you can create digital business cards that truly represent your professional identity. Embrace the future of networking with trusted digital business cards from the leading platform and make a lasting impression in every interaction.
Custom Software Development
Tags: softwaredevelopment
Published: 2024-05-31 13:36:51


Dev Technosys offers comprehensive [custom software development services](https://devtechnosys.com/custom-software-development.php) across various industries. With over a decade of experience, they specialize in tailored solutions for healthcare, manufacturing, CRM, and more. Their expertise includes software consulting, integration, product development, and ongoing maintenance. Connect with Dev Technosys for scalable and efficient software solutions.
Cool Tools & Hot Trends: Generative AI & Smart Scraping
Tags: news, webdev, javascript, beginners
Published: 2024-05-31 13:26:59

Hello people, 

Welcome to this week's newsletter. Sharing interesting news and tools for this week. 

[Read directly on browser](https://ihatereading.in/newsletter)

[Mailyto - Open-source Email Editor](https://maily.to/)

I was searching the email editors npm module or probably tools and found the mailyto among the first on the Google search. I've used the website and found it pleasing, and a good user experience as well, so I'm sharing it with devs across the globe, in addition, this is a cool small project frontend developers can add to their portfolio.

[Tiptap: Rich Text Editor](https://tiptap.dev/docs/editor/introduction)

I reached to tiptap website through Google Inspect. While inspecting the mailyto website, the first thing I did was to open Google Inspect and that's where I found this cool open-source module to build a rich text editor in the front end. 

[Frontend Resources](https://dev.to/miguelrodriguezp99/frontend-resources-1dl4)

An extensive list of resources for front-end development developers.

[Smart Scraping Web API, ScrapeNinja](https://scrapeninja.net/)

ScrapeNinja is making $8K/month and it's just a SAAS website run by a bunch of developers. This is a real deal breaker of how a developer can run a small yet huge profitable business out of his laptop. Check it out, a good inspiration for a small side project.

[Vercel AI SDK Introduction](https://www.youtube.com/watch?v=UDm-hvwpzBI&t=6s)

Watching vercel AI SDK videos on Youtube to get started with AI SDK in Next.js, here is the video

[Vercel launched version 15 of Next.js](https://www.youtube.com/watch?v=Txf2pbR2Cyk)

Vercel launched next.js version 15 after launching RSC components and vercel AI SDK we have a new version check the video as React 19 has also launched to vercel is thinking on the same ground. HINT: Something related to React Compiler which I've already mentioned in the last newsletter.

[Want to learn Generative AI](https://www.youtube.com/watch?v=2IK3DFHRFfw)

Watch the YouTube video with more than millions of views on Generative AI and what it is in a nutshell. LangChain is also quite trending to integrate LLMs or GPT into your website creating generative AI apps or AI-powered apps, [watch this playlist for LLM apps](https://www.youtube.com/watch?v=nAmC7SoVLd8&list=PLeo1K3hjS3uu0N_0W6giDXzZIcB07Ng_F)

[React 19 useOptimistic new hooks](https://x.com/steph_dietz_/status/1795468659617386956)

React 19 will be live in May 2024 and the big change was React Compiler which I've already covered in the last newsletter. In addition, React 19 introduce a few more hooks and useOptimistic is one among them, watch the video to understand it.

That's it for today

Feel free to share it with someone in need, see you next Friday

Shrey
I want to implement P2P connection via Signaling Server
Tags: webdev, javascript, programming, beginners
Published: 2024-05-31 13:24:48

I have signaling server and I want to implement P2P connection via signaling server.
Here is the information of signaling server.
https://p2p.vantagemdm.com:8890
- Supported Socket API functions
	connect
	disconnect
	reconnect_error
	connect_error
	error
- Supported signalling/socket events are. Send ping to ensure that connection will remain alive
     /v1/alive  (every 10 seconds)
     /v1/ready
     /v1/stream/start
     /v1/stream/destroy
     /v1/stream/joined
     /v1/stream/leaved
     /v1/sdp/peer_ice
     /v1/error

I want some advice from expert at WebRTC and Signaling.
Android App Development vs iOS App Development
Published: 2024-05-31 13:17:50

When deciding between Android app development and iOS app development, it's essential to understand the differences and unique advantages of each platform.

**Market Share and Audience:**
Android dominates the global market share with a larger user base, particularly in regions like Asia, Africa, and Latin America. iOS, however, has a strong presence in North America, Europe, and Australia. An [iOS app development](https://www.centrixcube.ae/flutter-app-development) firm often targets users who are typically more willing to spend on apps and in-app purchases, which can be advantageous for monetization.

**Development Environment:**
Android app development uses Java or Kotlin as programming languages and relies on Android Studio as its integrated development environment (IDE). In contrast, iOS app development primarily uses Swift or Objective-C, with Xcode as the preferred IDE. Each environment offers robust tools, but developers often find Xcode's interface more streamlined for a seamless development experience.

**Fragmentation:**
Android's open ecosystem means dealing with a wide range of devices, screen sizes, and OS versions, which can complicate the development and testing process. On the other hand, iOS offers a more controlled environment with fewer device variations, making it easier to ensure app consistency and performance across all devices.

**Revenue and Monetization:**
While Android apps reach a broader audience, iOS apps generally generate higher revenue through the App Store. An iOS app development company might focus on this aspect to maximize profitability.

**Cross-Platform Solutions:**
Using a Flutter app development company can bridge the gap between Android and iOS development. Flutter, an open-source framework by Google, allows developers to create high-quality, natively compiled applications for both platforms from a single codebase. This approach not only saves time and resources but also ensures a consistent user experience across devices.

**Conclusion**, 
Both Android and iOS app development have their own sets of benefits and challenges. The choice largely depends on your target audience, budget, and specific project requirements. Leveraging the expertise of a [Flutter app development company in Dubai](https://www.centrixcube.ae/flutter-app-development) or an iOS app development company can help you navigate these complexities and achieve your app development goals efficiently.