Skip to content

Instantly share code, notes, and snippets.

View bhowe's full-sized avatar

Blake Howe bhowe

View GitHub Profile
/**
* US STATE RELATED FUNCTIONS
**/
/**
* Return an array af state names and abbreviations
*
* @return (array) state names and abbreviations
**/
@bhowe
bhowe / constant contact ruby
Created April 19, 2014 01:15
Add a individual contact for constant contact using httparty in Ruby
require 'rubygems'
require 'bundler/setup'
require 'open-uri'
require 'httparty'
class Foo
def self.do_it
@bhowe
bhowe / generate_a_csv
Created April 19, 2014 16:01
generate a csv from array. It will handle escaping your data etc
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
@bhowe
bhowe / Deployment
Last active August 29, 2015 14:00 — forked from oodavid/README.md
# Deploy your site with git
This gist assumes:
* you have a local git repo
* with an online remote repository (github / bitbucket etc)
* and a cloud server (Rackspace cloud / Amazon EC2 etc)
* your (PHP) scripts are served from /var/www/html/
* your webpages are executed by apache
* apache's home directory is /var/www/
@bhowe
bhowe / download word document docx headers
Last active August 29, 2015 14:00
download word document docx headers
public function DownloadDocx()
{
$this->_extension = "docx";
$args = func_get_args();
$newName = trim($args[0]);
ob_flush();
if (!empty($newName)) {
$fileName =$_SERVER['DOCUMENT_ROOT'] . '/wills/docs/' .$newName;
} else {
throw new Exception("Invalid document name");
@bhowe
bhowe / gist:6206fa704a906a56f1d3
Created May 3, 2014 20:36
trigger google analytics event in onclick
<button class="download-pdf" onclick="document.location.href='doc.pdf';_gaq.push(['_trackEvent', 'PDFs', 'Download', 'Doc Name']);"> Doc Name </button>
@bhowe
bhowe / gist:b3fc6cdedfd0d4a15255
Last active August 29, 2015 14:01
Git ignore for wordpress
#==================#
# General WP stuff #
#==================#
.htaccess
wp-content/uploads/
wp-admin/
wp-includes/
wp-content/plugins/
wp-content/blogs.dir/
@bhowe
bhowe / generic-git-ignore
Last active August 29, 2015 14:01
Starter Git Ignore for Most projects
## OS and Utility Stuff ##
#==================#
# OS Files #
#==================#
.DS_Store
.DS_Store?
._*
.Spotlight-V100
@bhowe
bhowe / format-json-so-its-readable
Last active August 29, 2015 14:01
Format JSON so its readable with a one liner on any unix box
cat non_search_logs.json | python -m json.tool > formatted.json 
@bhowe
bhowe / shell-commands-to-look-for-wordpress-hacks
Last active August 29, 2015 14:01
Common Shell commands to help track down Wordpress hacks
Find common problems in wordpress hacks
Finds eval or base64 decode
grep -ri "eval" [path]
grep -ri "base64_decode" [path]
Recently modified files
find -type f -ctime -0 | more