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
@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
{
/**
@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
{
/**
@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'].

@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@magnusbae
magnusbae / git-stop-tracking-remote-branch.md
Created April 8, 2014 20:05
How to make Git stop track a remote branch without deleting the remote branch.

You don't have to delete your local branch.

Simply delete your remote tracking branch:

git branch -d -r origin/<remote branch name> (This will not delete the branch on the remote repo!)

See "Having a hard time understanding git-fetch"

there's no such concept of local tracking branches, only remote tracking branches.

@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',
@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
@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
@hofmannsven
hofmannsven / README.md
Last active May 3, 2024 15:30
Git CLI Cheatsheet
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active May 5, 2024 13:30
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx