Fast/efficient approach:
-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id = posts.id)")
-> 1.3197s
Slow/naïve approach:
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
describe 'Modal' do | |
should 'display login errors' do | |
visit root_path | |
click_link 'My HomeMarks' | |
within '#login_area' do | |
fill_in 'email', with: '[email protected]' | |
fill_in 'password', with: 'test' |
<?php | |
///.... | |
function step4() | |
{ | |
$app = JFactory::getApplication(); | |
$this->ordering->processRequest(JRequest::get('post'),self::$required_payments_objects); | |
$this->order = $this->ordering->getOrder(); | |
/// begin of patch |
Fast/efficient approach:
-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id = posts.id)")
-> 1.3197s
Slow/naïve approach:
# Caches Arbre elements in the `Rails.cache`. | |
# | |
# Yielding the first time adds to the output buffer regardless of the | |
# returned value. A cache miss must be handled separately from a hit | |
# to avoid double rendering. | |
# | |
# Returns yielded Arbre on cache miss OR an HTML string wrapped in | |
# an text node on cache hit. | |
def cache_arbre(context, *args, &block) | |
if controller.perform_caching |
<?php | |
$countries = array | |
( | |
'AF' => 'Afghanistan', | |
'AX' => 'Aland Islands', | |
'AL' => 'Albania', | |
'DZ' => 'Algeria', | |
'AS' => 'American Samoa', | |
'AD' => 'Andorra', |
@import "dataTables/jquery.dataTables"; | |
/* A modifier pour avoir les bons espacements */ | |
body.active_admin .data_table { | |
padding-bottom: 10px; | |
} | |
body.active_admin .dataTables_paginate { | |
margin-top: -10px; |
def select_from_chosen(item_text, options) | |
field = find_field(options[:from]) | |
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()") | |
page.execute_script("$('##{field[:id]}').val('#{option_value}')") | |
end |
#Original code from ActiveMerchant::PayPalNotification | |
#Modified by me to account for multiple items and custom flag | |
#Also bypassed the acknowledge if environment is "test" | |
require 'net/http' | |
class PayPalNotification | |
class Error < StandardError | |
end |
<?php | |
// Test cards | |
$cards = array( | |
'378282246310005', // American Express | |
'371449635398431', // American Express | |
'5078601870000127985', // Aura | |
'5078601800003247449', // Aura | |
'30569309025904', // Diners Club | |
'38520000023237', // Diners Club |
class User < ActiveRecord::Base | |
has_many :payments, class_name: 'Payment', foreign_key: :user_id do | |
def scoped_user | |
proxy_association.owner | |
end | |
end | |
end | |