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 | |
branches_to_test=('master' 'staging' 'develop') | |
branch=`git rev-parse --abbrev-ref HEAD` | |
test_branch () { | |
local e | |
for e in "${branches_to_test[@]}" | |
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
// SASS variable overrides must be declared before loading up Active Admin's styles. | |
// | |
// To view the variables that Active Admin provides, take a look at | |
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the | |
// Active Admin source. | |
// | |
// For example, to change the sidebar width: | |
// $sidebar-width: 242px; | |
$primary-color: dynamic_active_admin_color(); |
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
-- Dudu query: | |
select part_id,produced_at | |
from (select part_id,produced_at | |
,dense_rank () over (partition by part_id order by produced_at) as dr | |
from part_subhourly_data | |
where produced_at < now() - interval '100 days' | |
) p |
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
# lib/utils/sendmail_staging.rb | |
class SendmailStaging < ::Mail::Sendmail | |
# mail object can be used to modify mail before we pass it | |
# to sendmail | |
def deliver!(mail) | |
mail['to'] = '[email protected]' #replace recipient | |
super(mail) #Let Sendmail do his work | |
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 CollectionMath | |
class << self | |
# Returns nil instead of 0 for an empty array | |
def sum_values(collection) | |
values = if block_given? | |
collection.map{ |item| yield item }.compact | |
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
class NetworkExplorerController < ApplicationController | |
def index | |
end | |
def get_root_nodes | |
roots = NetworkExplorerService.roots(current_user) | |
respond_with(roots) | |
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 AppConfig < ActiveRecord::Base | |
validates :parameter, uniqueness: true, presence: true | |
def self.get(parameter) | |
AppConfig.where(parameter: parameter).first.try(:value) | |
end | |
def self.set(parameter, value) | |
param = AppConfig.find_or_initialize_by(parameter: parameter) |
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 dl_for(instance, attribute) | |
content = content_tag(:dt, class: "input-lg") do | |
instance.class.human_attribute_name(attribute) | |
end | |
content << content_tag(:dd, class: "input-lg") do | |
if block_given? | |
yield | |
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
RSpec::Matchers.define :have_content_type do |content_type| | |
MIME_TYPES = { json: 'application/json' } | |
match do |response| | |
response_content_type = response.header['Content-Type'] | |
response_content_type.split(";").include?(MIME_TYPES[content_type]) | |
end | |
description 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
# spec/support/pundit.rb | |
# Creates a 'grant_permission_to' matcher to better test Pundit policies | |
# See: http://thunderboltlabs.com/blog/2013/03/27/testing-pundit-policies-with-rspec/ | |
RSpec::Matchers.define :grant_permission_to do |action| | |
match do |policy| | |
policy.public_send("#{action}?") | |
end |