Skip to content

Instantly share code, notes, and snippets.

View carlosvega20's full-sized avatar

Carlos Vega carlosvega20

  • San Francisco, CA
View GitHub Profile
const getTree = barcode => {
const barcodeLength = barcode.length;
const firstTwoDigits = parseInt(barcode.slice(0,2));
const dic = {
'bluecypress': {digits: [45,56], length: 8, name: 'Blue Ice Arizona Cypress'},
'palm': {digits: [76, 43], length: 12, name: 'The Palm Tree'},
'maple': {digits: [23, 12,45,54], length: 6, name: 'Maple Trees'}
};
import * as cdk from 'aws-cdk-lib';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as appsync from 'aws-cdk-lib/aws-appsync';
import * as iam from 'aws-cdk-lib/aws-iam';
const { Stack, App, RemovalPolicy } = cdk;
class GraphQLAPIStack extends Stack {
const { graphql, buildSchema } = require('graphql');
const { makeExecutableSchema } = require('graphql-tools');
const AWS = require('aws-sdk');
// Set up AWS DynamoDB
const dynamodb = new AWS.DynamoDB.DocumentClient();
const tableName = 'Items'; // Your DynamoDB table name
// Define your GraphQL schema
const typeDefs = `
const fastify = require('fastify')({ logger: true });
const mysql = require('fastify-mysql');
const Joi = require('joi'); // For request validation
// Register the fastify-mysql plugin and set up the database connection with a connection pool
fastify.register(mysql, {
connectionString: 'mysql://your_username:your_password@your_database_url/your_database_name',
pool: {
min: 0,
max: 10,
@carlosvega20
carlosvega20 / customCSSEditor.css
Created March 11, 2022 23:11
JSON Viewer for Notable.app | Custom | JS | Editor
.json-skin { font-family: monospace,'Courier'; }
.json-skin ul { padding-left: 0; display: inline; list-style: none; }
.json-skin .elm-arbol { display: inline; }
.json-skin li { padding-left: 20px; }
.json-skin ul.elm-object::before { content: '{'; font-weight: bold; }
.json-skin ul.elm-object::after { content: '}'; font-weight: bold; }
.json-skin ul.elm-array::before { content: '['; font-weight: bold; }
.json-skin ul.elm-array::after { content: ']'; font-weight: bold; }
.json-skin span.elm-more {cursor: pointer; }
.json-skin span.elm-more::before { content: '...'; font-weight: bold; color: gray; }
@carlosvega20
carlosvega20 / Custom|JS|Editor.js
Last active March 12, 2022 20:47
Excel markdown table | Notable.app Plugin
const require = (url) => {
const head = document.getElementsByTagName('head')[0];
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
head.appendChild(script);
}
require("https://cdn.jsdelivr.net/npm/hyperformula/dist/hyperformula.full.min.js");
@carlosvega20
carlosvega20 / arrow.js
Created October 8, 2018 22:26
Arrow function
myFunc = () => {
var mensaje='hello World!';
console.log(mensaje);
};
//Can be also expressed as:
/*
function myFunc() {
var mensaje='hello World!';
const npm = async moduleName => {
console.log('Fetching ' + moduleName + '... just one second');
let res = await fetch('https://cdn.jsdelivr.net/npm/' + moduleName + '@latest');
let bd = await res.text();
console.log(bd);
};
// npm('lodash');
@carlosvega20
carlosvega20 / vundle
Created July 6, 2018 20:00
vim vundle
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
set runtimepath^=~/.vim/bundle/ctrlp.vim
source ~/.vim/vundle
execute pathogen#infect()
syntax on
filetype plugin indent on
set background=dark
colorscheme solarized