Skip to content

Instantly share code, notes, and snippets.

View gecugamo's full-sized avatar

Gary Cuga-Moylan gecugamo

View GitHub Profile
@gecugamo
gecugamo / angular-local-ssl.md
Created June 15, 2023 17:13
Running Angular Application Locally with SSL

Install mkcert

  • Run brew update
  • Run brew install mkcert
  • Run mkcert -install

Create a cert for localhost

  • Run mkcert localhost

Run ng serve with ssl

  • Run npm run start -- --ssl --ssl-cert ./localhost.pem --ssl-key ./localhost-key.pem or ng serve --ssl --ssl-cert ./localhost.pem --ssl-key ./localhost-key.pem
function transformTemplatedString(template, replacements) {
return Object.entries(replacements).reduce((transformedString, [key, value]) => {
if (!/^[a-z|_]+$/i.test(key)) {
throw new Error('keys may only consist of letters and underscores');
}
const keyPattern = new RegExp(`%{${key}}`, 'g');
return transformedString.replace(keyPattern, value);
}, template);
}
def transform_templated_string(template, replacements)
# Ensure replacements keys are valid
replacements.each_key do |key|
unless /^[a-z_]+$/i.match?(key.to_s)
raise ArgumentError, 'keys may only consist of letters and underscores'
end
end
# Perform the replacements
replacements.reduce(template) do |transformed_string, (key, value)|
@gecugamo
gecugamo / dynamic_rules.rb
Last active January 9, 2025 16:37
Dynamic Rules
class DynamicRuleAttributeService
METHOD_DICTIONARY = {
"coverage.coverage_a" => :coverage_a,
"coverage.coverage_b" => :coverage_b
}.freeze
# Finds the value for a given attribute alias
# @param attr_alias [String] Alias of attribute to find
# @return [Object, nil] Result of the corresponding method call or nil if not found
def self.call(policy, attr_alias)