Skip to content

Instantly share code, notes, and snippets.

@srgoogleguy
srgoogleguy / array-visualization.md
Last active April 19, 2023 06:32
Array Visualizations in PHP

Visualizing Array Operations in PHP

It's important to recognize that in PHP an array does not always behave like a traditional array. It's actually more representative of an ordered hashmap. Thus it maintains order, but consists of key/value pairs. A key, in a PHP array, is always unique, but can be either an integer or a string. If the string key can be cast to an integer then PHP will carry out this operation implicitly. Also, array keys do not determine the order of elements in a PHP array.

With this in mind, we can better understand how different operations, like diff, intersect, union, and merge, would be carried out on a native PHP array. Some of these operations rely on the array keys and others on the values in the array.


Table of Contents

@schmengler
schmengler / add-checkout-form-key.sh
Last active September 2, 2022 16:23
Magento SUPEE-9767 Checkout Form Key Theme Patch
find -L app/design/frontend -regex '.*\(shipping\|billing\|shipping_method\|payment\).phtml' -exec grep -L formkey {} \; \
| xargs sed -i 's/<\/form>/<?php echo $this->getBlockHtml("formkey") ?><\/form>/g'
find -L skin/frontend -name 'opcheckout.js' -exec grep -L form_key {} \; \
| xargs sed -i 's/if (elements\[i\].name=='\''payment\[method\]'\'') {/if (elements[i].name=='\''payment[method]'\'' || elements[i].name == '\''form_key'\'') {/g'
@0livare
0livare / .gitconfig
Last active January 27, 2024 14:36
My git alias list. Running 'git alias' will pretty-print these commands to the terminal.
# Some options that may or may not be applicable to you
[user]
name = Zach Olivare
email = zach@olivare.net
[push]
default = upstream
[core]
autocrlf = input # Force replacing CRLF line endings with LF
ignorecase = false
# editor = code --wait
(MySQLDUMP_DATABASE=$(sed -n 's/^.*<dbname><!\[CDATA\[\(.*\)\]\]><\/dbname>.*/\1/p' app/etc/local.xml | head -n1) \
&& \
mysqldump -h$(sed -n 's/^.*<host><!\[CDATA\[\(.*\)\]\]><\/host>.*/\1/p' app/etc/local.xml | head -n1) \
-u$(sed -n 's/^.*<username><!\[CDATA\[\(.*\)\]\]><\/username>.*/\1/p' app/etc/local.xml | head -n1) \
-p$(sed -n 's/^.*<password><!\[CDATA\[\(.*\)\]\]><\/password>.*/\1/p' app/etc/local.xml | head -n1) \
$MySQLDUMP_DATABASE \
--ignore-table=${MySQLDUMP_DATABASE}.core_cache \
--ignore-table=${MySQLDUMP_DATABASE}.core_cache_tag \
--ignore-table=${MySQLDUMP_DATABASE}.log_url \
--ignore-table=${MySQLDUMP_DATABASE}.log_url_info \
@7ochem
7ochem / git_mass_file_commands.sh
Last active December 11, 2015 17:18
Different shell command to mass add files to your git commit
# This is the base of the commands below. This adds all files appearing in git status:
git status -s |grep -E "^.[^D] " |sed "s/^.. //" |xargs git add
git status -s |grep -E "^.D " |sed "s/^.. //" |xargs git rm | wc -l
# For a simple add all (no deletions) you probably want to use this
# (add all files * and all dot files .[!.]*, asterix won't match dot files):
git add * .[!.]*
# These commands rely on the short GIT status output "git status -s"
# Short status line syntax is "XY myfile"
# X (first char) displays the status for a file in the staging area
@Rud5G
Rud5G / gitcommands.sh
Last active February 20, 2017 10:36
Git Commands
## config
# user
git config --global user.name "Rudger "
git config --global user.email ""
# color
git config --global color.ui true
# vim editor
git config --global core.editor vim
@7ochem
7ochem / .bashrc
Last active October 13, 2015 07:27 — forked from Rud5G/gist:3496231
.bashrc
## here is the original ~/.bashrc
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
@Rud5G
Rud5G / .gitignore
Last active January 14, 2019 16:06
magento 1 gitignore
# magento gitignore from htdocs
#
# https://gist.github.com/Rud5G/4148997
htdocs/app/etc/local.xml
htdocs/media/*
!htdocs/media/.htaccess
htdocs/var/*
!htdocs/var/.htaccess
@7ochem
7ochem / .vimrc
Last active October 13, 2015 02:18 — forked from Rud5G/vimrc.vim
.vimrc
" Vim RC
" Based upon Rud5G .vimrc
" @link https://gist.github.com/Rud5G
" @link https://gist.github.com/2316255
"
" Below some links that could help understand and edit this file
" @link http://vimdoc.sourceforge.net/htmldoc/options.html
" @link http://www.eng.hawaii.edu/Tutor/vi.html [BROKEN!]
" -> {@link http://www.linuxfocus.org/English/May2000/article153.shtml}
"
@Rud5G
Rud5G / vimrc.vim
Last active September 28, 2020 22:21
dotfile: .vimrc
"
" https://gist.github.com/Rud5G/2316255
"
" mkdir -p ~/.vim/{backup,syntax,tmp}
"
set autoindent " lines following an indented line will have the same indentation as the previous line.
set expandtab " resplace tabs with actuall spaces
set shiftwidth=4 " softtabs width 4.
set tabstop=4 " tabs are 4 spaces