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
#!/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
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
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
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
class Address | |
attr_accessor :address, :flat, :house_number, :house_name, :street, :street2, :street3, :town, :county | |
def initialize(address) | |
self.address = address | |
end | |
def parts | |
@parts ||= address.split(/\s?\,\s?/).collect(&:strip) | |
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 ContentsOf | |
def contents_of(file_path, location: Rails.root) | |
File.read File.expand_path(file_path, location) | |
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
# Resistence settings for cartidge loads | |
settings = [1.1, 33.0, 100.0, 1000.0] | |
# Combination of resistors switched in via panel under dino | |
# Equation is: 1/Rtotal = 1/R1 + 1/R2 ... + 1/Rn | |
(1..4).collect do |i| | |
settings.combination(i).each do |combination| | |
label = combination.inspect | |
fractions = combination.collect{|c| 1/c} |
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/concern' | |
module UseUuid | |
extend ActiveSupport::Concern | |
included do | |
before_save :generate_uuid | |
end | |
def to_param | |
uuid |
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 Parent | |
def self.to_be_over_ridden | |
raise "Class method `#{__method__}` must be defined in #{name}" | |
end | |
def to_be_over_ridden | |
raise "Instance method `#{__method__}` must be defined in #{self.class.name}" | |
end | |
end |