Skip to content

Instantly share code, notes, and snippets.

View abdmun8's full-sized avatar
:octocat:
Focusing

Abdul Munim abdmun8

:octocat:
Focusing
View GitHub Profile
@abdmun8
abdmun8 / lambda-describe-network.md
Created July 20, 2022 09:02
AWS Lambda:The provided execution role does not have permissions to call DescribeNetworkInterfaces on EC2

via Managed Policy

To grant Lambda necessary permissions to dig in to a VPC where a production RDS db resides in a private subnet. As mentioned by @portatlas above, the AWSLambdaVPCAccessExecutionRole managed policy fits like a glove (and we all know use of IAM Managed Policies is an AWS-recommended best-practice). This is for Lambdas with a service role already attached. AWS CLI

  1. Get Lambda Service Role Ask Lambda API for function configuration, query the role from that, output to text for an unquoted return.
aws lambda get-function-configuration \
 --function-name <> \
@abdmun8
abdmun8 / copy-local-storage.md
Created May 9, 2022 23:50
Copy Local Storage

Run this script on console source window

const t=JSON.stringify(localStorage);console.log(`Object.entries(${t}).forEach(e=>{localStorage.setItem(e[0],e[1]);});`);

Paste and run output script to console target window

@abdmun8
abdmun8 / copy-session-storage.md
Last active May 9, 2022 23:47
Copy Session Storage

Run this script on console source window

const t=JSON.stringify(sessionStorage);console.log(`Object.entries(${t}).forEach(e=>{sessionStorage.setItem(e[0],e[1]);});`);

Paste and run output script to console target window

@abdmun8
abdmun8 / delete-untagged-images-ecr.md
Created January 13, 2022 13:14
Delete untagged images on AWS Elastic Container Registry

Delete untagged images on AWS Elastic Container Registry

Example using ap-southeast-1 region

#!/bin/bash
REPOS=$(aws ecr describe-repositories --region ap-southeast-1 --query 'repositories[].repositoryName' --output text)
for repo in $REPOS; do
    TAGS=$(aws ecr list-images --region  ap-southeast-1 --repository-name $repo --filter tagStatus=UNTAGGED --query 'imageIds[].imageDigest' --output text)
    for tag in $TAGS; do
        echo “Deleting image: $tag”
 aws ecr batch-delete-image --region ap-southeast-1 --repository-name $repo --image-ids imageDigest=$tag
@abdmun8
abdmun8 / commit-how-to.md
Last active January 13, 2022 00:27
Git commit how to

Background

By writing good commits, you are simply future-proofing yourself. You could save yourself and/or coworkers hours of digging around while troubleshooting by providing that helpful description.

To come up with thoughtful commits, consider the following:

  • Why have I made these changes?
  • What effect have my changes made?
  • Why was the change needed?
  • What are the changes in reference to?
@abdmun8
abdmun8 / delete-files-older-than-7-days.md
Last active May 26, 2022 16:56
Delete Files older than 7 days windows

Delete Files older than 7 days on windows

ForFiles /p "C:\path\to\folder" /s /d -7 /c "cmd /c del /q @file"

or

ForFiles -p "C:\path\to\folder" -s -m *.bak -d -7 -c "Cmd /C del @FILE"
# paste in your console after login
var ids = ['FORCE_ENROLLMENT','freezeSearch'];ids.forEach(e => {var i = document.getElementById(e); i.style.display = 'none'});
@abdmun8
abdmun8 / iterm2.md
Created May 31, 2021 01:43 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@abdmun8
abdmun8 / delete_file.php
Created August 4, 2020 14:41
Delete file older than 7 days using php
<?php
// save in directory where file exists
$dir = __DIR__;
$files = scandir($dir);
$date = date_create();
$limit = strtotime('-7 day', date_timestamp_get($date));
$total = 0;
$count = 0;
foreach ($files as $key => $file) {
@abdmun8
abdmun8 / Error on 'react-native start' or 'npm start' or 'yarn start'
Last active July 6, 2020 03:00
Error on 'react-native start' / 'npm start' / 'yarn start'
\node_modules\metro-config\src\defaults\blacklist.js
FROM
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];