Skip to content

Instantly share code, notes, and snippets.

View gfmurphy's full-sized avatar

George F Murphy gfmurphy

  • Salesforce
  • Little Rock
View GitHub Profile
@gfmurphy
gfmurphy / fizz_buzz.php
Created November 22, 2011 16:34
My Pre-FizzBuzz Test
<?php
// Make the following code better *in the simplest possible way*
// Assume $result is a resource identifier returned from a call to mysql_query with a select query as an argument in which you don't expect any results to be returned
if(mysql_num_results($result) > 0)
$error = true;
?>
@gfmurphy
gfmurphy / soft_destroy.rb
Created October 7, 2011 20:33
Messy? Can you think of a more clear implementation of soft_destroy_method?
module SoftDestroy
# accepts a method or proc to execute as a soft deletion routine
# replaces existing destroy method with new soft destroy
def soft_destroy_method(&block)
if block_given?
self.class_eval do
def destroy_with_forgiveness
block.call(self)
end
function validate_forms() {
global $wpdb, $current_user, $user_ID;
$any_bad_inputs = false;
$bad_input_message = '';
if(is_numeric($_POST['card_number']) === false) {
$_SESSION['wpsc_gateway_error_messages']['card_number'] = __('Please enter a valid card number.', 'wpsc');
}