Skip to content

Instantly share code, notes, and snippets.

View mikedfunk's full-sized avatar

Mike Funk mikedfunk

View GitHub Profile
coverage
build
<project name="saatchiart" default="check" basedir=".">
<target name="clean" description="Clean up and create artifact directories">
<delete dir="${project.basedir}/build"/>
<mkdir dir="${project.basedir}/build/coverage"/>
<mkdir dir="${project.basedir}/build/logs"/>
<mkdir dir="${project.basedir}/build/code-browser"/>
<mkdir dir="${project.basedir}/build/pdepend"/>
</target>
<target name="lint" description="Perform syntax check of sourcecode files">
@mikedfunk
mikedfunk / array_only_keys.php
Created February 4, 2016 22:51
Filter an array by whitelist
<?php
$whitelist = ['key1', 'key2'];
$filterme = ['key1' => 1, 'skipme' => 2];
$filtered = array_filter(array_intersect_key($filterme, array_flip($whitelist)));
@mikedfunk
mikedfunk / .pre-commit-config.yaml
Last active February 6, 2016 03:12
yelp pre-commit hook example
- repo: git@github.com:pre-commit/pre-commit-hooks
sha: v0.4.2
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- repo: git@github.com:hootsuite/pre-commit-php.git
@mikedfunk
mikedfunk / find_large_files.sh
Created January 13, 2016 02:40
find large files in linux
cd /
sudo du -hsx * | sort -rh | head -10
@mikedfunk
mikedfunk / find_table_with_column_by_name.sql
Created December 29, 2015 00:28
search all tables for matching column names
SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%sku%'
AND TABLE_SCHEMA='zed';
@mikedfunk
mikedfunk / array_only_keys.php
Last active December 18, 2015 18:57
array only keys
<?php
$onlyKeys = ['ship_width', 'ship_height', 'width', 'height', 'depth', 'ship_depth'];
$toCheck = array_intersect_key($artwork, array_flip($onlyKeys));
@mikedfunk
mikedfunk / pdo_quick_assoc_array_insert.php
Created December 10, 2015 23:52
pdo insert assoc array
<?php
// @link http://stackoverflow.com/questions/13507496/pdo-php-insert-into-db-from-an-associative-array
$keys = array_keys($a);
$sql = "INSERT INTO user (".implode(", ",$keys).") \n";
$sql .= "VALUES ( :".implode(", :",$keys).")";
$q = $this->dbConnection->prepare($sql);
return $q->execute($a);
@mikedfunk
mikedfunk / guzzlehttp_example.php
Created October 21, 2015 20:59
How to use GuzzleHTTP 6.1
<?php
// in a method...
$this->client = new GuzzleHttp\Client(['base_uri' => 'my_base_uri']);
$config = [
'auth' => [$this->username, $this->password],
'headers' => [
'x-app-id' => $this->appId,
],
@mikedfunk
mikedfunk / port_check.sh
Created October 5, 2015 23:32
what's running on this port?
#!/bin/bash
sudo lsof -i :80 # checks port 80