Skip to main content

Posts

Composer Install Force PHP

Install composer dependencies ignoring PHP version When working with PHP projects, you often encounter situations where the required PHP version for a package is slightly different from the one you have installed locally. While it's generally recommended to stick to the specified version, there are cases where minor version differences might not be critical. In such scenarios, you can instruct Composer to ignore the platform requirements and proceed with the installation. Composer install ignoring PHP version Composer provides a handy flag "--ignore-platform-reqs" that allows you to bypass platform checks, including PHP version requirements. This can be particularly useful when you're confident that the minor version difference won't affect the package's functionality in your project. For instance, let's say a package you want to install requires PHP 8.2, but you have PHP 8.3 installed. In this case, you can use the following command to i
Recent posts

Neovim Leader Menu

How to Make a Menu in Neovim How to Make a Menu in Neovim In Neovim leader key pull up a menu, it is the which-key plugin. I saw many videos where people use a menu in Neovim. They just press the leader key and a menu pops up. I wanted to have that too. I wondered which component of Neovim is responsible for that. I found out that it is the which-key plugin: https://github.com/folke/which-key.nvim Cases where a menu is useful in Neovim Neovim has already a bunch of "commands". Why would I need a menu? Useful when you want to group a set of commands you often use together. Also helpful when the command name is hard to remember: use the leader key and a combo of keys to get to the command. How to write a menu tree in Neovim configuration I use code-ai.nvim plugin to call AI to write code for me. I have defined a bunch of commands in my configuration fi

ChatGPT Gemini REST API

Using direct AI REST API instead of SDK When working with large language models (LLMs) like ChatGPT and Gemini, developers often turn to Software Development Kits (SDKs) for streamlined integration. While SDKs offer convenience, there are compelling reasons to consider using the direct REST API, especially when starting new implementations like plugins or SDKs for a new language. This blog post will explore the advantages of this approach. ChatGPT and Gemini SDK SDKs simplify the process of interacting with LLMs. They provide pre-built functions and handle low-level details, making it easier to send prompts and receive responses. Let's look at examples for ChatGPT and Gemini: ChatGPT SDK The ChatGPT SDK for Node.js is available at https://github.com/openai/openai-node . Here's how to use it: import OpenAI from 'openai'; const client = new OpenAI({apiKey: process.env['OPENAI_API_KEY']}); async function main() { const chatCompletion =

Undefined global vim

Defining vim as global outside of Neovim When developing plugins for Neovim, particularly in Lua, developers often encounter the "Undefined global vim" warning. This warning can be a nuisance and disrupt the development workflow. However, there is a straightforward solution to this problem by configuring the Lua Language Server Protocol (LSP) to recognize 'vim' as a global variable. Getting "Undefined global vim" warning when developing Neovim plugin While developing Neovim plugins using Lua, the Lua language server might not recognize the 'vim' namespace by default. This leads to warnings about 'vim' being an undefined global variable. These warnings are not just annoying but can also clutter the development environment with unnecessary alerts, potentially hiding other important warnings or errors. Defining vim as global in Lua LSP configuration to get rid of the warning To resolve the "Undefined global vi

Asterisk catch e164 patterns

Catching e164 patterns with Asterisk In the realm of telephony, ensuring seamless call routing and processing hinges on the ability to accurately identify and handle phone numbers in a standardized format. Enter e164, a widely adopted standard that provides a consistent structure for international telephone numbers. This blog post delves into the intricacies of working with e164 patterns within the context of Asterisk, a powerful open-source communication platform. What is e164? E164 format is a standard for the international telephone numbering plan that ensures each number is unique. It follows a specific structure, starting with a "+" sign, followed by the country code, and finally the local telephone number. For instance, the e164 format for a French number could be +33123456789. Why do e164 is not matched by "_X."? Let's consider a scenario

Symfony JSON Login

Symfony JSON Login Context Most Web application use a "form login", which is rendered with Twig. This is fine when the application is entirely server-side rendered. But when the application is a Single Page Application (SPA), I mean when the backend is a REST API, the form login is not suitable. I need then a JSON login mechanism. Looking at the Symfony documentation, I found the JSON Login mechanism. But this documentation is not complete and needs more steps to be implemented. JSON Login with in memory Users Here, I am going to start from a bare Symfony application and implement the JSON login mechanism, and the users are not going to be stored in a database but in memory. More precisely, I am going to store users in the "config/packages/security.yaml" file. Step 1: Create a new Symfony application symfony new symfony-json-login cd symfony-json-login

TMux cheatsheet

This is my TMUX cheat sheet Sessions Create new named session tmux new -s mihamina List sessions tmux ls Attach to a session tmux attach -t mihamina Detach from a session Ctrl+b d Windows Create new window Ctrl+b c List windows Ctrl+b w Rename window Ctrl+b , Switch to window Ctrl+b 0 Close window Ctrl+b &