Skip to content

Instantly share code, notes, and snippets.

View jcbagtas's full-sized avatar
💭
IaC <3 DevOps

JC Bagtas jcbagtas

💭
IaC <3 DevOps
View GitHub Profile
@jcbagtas
jcbagtas / networkdays.js
Last active November 11, 2023 18:46
Calculate Working Days between two dates. Javascript equivalent of Microsoft Excel's NETWORKDAYS() function.
/****
Javascript equivalent of Microsoft Excel's NETWORKDAYS() function.
Calculate Working Days between two dates.
Optimized for performance. accepts String '12/18/1990' and new Date('12/18/1990') Object.
usage:
networkdays('12/18/1990','12/18/2016');
networkdays(new Date(),'12/18/2016');
@jcbagtas
jcbagtas / terraform.tf
Created April 14, 2020 13:28
Merge a variable List of Maps in Terraform 0.12
# This gist mimics the supposed behavior of
# variable = merge(someListOfMaps[*].parameters...)
# or
# policy_parameters = merge(data.azurerm_policy_definition.d_policy_definitions[*].parameters...)
locals {
policy_parameters = [
for key,value in data.azurerm_policy_definition.d_policy_definitions:
{
parameters = jsondecode(value.parameters)
@jcbagtas
jcbagtas / aws-s3-public-by-tag.json
Created January 28, 2023 07:57
AWS S3 public read based on object tag
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Principal": {
"AWS": "*"
},
"Effect": "Allow",
"Action": [
@jcbagtas
jcbagtas / auth.php
Last active August 23, 2021 12:11
Get current Laravel active session from outside laravel instance. Laravel 5.2
<?php
/**
* Get current Laravel active session from outside laravel instance.
* Tested Laravel 5.2
*
*
*/
function getLaravelUser()
{
require __DIR__ . '\path\to\bootstrap\autoload.php';
@jcbagtas
jcbagtas / role-email-addresses.txt
Created March 20, 2018 06:09
Role Email Addresses
abuse
admin
all
billing
contact
everyone
ftp
jobs
list
marketing
@jcbagtas
jcbagtas / config.sh
Created February 19, 2021 05:21
Configuration-Baseline
# workstation-ks.cfg
# version 1.0.1 2012-03-15
# Copyright 2010,2011,2012 Red Hat Inc., Durham, North Carolina.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
@jcbagtas
jcbagtas / confset.pl
Last active February 18, 2021 08:20
perl confset.pl ./some.cf "key = value" or perl confset.pl ./some.conf "key=value"
#!/usr/bin/perl
use strict;
my $scriptname = $0;
my $separator = '=';
my $whitespace = 0;
my @files = ();
my @namevalues = ();
@jcbagtas
jcbagtas / banner-creator.sh
Created November 27, 2020 07:58
Create a Bannered Text that demands attention.
## EMBED THIS FUNCTION INSIDE YOUR BASH FILE
banner () {
case $3 in
RED)COLOR='\033[0;31m'
;;CYAN)COLOR='\033[0;36m'
;;GREEN)COLOR='\033[0;32m'
;;LGREEN)COLOR='\033[1;32m'
;;PURPLE)COLOR='\033[0;35m'
;;BROWN)COLOR='\033[0;33m'
@jcbagtas
jcbagtas / az-loations.md
Created September 14, 2020 03:25
Azure Region List Location
az account list-locations -o table
DisplayName Latitude Longitude Name
East Asia 22.267 114.188 eastasia
Southeast Asia 1.283 103.833 southeastasia
Central US 41.5908 -93.6208 centralus
East US 37.3719 -79.8164 eastus
@jcbagtas
jcbagtas / install-az-extensions.md
Created August 27, 2020 15:55
Install AZ Extensions

How to Install Azure CLI Extensions

Personal Note on how to install Azure CLI Extension or AZ Extensions

References

List of Azure Extensions

az extension add --name [extension]