This file contains 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
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
# SPDX-License-Identifier: MIT-0 | |
import logging | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
def lambda_handler(event, context): | |
"""Secrets Manager RDS PostgreSQL Handler |
This file contains 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
jQuery.fn.extend( { | |
addClass: function( value ) { | |
var classes, elem, cur, curValue, clazz, j, finalValue, | |
i = 0; | |
if ( isFunction( value ) ) { | |
return this.each( function( j ) { | |
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); | |
} ); | |
} |
This file contains 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
number = "314143525252" | |
sum = 0 | |
number.reverse.split("").each_slice(2) do |x,y| | |
sum += x.to_i + (2*y.to_i).divmod(10).sum | |
end | |
p sum%10 == 0 ? 'valid card number' : 'invalid card number' |
This file contains 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
module ActiveJobTestHelper | |
def prepare_args_for_assertion(args) | |
args.dup.tap do |arguments| | |
arguments[:at] = arguments[:at].to_f if arguments[:at] | |
end | |
end | |
def assert_enqueued_with(job: nil, args: nil, at: nil, queue: nil) | |
expected = { job: job, args: args, at: at, queue: queue }.compact | |
expected_args = prepare_args_for_assertion(expected) |
This file contains 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
# You may or may not require this step | |
sudo apt install openssl build-essential xorg libssl-dev | |
sudo apt remove libssl-dev | |
sudo apt autoremove | |
sudo apt install libssl-dev=1.0.2g-1ubuntu4.12 | |
sudo apt-cache policy libssl-dev |
This file contains 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
# frozen_string_literal: true | |
require "active_record/connection_adapters/postgresql/schema_statements" | |
# | |
# Monkey-patch the refused Rails 4.2 patch at https://github.com/rails/rails/pull/31330 | |
# | |
# Updates sequence logic to support PostgreSQL 10. | |
# | |
module ActiveRecord |
This file contains 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
2.4.0 :031 > class A | |
2.4.0 :032?> def initialize | |
2.4.0 :033?> end | |
2.4.0 :034?> def a_method | |
2.4.0 :035?> puts self.class.name | |
2.4.0 :036?> end | |
2.4.0 :037?> end | |
:a_method | |
2.4.0 :038 > class B | |
2.4.0 :039?> def initialize |
This file contains 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
module BulkCreator | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def bulk_create(columns, values, *args) | |
records_to_create(values, args).each_slice(500) do |records| | |
self.connection.execute bulk_insert_sql(columns, records) | |
end | |
end |
This file contains 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
params = {a: 4, b: 5, b: 4, to: 'akshay'} | |
mandatory_keys = [:from, :to, :caller_id, :call_type] | |
keys = params.keys | |
Benchmark.ips do |benchmark| | |
benchmark.report('new') { mandatory_keys.any?{|key| keys.include?(key)} } | |
benchmark.report('old') { mandatory_keys.all?{|key| params.keys.include?(key)} } | |
benchmark.compare! | |
end |
This file contains 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
2.4.0 :029 > Benchmark.ips do |benchmark| | |
2.4.0 :030 > benchmark.report('faker approach') { Faker::Number.number(6) } | |
2.4.0 :031?> benchmark.report('raw random approach') { rand(100000..999999).to_s } | |
2.4.0 :032?> end | |
Warming up -------------------------------------- | |
faker approach 28.347k i/100ms | |
raw random approach 159.529k i/100ms | |
Calculating ------------------------------------- | |
faker approach 315.433k (± 4.0%) i/s - 1.587M in 5.040671s | |
raw random approach 2.981M (± 7.0%) i/s - 14.836M in 5.002986s |
NewerOlder