Skip to content

Instantly share code, notes, and snippets.

View stilliard's full-sized avatar
🐝

Andrew Stilliard stilliard

🐝
View GitHub Profile
@stilliard
stilliard / page-break-inside.jquery.js
Created September 28, 2011 13:55
CSS "page-break-inside" jQuery fix when using pdfmyurl.com
// applied to elements with class of "dont-break"
$('.dont-break').wrap('<table style="page-break-inside: avoid; width: 100%;" />');
@stilliard
stilliard / fullNameToFirstName.php
Created April 19, 2012 12:47
PHP - Get a users first name from the full name
<?php
/**
* Get a users first name from the full name
* or return the full name if first name cannot be found
* e.g.
* James Smith -> James
* James C. Smith -> James
* Mr James Smith -> James
* Mr Smith -> Mr Smith
@stilliard
stilliard / batman.func.js
Created June 22, 2012 10:16
batman function for console
(function batman(){
return Array(16).join({}-1)+" "+arguments.callee.name;
})();
@stilliard
stilliard / jsonToTable.php
Created October 9, 2012 13:24
JSON to HTML table
<?php
/**
* JSON data to html table
*
* @param object $data
*
*/
function jsonToTable ($data)
{
@stilliard
stilliard / invertMultidimensionalArray.php
Last active December 11, 2015 13:29
Multidimensional array function i seem to use on rare occasions, maybe someone knows a faster way?
<?php
/**
* Invert a multidimensional array
* @param array $origArray
* @return array
*/
function invertMultidimensionalArray($origArray) {
$invertedArray = array();
foreach ($origArray as $i => $sub) {
foreach ($sub as $key => $val) {
@stilliard
stilliard / dout.php
Created January 20, 2014 10:29
Dump the given value to stdout
<?php
/**
* Dump the given value to stdout
*
* @param mixed $value
* @return void
*/
function dout($value)
{
@stilliard
stilliard / apache-project.dev.conf
Last active August 29, 2015 14:00
simple-nginx-proxy-to-apache
<VirtualHost *:8080>
ServerName PROJECT_NAME.dev
ServerAlias www.PROJECT_NAME.dev
DocumentRoot PROJECT_DIR
<Directory "PROJECT_DIR">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
@stilliard
stilliard / cleanup-docker.sh
Created May 29, 2014 17:46
cleanup-docker
# Delete old docker containers
sudo docker rm `sudo docker ps --no-trunc -a -q`
# Delete old docker images
sudo docker rmi $(sudo docker images -a | grep -P '([A-z0-9_\-<>\/]+)\s+([A-z0-9_\-<>\/]+)\s+([A-z0-9_\-<>\/]+).*$' | awk '{print $3}')
@stilliard
stilliard / git-alias-migrate-to
Last active August 29, 2015 14:03
Git checkout and auto ruckusing migrations and composer composer setup!
git config alias.migrate-to '!f() { make checkout BRANCH=$1; }; f'
@stilliard
stilliard / select_all_indexes_on_all_tables.sql
Last active August 29, 2015 14:28
Select all indexes from all tables in a given MySQL databbase (in this example its called my_db)
SELECT table_name, index_name, GROUP_CONCAT(column_name)
FROM information_schema.statistics
WHERE table_schema = 'my_db'
AND non_unique = 1
GROUP BY table_name, index_name ;