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 'elasticsearch' | |
# Set up client bypassing Elasticsearch's Faraday imported proxy settings (which ignore system's no_proxy) | |
# So transport_options needed to access local elasticsearch instance | |
client = Elasticsearch::Client.new log: true, transport_options: { proxy: '' } | |
# Retrieve data - setup instructions here: | |
# https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-elasticsearch-on-ubuntu-16-04 | |
client.get index: 'tutorial', type: 'helloworld', id: 1 |
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
def glyphicon(name) | |
content_tag( | |
'span', '', class: "glyphicon glyphicon-#{name}", 'aria-hidden' => 'true' | |
) | |
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
unless [].respond_to? :to_h | |
class Array | |
def to_h | |
Hash[self] | |
end | |
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
#!/bin/bash | |
### | |
# Script for downgrading Elasticsearch to version 1.3.9 | |
# | |
# Before running this script, please reset your dependency cache in Project Settings > Admin. | |
# | |
# Add the line below to your Setup commands in Project Settings (without the # at the beginning): | |
# | |
# wget https://gist.githubusercontent.com/reggieb/c16ce698f482904ad0a8f81bd1fe7af4/raw/1fc5a9883ee85f74b6fc8415213deac69b002e55/elasticsearch-downgrade-semaphore.sh ; sudo bash elasticsearch-downgrade-semaphore.sh |
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 PickingSerializer < ActiveModel::Serializer | |
attribute :data do | |
{ | |
result: object.id, | |
entities: { | |
orders: { object.id => OrderSerializer.new(object) }, | |
line_items: object.line_items.each_with_object({}) do |line_item, h| | |
h[line_item.id] = LineItemSerializer.new(line_item) | |
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
# Set up the spy object | |
let(:chargebee_site) { spy(ChargebeeSite) } | |
# Hook it into the work flow | |
before do | |
allow(ChargebeeSite).to receive(:new).and_return(chargebee_site) | |
end | |
# use `have_received` to test connection | |
it 'creates a chargebee coupon' do |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<title><%= page_title %></title> |
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 TrueLayer | |
class IdentifyApplicant | |
TRUE_LAYER_URL = 'https://api.truelayer.com'.freeze | |
attr_reader :token, :error | |
def initialize(token) | |
@token = token | |
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 'active_support' | |
require 'active_support/core_ext/integer/time' | |
class SalaryPatternGenerator | |
def self.generate(*args) | |
new(*args).generate | |
end | |
attr_reader :period, :salary, :day_offset, :salary_offset, :start_at |
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 "active_support/core_ext" | |
class XBuilder | |
attr_reader :data, :namespace, :root | |
def initialize(data) | |
@namespace = data.delete(:_namespace) | |
@root = data.delete(:_root) | |
@data = data | |
end |