Skip to content

Instantly share code, notes, and snippets.

View robhurring's full-sized avatar
🍻
cheers

Rob Hurring robhurring

🍻
cheers
View GitHub Profile
@robhurring
robhurring / app.rb
Created November 23, 2010 17:03
ActiveRecord query caching with Sinatra
# ActiveRecord refuses to enable query caching _unless_ you have the following setup
# 1) you _must_ use ActiveRecord::Base.configurations to store your auth details
# 2) you _must_ include the ActiveRecord::QueryCache middleware
# 3) you _must_ inherit from the _Base_ connection -- abstract models don't
# cache without a bit of hacking, it only query caches anything from AR::Base
require 'sinatra'
require 'active_record'
# query caching requires that you use AR::Base.configurations to store your
@robhurring
robhurring / make_itunes_tolerable.sh
Created November 23, 2010 19:23
make the iTunes defaults better.
#!/bin/bash
# * remove those stupid PING buttons
# * show the store links
# * make the store links view more in your library (not the iTunes store)
defaults write com.apple.iTunes invertStoreLinks -bool YES
defaults write com.apple.iTunes show-store-link-arrows -bool YES
defaults write com.apple.iTunes hide-ping-dropdown -bool YES
@robhurring
robhurring / simple_logger.php
Created November 23, 2010 19:31
Simple PHP logger utility class : http://proccli.com/logging-php
<?php
/**
* Very simple error logger
* Set error level using bitwise OR
*
* Example Usage:
*
* SimpleLogger::log_level(SimpleLogger::All);
* SimpleLogger::log_method(function($message, $level = 0)
* {
@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(
@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 / 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 / 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
<?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',
.clearfix:after {
content: ".";
display: block;
height: 0;
font-size: 0;
clear: both;
visibility: hidden;
}
.clearfix {display: inline-block;}
/* Hides from IE5/Mac \*/
@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>