This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zone.try(:user).try(:has_carrier?, carrier.try(:name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Order.class_eval do | |
def amount | |
line_items.map(&:amount).sum | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_resource | |
"#{controller_name.classify}".constantize.find(params[:id]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::DataImport.for(:taxons).run("https://abcdef012356789:[email protected]/taxons.xml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paragraphs.join("\n").split(/\W/) | |
.reject { |w| w.size < 4 } | |
.map(&:downcase) | |
.reduce(Hash.new(0)) { |words, word| words[word] += 1; words } | |
.sort { |a, b| a.last <=> b.last } | |
.take(16) | |
.map(&:first) | |
.join(' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Condition_H::Wait() { | |
IntStatus oldLevel = interrupt->SetLevel(IntOff); | |
count++; | |
if (mon->next_count > 0) { | |
mon->next->V(); | |
mon->next_count--; | |
} | |
else mon->mutex->V(); | |
sem->P(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deal types currently included in xml sitemap | |
# * "LocalDeal", "EscapesDeal", "AtHomeDeal", "FamiliesDeal" | |
# * live event deals are included | |
# URLs are generated with LS::Routing | |
# * Need to support a mobile version of the url for alternate content and mobile sitemap in near future. | |
def search_engine_ignore?(deal) | |
deal.exclusive? || deal.boomerang? || !deal.active? | |
end | |
# this logic expands to |
OlderNewer