Skip to content

Instantly share code, notes, and snippets.

View danlamanna's full-sized avatar
🏠
Working from home

Dan LaManna danlamanna

🏠
Working from home
View GitHub Profile
@danlamanna
danlamanna / gist:2772089
Created May 22, 2012 22:42
Sample Project Definition
{
"projects": {
"sample_project": {
"type": "wordpress",
"repos": {
@danlamanna
danlamanna / imperial_spider.py
Created June 5, 2012 18:51
Scrapy crawling, pyEnchant spell checking.
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from spellchecker.items import SpellcheckItem
from BeautifulSoup import BeautifulSoup
import re,urllib,enchant
from string import strip
@danlamanna
danlamanna / Burst_Logger.php
Created June 6, 2012 13:34
Simple WP Logging plugin.
<?php
// No trailing slash
define('BURST_LOG_PATH', ABSPATH . 'wp-content');
// Define which get logged in Burst::$_burst_log_levels
define('BURST_INFO', 1);
define('BURST_DEBUG', 2);
define('BURST_CRITICAL', 3);
@danlamanna
danlamanna / gist:3056144
Created July 5, 2012 20:08
Code is Poetry
/**
* Generate rewrite rules from a permalink structure.
*
* The main WP_Rewrite function for building the rewrite rule list. The
* contents of the function is a mix of black magic and regular expressions,
* so best just ignore the contents and move to the parameters.
*
* @since 1.5.0
* @access public
*
(defun php-closing-paren()
"Adds a closing paren to the end of the current line, but before any semicolons, if present."
(interactive)
(save-excursion
(setq now-until-eol (substring (buffer-string) (point) (line-end-position)))
(whitespace-cleanup)
(move-end-of-line nil)
(while (eq (char-before (point)) 59)
(backward-char 1))
(insert ")")))
// Check dependencies
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
if (!is_plugin_active('gravityforms/gravityforms.php')) {
add_action('admin_notices', function() {
echo '<div class="error"><p>This plugin requires the Gravity Forms plugin to be enabled, and is not currently running.</p></div>';
});
if (class_exists('Burst')) {
Burst::log("Gravity Forms dependency unmet.", BURST_CRITICAL);
}
@danlamanna
danlamanna / gist:3927751
Created October 21, 2012 17:40
Evaluating defuns in list definitions
(defun iso-8601-now()
"Insert current date-time string in full ISO 8601 format.
Example: 2010-11-29T23:23:35-08:00"
(when (region-active-p)
(delete-region (region-beginning) (region-end)))
@danlamanna
danlamanna / gist:4138527
Created November 24, 2012 05:13
Ignoring prompt with sql-mysql in emacs
;; add our own mysql product
(eval-after-load "sql"
'(add-to-list 'sql-product-alist
'(mysql-noprompt
:name "MySQL"
:font-lock sql-mode-mysql-font-lock-keywords
:sqli-login nil
:sqli-program sql-mysql-program
:sqli-options sql-mysql-options
:sqli-comint-func sql-comint-mysql
#!/bin/bash
# skip returns of "No syntax errors..." or "Errors parsing... "
linterrors=$((find wp-content/themes wp-content/mu-plugins -type f -name "*.php" -exec php -l {} \; | egrep -v "^(No|Errors)") 2>&1)
if [ "$linterrors" != "" ]; then
echo "[PRE-COMMIT-ERROR]: Failed PHP Lint Check."
echo "---------------------------------------------"
echo $linterrors
exit 1
@danlamanna
danlamanna / hooks.php
Created December 11, 2012 15:19
Automating Rackspace email account creation.
public static function _setupRackspace($name, $domain, array $emails=array()) {
$rs = new ApiServer();
// Use existing customer, or create them as new
if (!($customer = self::_customerExists($name))) {
$customer = (object)json_decode($rs->post('/customers', array('name' => $name), 'application/json'));
}
// Add domain w/ mailboxes
$rs->post(sprintf('/customers/%d/domains/%s', $customer->accountNumber, $domain),