Skip to content

Instantly share code, notes, and snippets.

View gbalbuena's full-sized avatar
🏕️

Gabriel gbalbuena

🏕️
View GitHub Profile
@gbalbuena
gbalbuena / async-redis.js
Created October 30, 2019 05:44
jest mock library for async-redis deps, it has to be in __mock__ dir
let mock = { mock: true };
const client = {
set: function() {
},
get: function() {
return JSON.stringify(mock)
},
quit: function() {
}
@gbalbuena
gbalbuena / healthcheck.js
Last active October 25, 2019 04:22
lambda to test health of services like postgres, redis, sqs
const pg = require('pg');
const asyncRedis = require("async-redis");
const key = "HEALTH_CHECK";
async function check_redis() {
const client = asyncRedis.createClient();
client.on("error", (err) => {
throw err
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gbalbuena
gbalbuena / web-servers.md
Created October 21, 2019 05:11 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
aws --endpoint-url http://localhost:9324 \
sqs create-queue \
--queue-name "test"
aws --endpoint-url http://localhost:9324 \
sqs send-message \
--queue-url http://localhost:9324/queue/test \
--message-body "Hola!"
curl https://ui-avatars.com/api/?name=G%20B&size=512&rounded=true&color=FCD116&background=0038A8
get $(npm view @gbalbuena/aws-node-simple-http-endpoint dist.tarball)
tar xzf aws-node-simple-http-endpoint-1.0.2.tgz && \\
zip aws-node-simple-http-endpoint-1.0.2.zip $(tar tf aws-node-simple-http-endpoint-1.0.2.tgz) && \\
rm -r -f -- $(tar tf aws-node-simple-http-endpoint-1.0.2.tgz) && \\
aws-node-simple-http-endpoint-1.0.2.tgz
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject"
],
@gbalbuena
gbalbuena / Dockerfile
Created June 19, 2019 00:07
terraform-aws-cli-alpine docker
FROM alpine:edge
RUN apk add --update
RUN apk add ca-certificates
RUN apk add terraform
RUN apk add aws-cli --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
ADD . /app
WORKDIR /app
@gbalbuena
gbalbuena / superagent.js
Last active November 3, 2022 10:50 — forked from charleskorn/superagent.js
A Jest mock for superagent. Place in your __mocks__ directory.
llet mockDelay;
let mockError;
let mockResponse = {
get: jest.fn(),
ok: true,
status: 200,
toError: jest.fn(),
};
let mockResponseBodies;