Skip to content

Instantly share code, notes, and snippets.

View chgasparoto's full-sized avatar
:octocat:
🇧🇷 🇳🇱

Cleber Gasparoto chgasparoto

:octocat:
🇧🇷 🇳🇱
View GitHub Profile
@chgasparoto
chgasparoto / index.ts
Created October 13, 2023 09:14
AWS Bedrock Typescript
import {
BedrockRuntimeClient,
InvokeModelCommand,
} from '@aws-sdk/client-bedrock-runtime';
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda';
const client = new BedrockRuntimeClient({});
export const handler = async (
event: APIGatewayProxyEventV2,
// 1) Why do the anchors, when clicked on, alert -1 instead of their respective counter inside of the loop? How can you fix the code so that it does alert the right number?
<a href="#">text</a><br><a href="#">link</a>
<script>
var as = document.getElementsByTagName('a');
for ( var i = as.length; i--; ) {
as[i].onclick = function() {
alert(i);
return false;
}
@chgasparoto
chgasparoto / main.tf
Created March 3, 2019 03:10
[Part-3][Medium] - Como deployar AWS Lambda Layers com Terraform e Node.js
resource "null_resource" "build_lambda_layers" {
triggers {
layer_build = "${md5(file("${local.layers_path}/package.json"))}"
}
provisioner "local-exec" {
working_dir = "${local.layers_path}"
command = "npm install --production && cd ../ && zip -9 -r --quiet ${local.layer_name}.zip *"
}
}
@chgasparoto
chgasparoto / index.js
Last active March 3, 2019 04:15
[Part-2][Medium] - Como deployar AWS Lambda Layers com Terraform e Node.js
const moment = require('moment')
const Joi = require('joi')
exports.handler = async (event = {}) => {
const { error, value } = Joi.validate(event, { date: Joi.date().required() })
if (error) {
throw new Error(error.message)
}
@chgasparoto
chgasparoto / main.tf
Created March 3, 2019 02:25
[Part-1][Medium] - Como deployar AWS Lambda Layers com Terraform e Node.js
provider "aws" {
region = "${var.region}"
}
locals {
layer_name = "moment-joi"
layers_path = "${path.module}/../layers/${local.layer_name}/nodejs"
}
resource "aws_lambda_layer_version" "this" {
@chgasparoto
chgasparoto / gist:dfcbd5b1582e1164d26160b906de919e
Created February 21, 2018 19:22 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@chgasparoto
chgasparoto / lambda.js
Created November 22, 2017 16:18
Lambda function to parse and send AWS CloudWatch notifications to Slack
var https = require('https');
var util = require('util');
var CHANNEL = "#YOUR_CHANNEL";
var EMOJI = ":alert:";
var PATH = '/services/YOUR_KEY';
function tryParseJSON(jsonString) {
try {
var o = JSON.parse(jsonString);
@chgasparoto
chgasparoto / MY_date_helper.php
Last active August 29, 2015 13:56
CodeIgniter date helper - Converts a numeric representation of a month into a short textual with three letters
<?php
/**
* Converts a numeric representation of a month into a short textual
* with three letters(Jan through Dec)
*
* @param string $month - 01 through 12
* @param string $lang - language of the output month
* @return string - month converted
*/
@chgasparoto
chgasparoto / date.php
Created February 26, 2014 02:33
Valides and converts a date in PHP
<?php
function validaData($date, $format = 'Y-m-d H:i:s')
{
$v_date = date_create_from_format($format, $date);
$v_date = date_format($v_date, $format);
return ($v_date && $v_date == $date);
}
@chgasparoto
chgasparoto / MY_Form_validation.php
Last active August 29, 2015 13:56
Improves the is_unique function of the core of CI, letting updates don't fill the rule
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Extend Form Validation Class and improve the is_unique function to updates querys
*
* @package CodeIgniter
* @subpackage Libraries
* @category Validation