A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
require 'active_support/basic_object' | |
ActiveRecord::Base.class_eval do | |
class WithoutCallbacks < ActiveSupport::BasicObject | |
def initialize(target, types) | |
@target = target | |
@types = types | |
end | |
def respond_to?(method, include_private = false) |
<script type="text/javascript"><!-- | |
google_ad_client = "ca-pub-3658299045266116"; | |
/* top */ | |
if ($(window).width()<728 ){ | |
google_ad_slot = "4414183254"; | |
google_ad_width = 320; | |
google_ad_height = 50; | |
}else{ | |
google_ad_slot = "1020377061"; | |
google_ad_width = 728; |
#!/bin/bash | |
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/ | |
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server | |
############################################### | |
# To use: | |
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh | |
# chmod 777 install-redis.sh | |
# ./install-redis.sh | |
############################################### | |
echo "*****************************************" |
A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
# | |
# Returns a hash of all unique values for a given field and the number of objects | |
# in the array which have that value. | |
# ex: | |
# Post.all.uniq_value_counts(:status) | |
# => { | |
# "published" => 10, | |
# "draft" => 13, | |
# "archived" => 34 | |
# } |
# Plugin: jekyll-contentblocks | |
# Author: Rusty Geldmacher | |
# Git: https://github.com/rustygeldmacher/jekyll-contentblocks | |
# Instructions: https://github.com/rustygeldmacher/jekyll-contentblocks#usage | |
module Jekyll | |
module ContentBlocks | |
VERSION = "0.0.3" | |
module Common | |
def get_content_block_name(tag_name, block_name) | |
block_name = (block_name || '').strip |
This is a small programming problem to test your technical ability and coding style.
Write a simple script to generate a set of n-grams from a string of text. N-grams are a contiguous sequence of n words from a string of text, and have many applications from full-text search indexes to machine learning.
You'll generate a set of every permutation of contiguous n-grams from a string of text, from 1-gram to n-grams where n is the number of words in the string
# usage: | |
# it "should return a result of 5" do | |
# eventually { long_running_thing.result.should eq(5) } | |
# end | |
module AsyncHelper | |
def eventually(options = {}) | |
timeout = options[:timeout] || 2 | |
interval = options[:interval] || 0.1 | |
time_limit = Time.now + timeout |
gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'
Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component
(and thus, prerendering).
Note that jquery-rails
can be removed from Gemfile, the npm version of jquery
and jquery-ujs
will be used instead.
require 'sidekiq/api' | |
# 1. Clear retry set | |
Sidekiq::RetrySet.new.clear | |
# 2. Clear scheduled jobs | |
Sidekiq::ScheduledSet.new.clear |