Skip to content

Instantly share code, notes, and snippets.

View bhaidar's full-sized avatar

Bilal Haidar bhaidar

View GitHub Profile
@bhaidar
bhaidar / php-pools.md
Created September 25, 2024 05:44 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
Here is a quick way to add authentication logging to Laravel.
1. Modify app/Providers/EventServiceProvider.php and add lines 16 through 32 of the example file in this GIST.
2. Create a new file app/Listeners/LogActivity.php and copy the contents of the file below into that file.
3. Enjoy logging.
@bhaidar
bhaidar / google-recaptcha.md
Created December 15, 2023 20:30 — forked from babacarcissedia/google-recaptcha.md
Add google recaptcha to website

Opinionated code Laravel code for adding recaptcha on website. Bot protection especially on open form with user authentication.

  1. Create blade component for ease of reuse
resources/views/components/input/captcha.blade.php

@props([
    'id',
    'name',
@bhaidar
bhaidar / .eslintrc.js
Created December 5, 2023 15:35 — forked from onlime/.eslintrc.js
ESLint/Prettier config for Vue 3 in VS Code
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
'prettier'
@bhaidar
bhaidar / print.css
Created October 26, 2023 19:04 — forked from anonymous/print.css
/**
* Print Stylesheet fuer Deinewebsite.de
* @version 1.0
* @lastmodified 16.06.2016
*/
@media print {
/* Inhaltsbreite setzen, Floats und Margins aufheben */
/* Achtung: Die Klassen und IDs variieren von Theme zu Theme. Hier also eigene Klassen setzen */
@bhaidar
bhaidar / AppServiceProvider.php
Created October 3, 2023 07:23
Laravel macro to split a name into a first_name and last_name
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
@bhaidar
bhaidar / Setup_Laravel_App
Last active July 2, 2023 15:37
Setting up a new Laravel application
## Setting up a Laravel application
I started by creating a new Laravel app. There are several methods for creating a new Laravel app. I chose the Docker-based one using the Laravel Sail package. You can read more about Laravel installation by following this URL (https://laravel.com/docs/10.x/installation).
Choose the method that best suits you. Before you start, make sure you have Docker running on your computer.
I'm using a MacBook Pro. I start by running this command:
curl -s "https://laravel.build/laravel-app" | bash

Learning Plan for Test Driven Development (TDD)

These learning resources primarily focus on Test Driven Development (TDD).

  • There is an emphasis on learning using PHP, Laravel and PHPUnit.
  • All these resources are free (at the time of writing)
@bhaidar
bhaidar / README.md
Created March 5, 2023 20:44 — forked from eusonlito/README.md
Laravel Auth and Session without database. Using a remote API as Auth and Data provider.

This is an example of a web that uses a remote API as a database wrapper.

The remote API is stateless and the web uses cookies to maintain session persistence.

The API authentication endpoint returns a TOKEN that allows the web to make each request to the API with the user authentication header.


Este es un ejemplo de web que usa una API remota como wrapper de base de datos.

@bhaidar
bhaidar / useSpeechRecognition.js
Created February 25, 2023 14:37
Speech Recognition Composable for Vue and Composable API
import { ref,watch,shallowRef,unref } from 'vue'
export function useSpeechRecognition({lang,continuous,interimResults}) {
const isListening = ref(false)
const isFinal = ref(false)
const result = ref('')
const error = shallowRef(undefined)
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition