Skip to content
View gist:a097ef3d7df06c0045cc6ed335627805
diff --git a/spec/js_routes/rails_routes_compatibility_spec.rb b/spec/js_routes/rails_routes_compatibility_spec.rb
index ff0a480..6f027f7 100644
--- a/spec/js_routes/rails_routes_compatibility_spec.rb
+++ b/spec/js_routes/rails_routes_compatibility_spec.rb
@@ -93,6 +93,14 @@ describe JsRoutes, "compatibility with Rails" do
it "should support single route mapping" do
expect(evaljs("Routes.support_path({page: 3})")).to eq(routes.support_path(:page => 3))
end
+
+ describe "anonymous" do
View sweeperzz.rb
module Check_position
def check_position(x, y)
if @board[x][y] == 'b'
return 'b'
else
# Counter can be cached.
# That is optional to do but is a big +
counter(x, y)
end
end
View action_mailer_optional_tls.rb
require 'open-uri'
require 'net/https'
module Net
class HTTP
alias_method :original_use_ssl=, :use_ssl=
def use_ssl=(flag)
# Ubuntu
if File.exists?('/etc/ssl/certs')
View site.rb
def custom_domain_up_new?
return false unless custom_domain.present?
Resolv::DNS.open do |dns|
dns.timeouts = 2
# Querying each type of record individually
# Because ANY query may not return all required types
{
Resolv::DNS::Resource::IN::CNAME => /(talkable|curebit)\.com$/,
Resolv::DNS::Resource::IN::NS => /ns-\d+.awsdns-\d+.com$/,
}.any? do |type, regex|
View .irbrc
require 'rubygems'
require 'logger'
require "net/http"
irb_conf = defined?(::IRB) && IRB.respond_to?(:conf)
load File.dirname(__FILE__) + "/.rubyrc/bogdan.rb"
if irb_conf
begin
View log
production >> User.connection.select_value("SELECT 1 AS one FROM `origins` use index (index_purchases_migrated_on_visitor_id) WHERE `origins`.`visitor_id` = 30388798 AND `origins`.`site_id` = 6854 LIMIT 1")
(79.8ms) SELECT 1 AS one FROM `origins` use index (index_purchases_migrated_on_visitor_id) WHERE `origins`.`visitor_id` = 30388798 AND `origins`.`site_id` = 6854 LIMIT 1
=> nil
production >> User.connection.select_value("SELECT 1 AS one FROM `origins` WHERE `origins`.`visitor_id` = 30388798 AND `origins`.`site_id` = 6854 LIMIT 1")
(270.3ms) SELECT 1 AS one FROM `origins` WHERE `origins`.`visitor_id` = 30388798 AND `origins`.`site_id` = 6854 LIMIT 1
=> nil
production >>
View bogdan_change_attributes.rb
require 'benchmark/ips'
require 'active_model'
# run this
# bundle exec ruby benchmark.rb && second_run=y bundle exec ruby benchmark.rb
class Person
include ActiveModel::Dirty
define_attribute_methods :name, :age
View ab_math.rb
module AbMath
module Distribution
SQ2PI = Math.sqrt(2 * Math::PI)
class << self
def mean(distribution)
# average value
return 0.0 if distribution.empty?
distribution.reduce(:+).to_f / distribution.size
end
View purchase.rb
# == Schema Information
#
# Table name: origins
#
# id :integer not null, primary key
# order_number :string(255) not null
# site_id :integer not null
# subtotal :decimal(25, 2) not null
# order_date :datetime not null
# ip_address :string(255)
View gist:bd962f3bb04e893ea172
+-----------+--------------+---------+----------+------------------+------------------+------------------+------------------+-------------------+------------+-----------+--------+----------+-------------------+------------------+
| id | order_number | site_id | subtotal | order_date | ip_address | internal_ip_a... | created_at | updated_at | visitor_id | person_id | is_new | type | traffic_source_id | event_categor... |
+-----------+--------------+---------+----------+------------------+------------------+------------------+------------------+-------------------+------------+-----------+--------+----------+-------------------+------------------+
| 95709621 | 489437 | 8269 | 153813.0 | 2015-09-13 00... | | | 2015-09-13 00... | 2015-09-17 05:... | | 38436040 | false | Purchase | 16893 | 16044 |
| 95711237 | 491641 | 8269 | 63945.0 | 2015-09-13 00... | |
Something went wrong with that request. Please try again.