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 Template | |
class JsonInputStrategy < Template::InputStrategy | |
def parse_request_input | |
begin | |
JSON.parse(request_input) | |
rescue JSON::ParserError | |
{} | |
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
module Users | |
class AnnouncementsQuery | |
attr_accessor :used | |
def initialize(user) | |
@user = user | |
end | |
def unread | |
active |
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
DO $$ | |
DECLARE | |
v_ts TIMESTAMP; | |
v_repeat CONSTANT INT := 10000; | |
rec RECORD; | |
BEGIN | |
-- Repeat the whole benchmark several times to avoid warmup penalty | |
FOR i IN 1..5 LOOP | |
v_ts := clock_timestamp(); |
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
SELECT DISTINCT result.request_json->>'target' as target, | |
result.request_json->>'return_to' as return_to | |
FROM ( | |
SELECT "request_params"::json as request_json | |
FROM "histories" | |
WHERE (created_at > '2018-12-05 00:00:00') AND | |
(created_at < '2019-01-05 00:00:00') | |
) as result | |
WHERE ( |
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
version: '3' | |
services: | |
db: | |
image: postgres:10.5-alpine | |
ports: | |
- 5432:5432 | |
volumes: | |
- ./tmp/postgres_data:/var/lib/postgresql/data | |
web: | |
build: |
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
FROM ruby:2.6.5-slim-stretch | |
RUN apt-get update && apt-get install -y \ | |
curl \ | |
build-essential \ | |
libpq-dev &&\ | |
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ | |
apt-get update && apt-get install -y nodejs yarn |
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 | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
ruby "2.6.5" | |
gem "bootsnap", require: false | |
gem "pg", ">= 0.18", "< 2.0" | |
gem "puma", "~> 3.11" | |
gem "rails", "~> 6.0.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
// Within the Application_Start() event handler in the Global.asax.cs | |
ControllerBuilder.Current.SetControllerFactory(new DependencyControllerFactory()); | |
ObjectFactory.Initialize(registry => registry | |
.ForRequestedType<IContactRepository>() | |
.TheDefaultIsConcreteType<ContactManagerLinqRepository>()); | |
// The repository class which is passed through DI to the controller |
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 UsersController < ApplicationController | |
# ... | |
before_action :auth_user | |
# ... | |
def show | |
@user = User.find(params[:id]) | |
@customers_portals = UserCustomersPortalsQuery.new(@user).all | |
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
describe AuthService do | |
# ... | |
before { allow_any_instance_of(Dnsruby::Resolver).to receive(:query).and_return(message) } | |
# ... | |
before { allow(AuthService).to receive(:sso_url).and_return(sso_auth_url) } | |
# ... | |
end |
NewerOlder