Skip to content

Instantly share code, notes, and snippets.

View ankurk91's full-sized avatar
💤
Slow to respond

Ankur K ankurk91

💤
Slow to respond
View GitHub Profile
@ilyasozkurt
ilyasozkurt / FindRiskyNumericFields.php
Last active January 1, 2023 08:10
FindRiskyNumericFields.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class FindRiskyFieldsOnDatabases extends Command
{
/**
@vncsna
vncsna / bash_strict_mode.md
Created June 6, 2021 01:59 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@sindresorhus
sindresorhus / esm-package.md
Last active May 4, 2024 15:48
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@maelvls
maelvls / README.md
Last active April 29, 2024 05:49
Ubuntu, libsecret, git-credential-helper

Dealing with secrets

GNOME comes with libsecret. You can use libsecret to store your git credentials:

sudo apt install libsecret-1-0 libsecret-1-dev libglib2.0-dev
sudo make --directory=/usr/share/doc/git/contrib/credential/libsecret
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
@Jiab77
Jiab77 / real-time-php-fpm-status.md
Last active February 29, 2024 12:48
Real-time PHP-FPM Status

Real-time PHP-FPM Status

This gist will explain you how to enable an undocumented feature of PHP-FPM which will give a real-time performance stats.

Everybody knows the famous phpinfo() and the page it generates, right? Then the real-time PHP-FPM status page design is very similar.

image

Some informations from the top are not displayed to avoid security issues.

Enable PHP-FPM Status

@laravel-shift
laravel-shift / .php-cs-fixer.php
Last active April 9, 2024 14:08
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@pepeloper
pepeloper / ProfileJsonResponse.php
Created December 15, 2017 08:56
Middleware to use Laravel debugbar on JSON responses.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\JsonResponse;
class ProfileJsonResponse
{
/**
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 4, 2024 17:49
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@Jeff-Russ
Jeff-Russ / PHP: numeric array keys.md
Last active January 27, 2023 14:06
PHP: numeric array keys

PHP's Numeric & String Key Type Juggling

Arrays in PHP treat integer and string integers synonymously. If you set $a['1'] = '1' and access $a[1] you will get '1'. This is because php juggled your string key to an integer before assigning it; the assigment was actually made to an integer key. PHP also juggles in the process of accesssing too which means if you try to access [1] with ['1'] it will work. Therefore there is no real distinction between string integers and real integer, you can use them interchangably.

Remember that '1.0' does not equal '1' or 1 with strict comparison. This is true of array keys as well: you can have both ['1.0'] and ['1'] and they would be different elements but not [1] and ['1'].

@RuGa
RuGa / massInsertOrUpdate.php
Last active April 12, 2024 16:54
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows