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
a = 'Baloon . || woo,,ooddreeeed' | |
occurences = Hash.new(0) | |
array = a.gsub(/\W+/, '').split('') | |
array.each_with_index do |el, idx| | |
break if array.size == idx + 1 | |
if el == array[idx + 1] && el != array[idx - 1] | |
occurences[el] += 1 | |
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
# reverse decimal int number | |
# without converting to string | |
def reverse_decimal num | |
while num > 0 do | |
# condition | |
last = num % 10 | |
# algorithm body | |
res ||= 0 | |
res = (res *= 10) + last |
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 Client | |
TABLE = 'TestDevelopment1' | |
def client | |
Aws::DynamoDB::Client.new(region: 'No', | |
credentials: Rails.configuration.api.pulsar.creds, | |
endpoint: Rails.configuration.api.pulsar.east, | |
ssl_verify_peer: false) | |
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
class TestController < ApplicationController | |
skip_before_action :verify_authenticity_token | |
def index | |
json = { first_name: 'Jonh', last_name: 'Smith', address: '10 Greenwood Ave, Garden, MI, 15006', age: '25', status: 'married' } | |
render json: json, status: :ok | |
end | |
end | |
if __FILE__ == $0 |
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
class A | |
attr_accessor :options | |
cattr_accessor :name | |
def initialize | |
self.options = { code: 200, controller: OpenStruct.new(log_state: true) } | |
self.class.name = :api_name | |
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
# Place this file in /shingle directory name it shingle.rb | |
# run `gem install sinatra` | |
# run `ruby shingle/shingle.rb` | |
# open browser on http://localhost:4567 | |
require 'rubygems' | |
require 'sinatra' | |
set :port, '4567' | |
set :static, true |
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
require 'benchmark' | |
def get_benchmark | |
c = Aws::DynamoDB::Client.new(region: 'No', credentials: Rails.configuration.api.pulsar.creds, endpoint: Rails.configuration.api.pulsar.base, ssl_verify_peer: false) | |
ips = ["2001:0558:4030:0002", "2001:0558:6000:0002", "2601:0A40:0100:00A8", "67.164.233.81", "69.247.98.137", | |
"69.247.99.167", "69.247.99.168", "69.247.99.9", "76.26.116.108", "76.26.116.116"] | |
ids = ["1416782538086630295-2001:0558:4030:0002", "1416782538086630295-2001:0558:6000:0002", | |
"1416782538086630295-2601:0A40:0100:00A8", "1416782538086630295-67.164.233.81", "1416782538086630295-69.247.98.137", | |
"1416782538086630295-69.247.99.167", "1416782538086630295-69.247.99.168", "1416782538086630295-69.247.99.9", | |
"1416782538086630295-76.26.116.108", "1416782538086630295-76.26.116.116"] | |
bm = Benchmark.bm(7) do |x| |
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
# HTTPRequest class is an http client for API calls services | |
# see usages bellow | |
class HTTPRequest | |
attr_accessor :client, :options, :exceptions, :api_context, :async | |
module ::Manticore | |
class ResponseCodeException < ManticoreException; 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
require 'rails_helper' | |
describe HTTPRequest do | |
let(:logger) { ->(params) { } } | |
let(:api_context) { ParentalControls.new('', '', logger: logger) } | |
let(:subject) { HTTPRequest.new(api_context: api_context, headers: { 'Accept' => 'application/xml' }) } | |
let(:response) { double(:response, code: 200, body: {}.to_json) } | |
before do | |
allow_any_instance_of(ParentalControls).to receive(:get).and_return({}) |
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
# bash/zsh completion support for core Git. | |
# | |
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> | |
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
# Distributed under the GNU General Public License, version 2.0. | |
# | |
# The contained completion routines provide support for completing: | |
# | |
# *) local and remote branch names | |
# *) local and remote tag names |
OlderNewer