This file contains hidden or 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
#paste this code in your ransack.rb initializer | |
#if you want to use scopes on search or sort please use Class.ransack_with_scopes instead of Class.search | |
Ransack::Adapters::ActiveRecord::Base.class_eval do | |
def ransack(params = {}, options = {}, scope_used_on_sort = false) | |
Ransack::Search.new(self, params, options, scope_used_on_sort) | |
end | |
def ransack_with_scopes(params = {}, options = {}) | |
scope_used_on_sort = false | |
ransack_scope = self | |
ransack_params = {} |
This file contains hidden or 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
require 'benchmark/ips' | |
require 'set' | |
#init array | |
arr = Array.new | |
1000.times do | |
arr << (rand * 20).to_i | |
end | |
Benchmark.ips do |x| |
This file contains hidden or 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
defmodule Meinac.User do | |
use Meinac.Web, :model | |
schema "users" do | |
field :first_name, :string | |
field :last_name, :string | |
field :email, :string | |
field :password_digest, :string | |
field :password, :string, virtual: true |
This file contains hidden or 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
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(false) do | |
source 'https://rubygems.org' | |
gem 'activerecord', '4.2.6' |
This file contains hidden or 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
container_commands: | |
01_remove_old_cron_jobs: | |
command: "crontab -u ec2-user -r || exit 0" | |
test: '[ -n "$tier" ] && [ "$tier" = "worker" ]' | |
02_create_cron_command: | |
command: "echo '0 * * * * source /home/ec2-user/.bashrc && pushd /var/app/current && rake task_name' > /home/ec2-user/cron_command" | |
test: '[ -n "$tier" ] && [ "$tier" = "worker" ]' | |
10_run_cron_job: | |
command: "crontab -u ec2-user /home/ec2-user/cron_command" | |
test: '[ -n "$tier" ] && [ "$tier" = "worker" ]' |