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
# Preparation | |
# gem install sinatra | |
# gem install timezone | |
# | |
# Launch | |
# RACK_ENV=production ruby time_utc.rb | |
# | |
# Check working | |
# curl http://localhost:4567/time?Moscow,New%20York | |
# |
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
findMissedValues = (arr) -> | |
result = [] | |
findWithBinarySearch result, arr, 0, arr.length - 1 | |
result | |
findWithBinarySearch = (result, arr, from, to) -> | |
from = to if from > to | |
if (from == to && arr[to] != to) | |
diffPosition = arr[to] - to - 1 | |
diffNeighbor = if diffPosition == 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
module PerformAsync | |
extend ActiveSupport::Concern | |
included do | |
def method_missing(method, *args, &block) | |
parts = method.to_s.split('_') | |
async_method_to_call = parts[0...-1].join('_') | |
if parts.last == 'async' && self.class.async_method_allowed?(async_method_to_call) && !async_method_to_call.empty? | |
perform_method_async async_method_to_call, args, block | |
else |
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
SET SERVEROUTPUT ON | |
/* | |
* dishes table | |
*/ | |
DROP TABLE dishes; | |
DROP SEQUENCE dishes_seq; | |
CREATE TABLE dishes ( |
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
deploy: | |
steps: | |
- script: | |
name: create necessary folders | |
code: |- | |
mkdir -p $HOME/.aws | |
mkdir -p $WERCKER_SOURCE_DIR/.elasticbeanstalk | |
- create-file: | |
name: setting up AWS credentials | |
filename: $HOME/.aws/credentials |
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
data Error = ParsingError | IncompleteDataError | IncorrectDataError String | |
deriving (Show, Eq) | |
data Person = Person { firstName :: String, lastName :: String, age :: Int } | |
deriving (Show, Eq) | |
parsePerson :: String -> Either Error Person | |
parsePerson = validatePerson . buildPerson (Right $ Person "" "" (-1)) . parse where | |
trim = unwords . words |
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 Container | |
module Dependent | |
def dependencies(*deps) | |
@dependencies ||= [] | |
deps.each { |d| @dependencies << d } | |
@dependencies.uniq! | |
end | |
end | |
attr_reader :instances |
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 'socket' | |
require 'http_tools' | |
require 'sinatra/base' | |
require 'sinatra/cookies' | |
class Server | |
DEFAULT_HOST = 'localhost' | |
DEFAULT_PORT = 3000 | |
def self.run(app, **options) |
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
############# | |
# Gemfile | |
############# | |
source 'https://rubygems.org' | |
gem 'rack', '>= 2.0' | |
gem 'roda' | |
gem 'thin' | |
gem 'rack-fiber_pool', github: 'alebsack/rack-fiber_pool' |
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 HashTable | |
DEFAULT_BUCKETS_COUNT = 10 | |
RESIZE_STORE_FACTOR = 2 | |
def initialize | |
@buckets_count = DEFAULT_BUCKETS_COUNT | |
@store = Array.new(@buckets_count) | |
@size = 0 | |
end |