Skip to content

Instantly share code, notes, and snippets.

View igorparrabastias's full-sized avatar

Igor Parra Bastias igorparrabastias

View GitHub Profile
@codeweft
codeweft / pulumi-profile
Created April 16, 2021 01:14
Pulumi CLI #6029 - Be able to use multiple accounts simultaneously on linux
#!/usr/bin/env bash
set -Eeuo pipefail #https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
trap "usage: pulumi-profile <personal|work>" ERR
# Context: https://github.com/pulumi/pulumi/issues/6029
# Set token values and move this script to /usr/bin or $PATH to have direct access from cli
if [ -z ${1+x} ]; then
echo "usage: pulumi-profile <personal|work>"
exit 0
@ddunkin
ddunkin / cloudsql-proxy.ts
Last active September 21, 2022 15:10
Pulumi functions to setup and add a Google Cloud SQL Proxy sidecar to a Kubernetes deployment
import * as pulumi from '@pulumi/pulumi';
import * as gcp from '@pulumi/gcp';
import * as k8s from '@pulumi/kubernetes';
import * as k8sInputApi from '@pulumi/kubernetes/types/input';
const serviceAccountKeys = new Map<string, gcp.serviceAccount.Key>();
/**
* Creates a service account and key, and sets the cloudsql.client role in IAM.
*/
@abhilash1in
abhilash1in / user-data.sh
Created April 24, 2018 17:06
Install nvm and NodeJS using AWS EC2 user data script
#!/bin/bash
apt-get -y update
cat > /tmp/subscript.sh << EOF
# START UBUNTU USERSPACE
echo "Setting up NodeJS Environment"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
echo 'export NVM_DIR="/home/ubuntu/.nvm"' >> /home/ubuntu/.bashrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /home/ubuntu/.bashrc
# Dot source the files to ensure that variables are available within the current shell
. /home/ubuntu/.nvm/nvm.sh
@goloroden
goloroden / app.js
Last active June 22, 2023 02:10
Async constructors for JavaScript
// In JavaScript, constructors can only be synchronous right now. This makes sense
// from the point of view that a constructor is a function that returns a newly
// initialized object.
//
// On the other hand, it would sometimes be very handy, if one could have async
// constructors, e.g. when a class represents a database connection, and it is
// desired to establish the connection when you create a new instance.
//
// I know that there have been discussions on this on StackOverflow & co., but
// the so-far mentioned counter arguments (such as: doesn't work as expected
@CristalT
CristalT / FileUploader.vue
Last active October 5, 2023 11:20
File Uploader Component for Vue.js using Firebase Storage
<template>
<div>
<input type="file" multiple accept="image/jpeg" @change="detectFiles($event.target.files)">
<div class="progress-bar" :style="{ width: progressUpload + '%'}">{{ progressUpload }}%</div>
</div>
</template>
<script>
@varunnayal
varunnayal / process_max_n_times.js
Created July 20, 2017 15:09
RabbitMQ: Process a message maximum of "N" times using dead letter exchange
var amqp = require('amqplib');
var url = 'amqp://localhost';
var WORK_QUEUE_NAME = 'work.queue';
var WORK_EXCHANGE_NAME = 'work.exchange';
var DEAD_QUEUE_NAME = 'dead.work.queue';
var DEAD_EXCHANGE_NAME = 'dead.work.exchange';
var MAX_RETRY_COUNT = 3;
@juanbrujo
juanbrujo / comunas-regiones.json
Last active June 3, 2024 16:31 — forked from sergiohidalgo/comunas-regiones-chile.json
Comunas y regiones de chile JSON
{
"regiones": [
{
"region": "Arica y Parinacota",
"comunas": ["Arica", "Camarones", "Putre", "General Lagos"]
},
{
"region": "Tarapacá",
"comunas": ["Iquique", "Alto Hospicio", "Pozo Almonte", "Camiña", "Colchane", "Huara", "Pica"]
},
@jgrodziski
jgrodziski / docker-aliases.sh
Last active June 23, 2024 03:01
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #
@randallreedjr
randallreedjr / .elsintrc.js
Created October 13, 2016 14:50
ESLint config file extending local configuration
module.exports = {
  “extends”: “../src/.eslintrc.js”,
  “rules”: {
  “import/no-extraneous-dependencies”: “error”
  }
};
@fwertz
fwertz / app.js
Created May 23, 2016 20:22
Basic load balancing NodeJS (Nginx + PM2 + Express)
import express from 'express';
// ... So much space for unstable dependency imports ...
let app = express();
// ... Insert your own routing magic ...
export default app;