Skip to content

Instantly share code, notes, and snippets.

View itsliamjones's full-sized avatar

Liam Jones itsliamjones

View GitHub Profile
@itsliamjones
itsliamjones / create-thumbnails.sh
Created February 16, 2023 12:57
Bulk create square thumbnails from images with ImageMagick, trim but no crop
convert -define png:size=200x200 *.* \
-trim -quality 100 \
-thumbnail '128x128>' \
-background white -gravity center -extent 128x128 \
-set filename:base "%[basename]" "resized/%[filename:base].png"
@itsliamjones
itsliamjones / Configuration.php
Created January 16, 2019 09:04 — forked from xphere/Configuration.php
Recursive symfony/configuration
<?php
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* Helper function to create recursive nodes
*/
function recursiveNode(string $name, callable $callback)
@itsliamjones
itsliamjones / generator.php
Created September 4, 2018 14:08 — forked from tawfekov/generator.php
Doctrine2 Generate Entities form Existing Database
<?php
include '../vendor/autoload.php';
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();
// config
$config = new \Doctrine\ORM\Configuration();
@itsliamjones
itsliamjones / mysql-docker.sh
Created August 9, 2018 10:51 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@itsliamjones
itsliamjones / composer-global.md
Last active June 15, 2017 09:19
Global installation of PHP tools with Composer

To install a composer package globally, you run the usual require command, but with the addition of the global modifier. So to install PHPUnit, you would run:

$ composer global require phpunit/phpunit
$ composer global require phpunit/dbunit
$ composer global require phing/phing
$ composer global require phpdocumentor/phpdocumentor
$ composer global require sebastian/phpcpd
$ composer global require phploc/phploc
@itsliamjones
itsliamjones / WSDLSoapClientDebugger.php
Created June 12, 2017 08:57
Super simple class to pretty-print a WSDL's methods and types as HTML
<?php
/**
* Super simple class to pretty-print a WSDL's methods and types as HTML
*/
class WSDLSoapClientDebugger
{
/**
* Instance of SoapClient
*
@itsliamjones
itsliamjones / sqlite-to-csv.sh
Last active February 10, 2017 09:42
Export all tables from an SQLite database to CSVs
#!/usr/bin/env bash
# obtains all data tables from database
TS=`sqlite3 $1 "SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%';"`
# exports each table to csv
for T in $TS; do
sqlite3 $1 <<!
.headers on
@itsliamjones
itsliamjones / ruleset.xml
Created December 1, 2016 12:20 — forked from gsherwood/ruleset.xml
PSR2 with tabs instead of spaces
<?xml version="1.0"?>
<ruleset name="MyStandard">
<description>PSR2 with tabs instead of spaces.</description>
<arg name="tab-width" value="4"/>
<rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
@itsliamjones
itsliamjones / click-register.js
Last active August 15, 2016 15:56
Example register for click delegation
function ClickRegister(global, parent, debug) {
var parent = parent || document,
debug = !!debug,
register = [];
var action = function (event) {
var target = event.target || event.srcElement;
if (debug) {
console.group("click register debugging");
@itsliamjones
itsliamjones / curl-repo.txt
Created August 11, 2016 11:14
Use cURL to download a GitHub repository, useful for building docker images
curl -sL https://github.com/user-or-org/repo/archive/sha1-or-ref.tar.gz | tar xz
Replace user-or-org, repo, and sha1-or-ref accordingly.
If you want a zip file instead of a tarball, specify .zip instead of .tar.gz suffix.