Skip to content

Instantly share code, notes, and snippets.

View robhurring's full-sized avatar
🍻
cheers

Rob Hurring robhurring

🍻
cheers
View GitHub Profile
# Search term parser from https://gist.github.com/1477730
# Modified to allow periods (and other non-letter chars) in unquoted field values
# and field names.
#
# Helper class to help parse out more advanced saerch terms
# from a form query
#
# Note: all hash keys are downcased, so ID:10 == {'id' => 10}
# you can also access all keys with methods e.g.: terms.id = terms['id'] = 10
# this doesn't work with query as thats reserved for the left-over pieces
@robhurring
robhurring / USAGE
Created November 12, 2011 16:06
Update or export wordpress using Thor from the command line : http://proccli.com/update-wordpress-ruby-thor
1. install thor gem
> gem install thor
2. add wordpress script to your wordpress install root and chmod it
> chmod a+x wordpress
3. update wordpress
> ./wordpress update
4. export wordpress (php must have CLI support)
@robhurring
robhurring / Capfile
Created July 6, 2011 19:43
Wordpress with Capistrano
default_run_options[:pty] = true
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
set :application, 'wordpress'
set :deploy_to, "/var/sites/#{application}"
set :use_sudo, false
set :user, 'server-username'
server 'example.com', :web, :app, :db
@robhurring
robhurring / fix.diff
Created April 24, 2011 17:20
MySQLi PHP 5.3 compile error solution
Index: ext/mysqli/php_mysqli_structs.h
===================================================================
--- ext/mysqli/php_mysqli_structs.h (revision 301474)
+++ ext/mysqli/php_mysqli_structs.h (working copy)
@@ -54,6 +54,7 @@
#define WE_HAD_MBSTATE_T
#endif
+#define HAVE_ULONG 1
#include <my_global.h>
.clearfix:after {
content: ".";
display: block;
height: 0;
font-size: 0;
clear: both;
visibility: hidden;
}
.clearfix {display: inline-block;}
/* Hides from IE5/Mac \*/
<?php
$lawpress_settings = array(
'lawpress.web_service_section' => array(
'title' => 'Web Service Settings',
'description' => 'NOTHING',
'settings' => array(
'lawpress.default_aop' => array(
'name' => 'default_aop',
'description' => 'Default AOP ID',
@robhurring
robhurring / Rakefile
Created December 7, 2010 20:09
Delayed Job with Sinatra -- without sinatra specific gems, etc.
task :environment do
require './dj-sinatra'
end
namespace :jobs do
desc "Clear the delayed_job queue."
task :clear => :environment do
Delayed::Job.delete_all
end
@robhurring
robhurring / usage.rb
Created November 30, 2010 21:34
http auth basic request with warden. simple method
use Warden::Manager do |config|
config.default_strategies :basic
config.failure_app = ErrorsController.action(:unauthenticated)
end
Warden::Strategies.add :basic, HttpAuthBasicStrategy do |config|
config.realm = "Welcome!"
config.callback do |env, username, password|
return username if username == 'rob'
false
@robhurring
robhurring / ruby-1.9.2p0-gems-error.sh
Created November 29, 2010 16:37
Solution to the ruby 1.9.2p0 install that was breaking ruby gems
# /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:68:in `installed_spec_directories': undefined method `path' for Gem:Module (NoMethodError)
# solution
sudo rm -rf /usr/local/lib/ruby/site_ruby/1.9.1/*ubygem*
# make install again
@robhurring
robhurring / example.php
Created November 23, 2010 19:39
Simple modeling in PHP using late static bindings.
<?php
// Using the simple model -- its very similar to active record, but
// its basic and simple :) (and not that powerful...)
require 'simple_model.php';
// set our environment
define('ENVIRONMENT', 'development');
// our db configurations
$DatabaseAuths = array(