Skip to content

Instantly share code, notes, and snippets.

View ethanhinson's full-sized avatar

Ethan Hinson ethanhinson

View GitHub Profile
@ethanhinson
ethanhinson / amplifyToZod.ts
Created April 22, 2024 02:29
Create Zod schema from Amplify Model
export function createZodSchema(schemaMap: Record<string, ModelField>) {
let schemaObject: { [key: string]: z.ZodTypeAny } = {};
for (const key in schemaMap) {
const field = schemaMap[key];
let baseType: z.ZodTypeAny;
if (typeof field.type === 'string') {
switch (field.type) {
case 'ID':
case 'String':
case 'AWSJSON':
@ethanhinson
ethanhinson / get-creds-from-jenkins.groovy
Created January 8, 2024 23:11
Extract secrets stored in Jenkins credentials.
import org.jenkinsci.plugins.plaincredentials.StringCredentials
import com.cloudbees.plugins.credentials.CredentialsProvider
import com.cloudbees.plugins.credentials.domains.DomainRequirement
import groovy.json.JsonBuilder
import jenkins.model.Jenkins
import hudson.model.Job
String jobName = "YourFolder/YourMultibranch/YourJob"
Job job = Jenkins.instance.getItemByFullName(jobName, Job.class)
package secrets
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
"github.com/propertybrands/btt-cloud-deployment-manager/internal/app"
)
var secretsManagerConnection *secretsmanager.Client
@ethanhinson
ethanhinson / generate.sh
Created November 17, 2019 20:52
Iterate the list of .proto files in a directory recursively
#!/bin/bash
for x in $(find "$(pwd)/apis" -name '*.proto'); do
protoc -I /usr/local/include -I "$(pwd)"/apis \
-I $GOPATH/src \
--go_out=paths=source_relative,plugins=grpc:gen/go \
--grpc-gateway_out=logtostderr=true:. "$x"
done
@ethanhinson
ethanhinson / data.json
Last active February 13, 2019 17:06
Hub Options Data Structure
{
"settings": {
"ldrc": {
/// Stuff
},
"components": {
"MyComponent": {
/// Stuff
}
}
@ethanhinson
ethanhinson / styleExamples.css
Last active February 4, 2019 19:38
Provide examples for how the Hub UI can be customized with CSS.
/**
* Style overrides to unset hidden descriptions.
* Be wary of mobile and pushing other content down the page when
* leaving the description open.
*/
.bt-details__description p {
max-height: none !important;
overflow: visible;
visibility: visible !important;
width: 100% !important;
@ethanhinson
ethanhinson / webpack.withOpts.js
Created November 14, 2018 15:51
Webpack Define plugin example
const merge = require('webpack-merge');
const webpack = require('webpack');
const prod = require('./webpack.prod');
module.exports = merge(prod, {
plugins: [
new webpack.DefinePlugin({
foo: JSON.stringify('bar'),
someProps: JSON.stringify({
one: 2,
{"responseHeader":{"status":0,"QTime":2},"suggest":{"barSuggester":{"foo":{"numFound":3,"suggestions":[{"term":"Foo","weight":0,"payload":"Foo payload"},{"term":"FooDiddlyDoo","weight":0,"payload":"Bar payload"},{"term":"FooDiddlyDee","weight":0,"payload":"Baz payload"}]}}}}
@ethanhinson
ethanhinson / smartemail.java
Created December 15, 2017 19:29
Simple Smart Email
/*
Add a dependancy via Gradle:
dependencies {
compile 'createsend:createsend-java:5.1.0'
}
Or Maven:
<dependency>
<groupid>createsend-java</groupid>
<artifactid>createsend-java</artifactid>
@ethanhinson
ethanhinson / activities.json
Last active December 15, 2017 19:27
JSON Sample
{
"To": "Someone <someone@bluetent.com>",
"Data": {
"activities": [
{
"name": "My Activity Name",
"link": "https://www.explorie.com/some-link",
"image_url": "https://www.explorie.com/path/to/images/image.jpg"
},
{