Skip to content

Instantly share code, notes, and snippets.

View robertsosinski's full-sized avatar

Robert Sosinski robertsosinski

View GitHub Profile
@robertsosinski
robertsosinski / test.html
Created October 28, 2024 13:45
A HTML page that uses Web Compoents, Templates with slot elements, and the Shadow DOM
<html>
<head>
</head>
<body>
<template id="custom-card-template">
<h2><slot name="card-title">Default Card Title</slot></h2>
<p><slot name="card-content">Default content goes here.</slot></p>
</template>
<custom-card>
@robertsosinski
robertsosinski / eslint.config.js
Last active October 23, 2024 16:46
ESLint config for JS, Astro, and React
import globals from 'globals'
import pluginJs from '@eslint/js'
import stylistic from '@stylistic/eslint-plugin'
import pluginReact from 'eslint-plugin-react'
import pluginAstro from 'eslint-plugin-astro'
export default [
// Configure directories to ignore
{
ignores: ['dist', 'public'],
@robertsosinski
robertsosinski / add_test.astro
Created October 17, 2024 20:25
VSCode Astro Error Example
<app-complex-time>
<button>click</button>
<div class="target"></div>
</app-complex-time>
<script>
import {actions} from "astro:actions";
class AppComplexTime extends HTMLElement {
async connectedCallback() {
@robertsosinski
robertsosinski / blackjack.js
Created June 11, 2022 15:52
Blackjack Strategy
// All potential actions that can be taken
let action = [
'hit', // 0
'stand', // 1
'double', // 2
'split', // 3
'blackjack' // 4
];
// Used for hard hands, when the player hand does not have an Ace (11)
-- 1. must be between 3 and 20 characters,
-- 2. must be only:
-- a. lowercase letters,
-- b. numbers,
-- c. individual dashes.
-- 3. must start with a letter,
-- 4. must not end with a dash.
'^[a-z]([-](?![-])|[a-z0-9]){1,18}[a-z0-9]$'
@robertsosinski
robertsosinski / keybase.md
Last active January 12, 2021 16:56
keybase.md

Keybase proof

I hereby claim:

  • I am robertsosinski on github.
  • I am sosinski (https://keybase.io/sosinski) on keybase.
  • I have a public key ASAPxI5BFCvyApljKvTgZLqHO2P5ae6jaG_jncmP2EI1iQo

To claim this, I am signing this object:

@robertsosinski
robertsosinski / create-encrypted-ssm-parameter.js
Created September 6, 2019 20:03
Create an encrypted SSM Parameter using a Custom Cloud Formation Resource
const aws = require("aws-sdk");
const https = require("https");
const url = require("url");
// Sends a response to the pre-signed S3 URL
function sendResponse(event, context, callback, responseStatus, responseData) {
const responseBody = JSON.stringify({
Status: responseStatus,
Reason: `See the details in CloudWatch Log Stream: ${context.logStreamName}`,
PhysicalResourceId: event.ResourceProperties.Name,
@robertsosinski
robertsosinski / stddev.sql
Created June 19, 2019 20:11
Calculating out-of-bounds values using standard deviation
with nums as (
select * from (values (18), (3), (3), (2), (4), (2), (5), (3), (12), (0.00003), (4), (2)) as n (x)
), a as (
select
stddev(nums.x) as sdev,
abs(avg(nums.x)) as aavg,
numrange(
(abs(avg(nums.x) - stddev(nums.x))),
(abs(avg(nums.x) + stddev(nums.x)))
) as bounds
@robertsosinski
robertsosinski / config.yml
Last active June 14, 2019 15:48
Example AWS Config Custom Rule Lambda
AWSTemplateFormatVersion: 2010-09-09
Description: Configure Config Rules
Resources:
ConfigS3BucketPublicReadProhibitedRule:
Type: AWS::Config::ConfigRule
Properties:
ConfigRuleName: s3-bucket-public-read-prohibited
Description: Checks that your Amazon S3 buckets do not allow public read access. The rule checks the Block Public Access settings, the bucket policy, and the bucket access control list (ACL).
MaximumExecutionFrequency: TwentyFour_Hours
@robertsosinski
robertsosinski / aws-sdk-cli-sts.js
Created May 8, 2019 21:33
AWS SDK CLI STS Usage
let fs = require("fs");
let path = require("path");
let AWS = require("aws-sdk");
let cliPath = path.resolve(process.env.HOME, ".aws", "cli");
/*
NOTES: Make sure you alias the SHA1 fingerprinted cache token to the profile name
E.G. ln -s ~/.aws/cli/cache/09a19nczc3zvza58zrftetyfso7yw9d48u6ugsel.json profile