bg_image
header

Perl Compatible Regular Expressions - PCRE

Perl Compatible Regular Expressions (PCRE) are a type of regular expression syntax and engine that follows the powerful and flexible style of the Perl programming language. They offer advanced features that go beyond the basic regular expressions found in many older systems.


Why "Perl Compatible"?

Perl was one of the first languages to introduce highly expressive regular expressions. The PCRE library was created to bring those capabilities to other programming languages and tools, including:

  • PHP

  • Python (similar via the re module)

  • JavaScript (with slight differences)

  • pcregrep (a grep version supporting PCRE)

  • Editors like VS Code, Sublime Text, etc.


Key Features of PCRE:

Lookahead & Lookbehind:

  • (?=...) – positive lookahead

  • (?!...) – negative lookahead

  • (?<=...) – positive lookbehind

  • (?<!...) – negative lookbehind

Non-greedy quantifiers:

  • *?, +?, ??, {m,n}?

Named capturing groups:

  • (?P<name>...) or (?<name>...)

Unicode support:

  • \p{L} matches any kind of letter in any language

Assertions and anchors:

  • \b, \B, \A, \Z, \z

Inline modifiers:

  • (?i) for case-insensitive

  • (?m) for multiline matching, etc.

(?<=\buser\s)\w+

This expression matches any word that follows "user " using a lookbehind assertion.


Summary:

PCRE are like the "advanced edition" of regular expressions — highly powerful, widely used, and very flexible. If you're working in an environment that supports PCRE, you can take advantage of rich pattern matching features inspired by Perl.


Link Juice

“Link Juice” is a term from Search Engine Optimization (SEO) that refers to the value or authority passed from one webpage to another through hyperlinks. This "juice" helps influence how well a page ranks in search engine results (especially Google).


In simple terms:

When website A links to website B, it passes on some of its credibility or authority — that’s the "link juice." The more trusted and relevant site A is, the more juice it passes.


Key factors that influence link juice:

  • Authority of the linking site (e.g., a major news site vs. a small blog)

  • Number of outgoing links: The more links on a page, the less juice each one gets.

  • Follow vs. Nofollow: Only dofollow links typically pass link juice. Nofollow links (with rel="nofollow") usually don’t.

  • Link placement: A link within the main content has more value than one in the footer or sidebar.

  • Relevance: A link from a site with related content carries more weight.


Example:

A backlink from Wikipedia to your site gives you a ton of link juice — Google sees it as a sign of trust. A link from an unknown or spammy site, on the other hand, might do little or even harm your rankings.

 


Scalable Vector Graphics - SVG

SVG stands for Scalable Vector Graphics. It's an XML-based file format used to describe 2D graphics. SVG allows for the display of vector images that can be scaled to any size without losing quality. It's widely used in web design because it offers high resolution at any size and integrates easily into web pages.

Here are some key features of SVG:

  • Vector-based: SVG graphics are made up of lines, curves, and shapes defined mathematically, unlike raster images (like JPEG or PNG), which are made of pixels.

  • Scalability: Since SVG is vector-based, it can be resized to any dimension without losing image quality, making it ideal for responsive designs.

  • Interactivity and Animation: SVG supports interactivity (e.g., via JavaScript) and animation (e.g., via CSS or SMIL).

  • Search engine friendly: SVG content is text-based and can be indexed by search engines, offering SEO benefits.

  • Compatibility: SVG files are supported by most modern web browsers and are great for logos, icons, charts, and other graphics.


Happy Path

The "Happy Path" (also known as the "Happy Flow") refers to the ideal scenario in software development or testing where everything works as expected, no errors occur, and all inputs are valid.

Example:

Let’s say you’re developing a user registration form. The Happy Path would look like this:

  1. The user enters all required information correctly (e.g., a valid email and secure password).

  2. They click “Register.”

  3. The system successfully creates an account.

  4. The user is redirected to a welcome page.

➡️ No validation errors, no server issues, and no unexpected behavior.


What is the purpose of the Happy Path?

  • Initial testing focus: Developers and testers often check the Happy Path first to make sure the core functionality works.

  • Basis for use cases: In documentation or requirements, the Happy Path is typically the main scenario before covering edge cases.

  • Contrasts with edge cases / error paths: Anything that deviates from the Happy Path (e.g., missing password, server error) is considered an "unhappy path" or "alternate flow."

 


Second Level Domain - SLD

The SLD (Second-Level Domain) is the part of a domain name that appears directly to the left of the Top-Level Domain (TLD).

Example:

In the domain
👉 example.com

  • .com is the TLD (Top-Level Domain)

  • example is the SLD (Second-Level Domain)


Domain Structure (from right to left):

Level Example
Top-Level Domain .com
Second-Level Domain example
Subdomain (optional) www. or e.g. blog.

More Examples:

Domain SLD TLD
google.de google .de
wikipedia.org wikipedia .org
meinshop.example.com example .com

Why it matters:

The SLD is usually the custom, chosen part of the domain—often representing a company name, brand, or project. It's the most recognizable and memorable part of a domain name.

 


Vite

Vite is a modern build tool and development server for web applications, created by Evan You, the creator of Vue.js. It is designed to make the development and build processes faster and more efficient. The name "Vite" comes from the French word for "fast," reflecting the primary goal of the tool: a lightning-fast development environment.

The main features of Vite are:

  1. Fast Development Server: Vite uses modern ES modules (ESM), providing an ultra-fast development server. It only loads the latest module, making the initial startup much faster than traditional bundlers.

  2. Hot Module Replacement (HMR): HMR works extremely fast by updating only the changed modules, without needing to reload the entire application.

  3. Modern Build System: Vite uses Rollup under the hood to bundle the final production build, enabling optimized and efficient builds.

  4. Zero Configuration: Vite is very user-friendly and doesn’t require extensive configuration. It works immediately with the default settings, supporting many common web technologies out-of-the-box (e.g., Vue.js, React, TypeScript, CSS preprocessors, etc.).

  5. Optimized Production: For production builds, Rollup is used, which is known for creating efficient and optimized bundles.

Vite is mainly aimed at modern web applications and is particularly popular with developers working with frameworks like Vue, React, or Svelte.

 


Partial Mock

A Partial Mock is a testing technique where only certain methods of an object are mocked, while the rest of the object retains its real implementation. This is useful when you want to stub or mock specific methods but keep others functioning normally.

When to Use a Partial Mock?

  • When you want to test a class but isolate certain methods.

  • When some methods are difficult to test (e.g., they have external dependencies), but others should retain their real logic.

  • When you only need to stub specific methods to control test behavior.

Example in PHP with PHPUnit

Suppose you have a Calculator class but want to mock only the multiply() method while keeping add() as is.

class Calculator {
    public function add($a, $b) {
        return $a + $b;
    }

    public function multiply($a, $b) {
        return $a * $b;
    }
}

// PHPUnit Test with Partial Mock
class CalculatorTest extends \PHPUnit\Framework\TestCase {
    public function testPartialMock() {
        // Create a Partial Mock for Calculator
        $calculator = $this->getMockBuilder(Calculator::class)
                           ->onlyMethods(['multiply']) // Only mock this method
                           ->getMock();

        // Define behavior for multiply()
        $calculator->method('multiply')->willReturn(10);

        // Test real add() method
        $this->assertEquals(5, $calculator->add(2, 3));

        // Test mocked multiply() method
        $this->assertEquals(10, $calculator->multiply(2, 3));
    }
}

Here, add() remains unchanged and executes the real implementation, while multiply() always returns 10.

Conclusion

Partial Mocks are useful when you need to isolate specific parts of a class without fully replacing it. They help make tests more stable and efficient by mocking only selected methods.


Salesforce Apex

Salesforce Apex is an object-oriented programming language specifically designed for the Salesforce platform. It is similar to Java and is primarily used to implement custom business logic, automation, and integrations within Salesforce.

Key Features of Apex:

  • Cloud-based: Runs exclusively on Salesforce servers.

  • Java-like Syntax: If you know Java, you can learn Apex quickly.

  • Tightly Integrated with Salesforce Database (SOQL & SOSL): Enables direct data queries and manipulations.

  • Event-driven: Often executed through Salesforce triggers (e.g., record changes).

  • Governor Limits: Salesforce imposes limits (e.g., maximum SOQL queries per transaction) to maintain platform performance.

Uses of Apex:

  • Triggers: Automate actions when records change.

  • Batch Processing: Handle large data sets in background jobs.

  • Web Services & API Integrations: Communicate with external systems.

  • Custom Controllers for Visualforce & Lightning: Control user interfaces.

 


Memcached

Memcached is a distributed in-memory caching system commonly used to speed up web applications. It temporarily stores frequently requested data in RAM to avoid expensive database queries or API calls.

Key Features of Memcached:

  • Key-Value Store: Data is stored as key-value pairs.

  • In-Memory: Runs entirely in RAM, making it extremely fast.

  • Distributed: Supports multiple servers (clusters) to distribute load.

  • Simple API: Provides basic operations like set, get, and delete.

  • Eviction Policy: Uses LRU (Least Recently Used) to remove old data when memory is full.

Common Use Cases:

  • Caching Database Queries: Reduces load on databases like MySQL or PostgreSQL.

  • Session Management: Stores user sessions in scalable web applications.

  • Temporary Data Storage: Useful for API rate limiting or short-lived data caching.

Memcached vs. Redis:

  • Memcached: Faster for simple key-value caching, scales well horizontally.

  • Redis: Offers more features like persistence, lists, hashes, sets, and pub/sub messaging.

Installation & Usage (Example for Linux):

sudo apt update && sudo apt install memcached
sudo systemctl start memcached

It can be used with PHP or Python via appropriate libraries.

 


Crawler

A crawler (also known as a web crawler, spider, or bot) is an automated program that browses the internet and analyzes web pages. It follows links from page to page and collects information.

Uses of Crawlers:

  1. Search Engines (e.g., Google's Googlebot) – Index web pages so they appear in search engine results.

  2. Price Comparison Websites – Scan online stores for the latest prices and products.

  3. SEO Tools – Analyze websites for technical errors or optimization potential.

  4. Data Analysis & Monitoring – Track website content for market research or competitor analysis.

  5. Archiving – Save web pages for future reference (e.g., Internet Archive).

How a Crawler Works:

  1. Starts with a list of URLs.

  2. Fetches web pages and stores content (text, metadata, links).

  3. Follows links on the page and repeats the process.

  4. Saves or processes the collected data depending on its purpose.

Many websites use a robots.txt file to control which content crawlers can visit or ignore.

 


Random Tech

Salesforce Apex


Learning-Apex-Salesforce.png