Skip to content

Instantly share code, notes, and snippets.

Bogdan Gusiev bogdan

View GitHub Profile
View bm.rb
require "benchmark/ips"
quiet_logger
c = ActiveRecord::Base.connection
mysql = c.instance_variable_get("@connection")
sql = "select * from users where id = 1"
Benchmark.ips do |x|
x.time = 5
x.warmup = 0.1
View json.js
var a = {
success: true,
rewarded: true,
coupon_code: 'aaa',
unredeem_reason: 'aaa',
friend_person: {
"first_name": "John",
"last_name": "Smith",
"email": "advocate@example.com",
"username": "sample",
View 20180420174111_kickbox_parallel_analysis.rb
100.times.to_a.map do |i|
HTTParty.get("#{Kickbox::KICKBOX_API_URL}/verify?email=fainevb837ehadk#{i}@hotmail.com&apikey=#{Kickbox.api_key}")
end
View 20180426120831_dev_shard_1_extraction.rb
require Rails.root.join 'support/2018/20180202160337_db_extraction'
class DevShard1Extraction < ActiveRecord::Migration[5.1]
extractor = DbExtraction.new
if extractor.db_match?
raise 'Please set the shard 1 DB to be different from primary DB. You may take the config/deploy/templates/database.yml or modify your own copy.'
end
shard 1
def change
return unless Rails.env.development?
View test.log
[2018-04-20 12:37:47.513] x27[1mx27[35m (11.0ms)x27[0m x27[1mx27[35mSET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci, @@SESSION.sql_mode = 'TRADITIONAL', @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483x27[0m
[2018-04-20 12:37:47.524] x27[1mx27[35m (0.2ms)x27[0m x27[1mx27[35mBEGIN /* shard nil master */x27[0m
[2018-04-20 12:37:47.524] x27[1mx27[35m (0.1ms)x27[0m x27[1mx27[35mBEGIN /* shard 1 master */x27[0m
[2018-04-20 12:37:48.336] x27[1mx27[35m (0.2ms)x27[0m x27[1mx27[35mSAVEPOINT active_record_1 /* shard nil master */x27[0m
[2018-04-20 12:37:48.362] x27[1mx27[36mAccount Exists (6.0ms)x27[0m x27[1mx27[34mSELECT 1 AS one FROM `accounts` WHERE `accounts`.`api_key` = BINARY 'XFgLPXsZRCUKD3lx68a' LIMIT 1 /* shard nil master */x27[0m
[2018-04-20 12:37:48.364] x27[1mx27[36mAccount Exists (0.3ms)x27[0m x27[1mx27[34mSELECT 1 AS one FROM `accounts` WHERE `accounts`.`name` = 'Account 1' LIMIT 1 /* shard nil master */x27[0m
[2018-04-20 12:37:48.392] x27[1mx27[35mSQL (0.5ms)x27[0m x
View spellgood
#!/usr/bin/env ruby
new_words = ARGV
file_name = File.dirname(__FILE__) + "/../.pronto_spell.pws"
lines = File.read(file_name)
words = lines.split("\n")
header = words.shift
new_words.each do |word|
unless words.include?(word)
words << word
end
View gist:5ef38bfa60bcd47b3495b8acb0967a5d
app/grids/people_grid.rb|102| scope.with_property_value(key.id, value, :cp_1)
app/grids/people_grid.rb|110| scope.with_property_value(key.id, value, :cp_2)
app/models/activity.rb|136| joins(offer: :person).merge(Person.with_property_value(key_id, value))
app/models/concerns/customizable_properties.rb|7| scope :with_property_value, ->(key_id, value, table_alias = :custom_properties) {
app/models/customer_email.rb|141| joins(offer: :person).merge(Person.with_property_value(key_id, value))
app/models/incentive_outcome.rb|99| joins(offer: :person).merge(Person.with_property_value(key_id, value))
app/models/offer.rb|120| joins(:person).merge(Person.with_property_value(key_id, value))
app/models/offer_share.rb|82| joins(:person).merge(Person.with_property_value(key_id, value))
app/models/referral.rb|248| joins(offer: :person).merge(Person.with_property_value(key_id, value))
app/models/visitor_offer.rb|133| joins(offer: :person).merge(Person.with_property_value(key_id, value))
View md.md

Fits

WHERE (`custom_properties`.`person_id` = 197950367 OR `custom_properties`.`visitor_id` = 1052274563) AND ...

WHERE (`campaigns`.`activates_at` BETWEEN '2018-02-22 14:30:07' AND '2018-02-22 14:30:54' OR `campaigns`.`expires_at` BETWEEN '2018-02-22 14:30:07' AND '2018-02-22 14:30:54') AND ...

WHERE (role='admin' OR staff_member=1) AND

WHERE (`incentive_outcomes`.`target_type` = "Referral" OR `referrals`.`status` IN ('approved','unblocked')) AND ...
View zz.diff
where(person_id: Person.find_by(email: email, site_id: site_id), site_id: site_id)
}
+ scope :by_coupon_list, ->(coupon_list_id) {
+ sub_query = Coupon.
+ joins('INNER JOIN `checkout_coupons` ON `checkout_coupons`.`coupon_id` = `coupons`.`id`').
+ where('`origins`.`id` = `checkout_coupons`.`purchase_id`').where(coupon_list_id: coupon_list_id)
+ where("exists (#{sub_query.to_sql})")
+ }
+
View gist:6b963df28ccec53f0031199283dd38e0
[4c015ea6bb27] Started POST "/internal/localization_override" for 127.0.0.1 at 2017-11-22 15:03:21 +0200
[4c015ea6bb27] [ETagCahing] ETag: none
[2017-11-22 15:03:21.601] Processing by Internal::LocalizationOverrideController#create as JSON
[4c015ea6bb27] [master/1] User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 5139 LIMIT 1
[4c015ea6bb27] [master/1] (0.3ms) BEGIN
[4c015ea6bb27] [master/1] SQL (0.5ms) UPDATE `users` SET `perishable_token` = 'wLM6kWLPS4Nb3b5eGhA', `last_request_at` = '2017-11-22 13:03:21', `updated_at` = '2017-11-22 13:03:21' WHERE `users`.`id` = 5139
[4c015ea6bb27] [master/1] CustomAttribute Load (0.5ms) SELECT `custom_attributes`.* FROM `custom_attributes` WHERE `custom_attributes`.`foreign_id` = 5139 AND `custom_attributes`.`model` = 'User'
[4c015ea6bb27] [master/1] (0.3ms) COMMIT
[4c015ea6bb27] [master/1] Account Load (0.6ms) SELECT `accounts`.* FROM `accounts` WHERE `accounts`.`id` = 4416 LIMIT 1
[2017-11-22 15:03:21.624] Completed 400 Bad Request
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.