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
| class ComplexNumber | |
| def initialize(real, imaginary) | |
| @real = real | |
| @imaginary = imaginary | |
| end | |
| def to_s | |
| "#{@real} + #{@imaginary}i" | |
| 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
| class Employees | |
| include Enumerable | |
| def initialize(employees) | |
| @employees = employees | |
| end | |
| def each &block | |
| @employees.each &block | |
| 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
| alert(32); |
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_ |
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
| 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
| 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
| 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
| 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
| describe "AI office" do | |
| describe "/feed URL" do | |
| its(:content) { | |
| should permit(client_machines).access_to("/feed") | |
| } | |
| end | |
| end |
NewerOlder