Skip to content

Instantly share code, notes, and snippets.

View gecugamo's full-sized avatar

Gary Cuga-Moylan gecugamo

View GitHub Profile
@gecugamo
gecugamo / persistable_required_fields.js
Last active January 21, 2026 23:33
Persistable Required Fields with Instanced Attribute Payload
const payload = {
attributes: [
{
attribute_id: "address_zipcode",
attribute_hash: "45486028e8690603de6e69c2a772584ad1a81429a07777ee10ecb4369e506980",
value: "91403"
},
{
attribute_id: "address_zipcode",
attribute_hash: "584ad1a81429a07777ee10ecb4369e50698045486028e8690603de6e69c2a772",
@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)
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)|
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);
}
@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
@gecugamo
gecugamo / babel.config.js
Created January 9, 2023 18:54
Ex Babel Config
module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')
if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
@gecugamo
gecugamo / kin-address-autocomplete.dist.js
Created November 7, 2022 23:20
kin-address-autocomplete.dist.js
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
debugger;
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var KinAddressAutocomplete_1;
import { html, LitElement } from 'lit';
import { customElement, property, query, queryAll, state } from 'lit/decorators.js';
@gecugamo
gecugamo / input.scss
Created September 26, 2022 15:14
Generated by SassMeister.com.
$sizes: 'xs', 'sm', 'md', 'lg';
@each $size in $sizes {
@for $i from 1 through 12 {
$width: 100% / 12 * $i;
.col-#{$size}-#{$i} {
max-width: $width;
flex-basis: $width;
}

TypeScript + JSDoc

​ With TypeScript, a lot of information can be gleaned from TypeScript itself, either through explicit types or inferred types. So when we use TypeScript along with JSDoc, we could end up duplicating our documentation in some cases. When using JSDoc, we advise you to leave the documentation of types to TypeScript, but still utilize JSDoc to add descriptions. ​

Examples

When using JavaScript, we would use JSDoc to document the type, name (for @param), and description for @param and @returns. ​

/**
 * Divides one number by the other
@gecugamo
gecugamo / click-lead-dev-notes.md
Last active September 30, 2021 20:01
Click Lead Landing Page Dev Notes

Links

Current Implementation

  • User browsing on third-party site
  • Click link that plops them on welcome.kin.com/landing and contains query params provider, lead_id, click_id
  • If click_lead doesn't exist in db, 500 error
  • If we have address data and it's from the proper location, send to /quote/about-you
  • If we don't have enough info, send to /start