Skip to content

Instantly share code, notes, and snippets.

@fbatroni
fbatroni / DeadLetterQueueStack.ts
Created July 6, 2022 17:01 — forked from brianfoody/DeadLetterQueueStack.ts
Dead Letter Queue example with CDK
import { Queue } from "@aws-cdk/aws-sqs";
import { App, Duration, Stack, StackProps } from "@aws-cdk/core";
import { Runtime, Code, Function } from "@aws-cdk/aws-lambda";
import { SqsEventSource } from "@aws-cdk/aws-lambda-event-sources";
class DeadLetterQueue extends Stack {
constructor(parent: App, name: string, props?: StackProps) {
super(parent, name, props);
@fbatroni
fbatroni / gist:aa6b1db71aa83b8f079592b6954ede63
Created November 22, 2021 16:05 — forked from mbains/gist:3406184
Factory pattern using C++ templates
#include <iostream>
#include <map>
using namespace std;
class BaseClass{
public:
virtual int funk() {
return 0;
}
@fbatroni
fbatroni / .bash
Created October 14, 2021 22:05 — forked from devonhk/.bash
detect changed files in mono repo
CHANGED_FOLDERS=$(git diff --name-status $TRAVIS_COMMIT_RANGE -- | awk 'BEGIN {FS="/"} {print $1}' | awk '{print $2}' | uniq)
anchors:
tf_init: &tf_init |
terraform init -lock=false \
-backend-config="resource_group_name=terraform" \
-backend-config="key=${{ env.TF_BACKEND_KEY }}" \
-backend-config="access_key=${{ secrets.TF_BACKEND_ACCESS_KEY }}" \
-backend-config="storage_account_name=${{ secrets.TF_BACKEND_SA }}"
setup_backend_key: &setup_backend_key "githubdeployment.${{ github.event.inputs.environment }}.aks_setup.terraform.tfstate"
configure_backend_key: &configure_backend_key "githubdeployment.${{ github.event.inputs.environment }}.aks_configure.terraform.tfstate"
@fbatroni
fbatroni / npm-scripts-for-docker.md
Created March 4, 2021 01:01 — forked from duluca/npm-scripts-for-docker.md
npm scripts for Docker

These are generic npm scripts that you can copy & paste into your package.json file as-is and get access to convinience scripts to manage your Docker images all in one place.

How to Use

npm i -g mrm-task-npm-docker
npx mrm npm-docker

Contribute

Here's the code repository https://github.com/expertly-simple/mrm-task-npm-docker

@fbatroni
fbatroni / openvpn_on_google_cloud.md
Created December 21, 2020 20:17 — forked from neuni/openvpn_on_google_cloud.md
Create a openVPN server on Google Cloud Platform to connect to your Google Cloud network using openVPN and/or to route your internet traffic through the VPN (Road Warrior Scenario)

Install openVPN server on Google Cloud using Pritunl

Purpose:

Create a openVPN server on Google Cloud Platform to connect to your Google Cloud network using openVPN and/or to route your internet traffic through the VPN (Road Warrior Scenario)

Create instance

  • Create new instance in default network
  • Chosse Ubuntu 16.04 LTS
@fbatroni
fbatroni / async.js
Created July 31, 2020 00:59 — forked from bschwartz757/async.js
Async/await function to fetch data from multiple URLs in parallel
/* Client side, works in Chrome 55 and Firefox 52 without transpilation */
//https://blogs.msdn.microsoft.com/typescript/2016/11/08/typescript-2-1-rc-better-inference-async-functions-and-more/
async function fetchURLs() {
try {
// Promise.all() lets us coalesce multiple promises into a single super-promise
var data = await Promise.all([
/* Alternatively store each in an array */
// var [x, y, z] = await Promise.all([
// parse results as json; fetch data response has several reader methods available:
//.arrayBuffer()
@fbatroni
fbatroni / applescript_launch_command_on_idle.txt
Created February 1, 2018 16:51
AppleScript - Launch command if computer has been idle for X seconds
property idleTest : 180 -- How long to be idle (in seconds) before activating script
on idle_time()
set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'")
return idleTime
end idle_time
script should_run_matrix
set idleComp to false
-- this repeat loop polls the idle time every 30 seconds to determine
@fbatroni
fbatroni / dev_random.py
Created January 16, 2018 22:19
Example of python implementation of /dev/random
#!/usr/bin/env python
import os
import argparse
import binascii
from sys import argv, stdout
# default values
DEFAULT_ENTROPY = 4096*16
@fbatroni
fbatroni / gist:0ce8a548d2e64d45bcc00142739eca06
Created December 28, 2017 01:35
ES6 Class With Inheritance
'use strict';
const EventEmitter = require('events').EventEmitter;
const SomeClass = (() => {
class SomeClass extends SomeOtherClass {
constructor() {
super();
EventEmitter.call(this);
}