Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / .gitattributes
Last active Sep 26, 2022
Prevent Git Managing CSV Line Endings
View .gitattributes
# Prevent Git managing line endings of CSV files, otherwise it changes CRLF to LF on commit and checkout.
# This is useful if you're working with CSV files that come from legacy systems and have differing line endings.
#
# You can see view how Git manages line endings with this command: git ls-files --eol | grep .csv
#
# @see: https://git-scm.com/docs/gitattributes
# @see: https://stackoverflow.com/questions/17628305/windows-git-warning-lf-will-be-replaced-by-crlf-is-that-warning-tail-backwar
# @see: https://stackoverflow.com/questions/42667996/enforce-core-autocrlf-input-through-gitattributes
# @see: https://stackoverflow.com/questions/20496084/git-status-ignore-line-endings-identical-files-windows-linux-environment
# @see: https://stackoverflow.com/questions/21822650/disable-git-eol-conversions
@ziadoz
ziadoz / install.sh
Last active Sep 26, 2022
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
View install.sh
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# https://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# https://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# https://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# https://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE`
@ziadoz
ziadoz / MemberOfMacro.php
Created Nov 5, 2021
MySQL 8.0 JSON MEMBER OF Laravel Eloquent Macro
View MemberOfMacro.php
<?php
use Illuminate\Database\Query\Builder;
$memberOf = function ($value, string $column, string $path = '$', $boolean = 'and') {
return $this->whereRaw(
sprintf(
'? MEMBER OF(JSON_EXTRACT(%s, "%s"))',
$this->getGrammar()->wrap($column),
$path
),
@ziadoz
ziadoz / composer_path.json
Last active Aug 31, 2022
Composer Using Local Repositories and Branches
View composer_path.json
{
"repositories": [
{
"type": "path",
"url": "../relative/project/path"
}
],
"require": {
"${project}": "dev-${branch}"
}
@ziadoz
ziadoz / repl.php
Last active Aug 16, 2022
Simple PHP REPL
View repl.php
#!/usr/bin/env php
<?php
if (php_sapi_name() !== 'cli') {
exit(1);
}
function input() {
return fgets(STDIN);
}
@ziadoz
ziadoz / mp3-2-m4a.sh
Created Jan 25, 2022
FFMPEG: MP3 to M4A
View mp3-2-m4a.sh
#!/usr/bin/env bash
for file in *.mp3; do ffmpeg -i $file -c:a aac -vn ${file%.mp3}.m4a; done
@ziadoz
ziadoz / jquery-capture-css3-transition-end-event.js
Created Jul 9, 2012
jQuery Capture CSS3 Transition End Event
View jquery-capture-css3-transition-end-event.js
$(document).ready(function() {
$('div').on('transitionend MSTransitionEnd webkitTransitionEnd oTransitionEnd', function(event) {
// Do stuff after transition
});
});
@ziadoz
ziadoz / backup-restore-mysql-docker-volume.sh
Created Jul 29, 2022
Backup and Restore MySQL Docker Volume
View backup-restore-mysql-docker-volume.sh
#!/usr/bin/env bash
# @see: https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes
# @see: https://jareklipski.medium.com/backup-restore-docker-named-volumes-350397b8e362
# @see: https://www.spherex.dev/backing-up-docker-volumes/
# The name of the volume to backup/restore:
VOLUME="my-db"
# Backup the Docker Volume to an archive:
docker run --rm --volume $VOLUME:/var/lib/mysql -v $(pwd):/backup alpine:latest sh -c "tar cvf /backup/$VOLUME.tar /var/lib/mysql"
@ziadoz
ziadoz / awesome-php.md
Last active Jul 25, 2022
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
View awesome-php.md
@ziadoz
ziadoz / Dockerfile
Last active Jun 30, 2022
Install glibc on PHP Alpine Docker Image
View Dockerfile
FROM php:8-cli-alpine
# @see: @see: https://stackoverflow.com/a/65969295
RUN apk --no-cache add binutils curl \
&& GLIBC_VER=$(curl -s https://api.github.com/repos/sgerrand/alpine-pkg-glibc/releases/latest | grep tag_name | cut -d : -f 2 | tr -d \",' ') \
&& curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk \
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \
&& apk add --no-cache \
glibc-${GLIBC_VER}.apk \