Skip to content

Instantly share code, notes, and snippets.

View Fivell's full-sized avatar
🏠
Working from home

Igor Fedoronchuk Fivell

🏠
Working from home
View GitHub Profile
@Fivell
Fivell / wait_until.rb
Created June 2, 2016 11:45 — forked from metaskills/wait_until.rb
Never sleep() using Capybara!
# 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'
@Fivell
Fivell / order.php
Last active April 5, 2016 09:53
patch.php
<?php
///....
function step4()
{
$app = JFactory::getApplication();
$this->ordering->processRequest(JRequest::get('post'),self::$required_payments_objects);
$this->order = $this->ordering->getOrder();
/// begin of patch
@Fivell
Fivell / OUTPUT.md
Last active February 12, 2016 06:57 — forked from rmm5t/OUTPUT.md
How to properly introduce a new counter_cache to an existing Rails project.

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:

@Fivell
Fivell / cache_arbre.rb
Created February 12, 2016 06:24 — forked from zorab47/cache_arbre.rb
Arbre content caching for ActiveAdmin
# 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
@Fivell
Fivell / test.php
Last active August 29, 2015 14:24 — forked from claudiosanches/test.php
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
@Fivell
Fivell / example.rb
Last active August 29, 2015 14:20
access to parent object from has_many
class User < ActiveRecord::Base
has_many :payments, class_name: 'Payment', foreign_key: :user_id do
def scoped_user
proxy_association.owner
end
end
end