This file contains hidden or 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
# | |
# Cookbook Name:: rails_app | |
# Recipe:: default | |
# | |
# Copyright 2014, AbelsonInfo | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
include_recipe 'rails_app_server::default' |
This file contains hidden or 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
# Determine which apps require the 'app' tier to be set up on this node: | |
tier_apps = ai_stack.apps_for_tier(node, 'app') | |
# Initialize an array to store user names that will later be added to the | |
# "sshlogin" group: | |
sshlogin_users = [] | |
# Perform configuration required by all apps: | |
unless tier_apps.empty? | |
# Ensure all dependencies necessary to build Ruby are present: |
This file contains hidden or 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 NginxMatchers | |
RSpec::Matchers.define :permit do |ip_addresses| | |
match do |content| | |
escaped_url = Regexp.escape @url | |
ip_addresses.all?{ |ip_address| | |
content=~/location #{escaped_url} \{[^}]+allow #{ip_address};/m | |
} | |
end | |
chain :access_to do |url| |
This file contains hidden or 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 "AI office" do | |
describe "/feed URL" do | |
its(:content) { | |
should permit(client_machines).access_to("/feed") | |
} | |
end | |
end |
This file contains hidden or 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 PostgresqlMatchers | |
RSpec::Matchers.define :permit_user do |user| | |
match do |content| | |
!(content=~/host #{@database} #{user} 127\.0\.0\.1\/32 trust/).nil? | |
end | |
chain :to_connect_to do |database| | |
@database = database | |
end |
This file contains hidden or 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
if defined?(ChefSpec) | |
module ChefSpec::Matchers | |
class NginxPrivilegeMatcher | |
def initialize(runner, ip_addresses, permission="allow") | |
@runner = runner | |
@ip_addresses = ip_addresses | |
@permission = permission | |
end |
This file contains hidden or 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
if defined?(ChefSpec) | |
def whitelist_requests_from(ip_addresses) | |
ChefSpec::Matchers::NginxPrivilegeMatcher.new(chef_run, ip_addresses, "allow") | |
end | |
def blacklist_requests_from(ip_addresses) | |
ChefSpec::Matchers::NginxPrivilegeMatcher.new(chef_run, ip_addresses, "deny") | |
end | |
end |
This file contains hidden or 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 "configuration" do | |
before :each do | |
@nginx_configuration = chef_run.template(@server_nginx_config_file) | |
end | |
describe "server" do | |
describe "location" do | |
describe "/" do | |
it "whitelists requests from Abelson Info servers" do | |
expect(@nginx_configuration).to whitelist_requests_from(["92.165.78.7", "12.34.56", "24.68.12"]).to_url "/" |
This file contains hidden or 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
import numpy as np | |
from numpy.linalg import inv | |
from scipy import linalg | |
from sklearn.decomposition import PCA | |
from sklearn import utils | |
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) | |
mean_ = np.mean(X, axis=0) | |
X = X - mean_ |
This file contains hidden or 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
import numpy as np | |
from numpy.linalg import inv | |
from scipy import linalg | |
from sklearn.decomposition import PCA | |
from sklearn import utils | |
X = np.array([[2.5, 2.4], [0.5, 0.7], [2.2, 2.9], [1.9, 2.2], [3.1, 3.0], [2.3, 2.7], [2, 1.6], [1, 1.1], [1.5, 1.6], [1.1, 0.9]]) | |
mean_ = np.mean(X, axis=0) | |
X = X - mean_ |
OlderNewer