Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Always Learning!

Dedunu Dhananjaya dedunumax

:octocat:
Always Learning!
View GitHub Profile
View blogger-theme.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' expr:lang='data:blog.locale' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
<meta content='width=device-width, initial-scale=1.0' name='viewport'/>
<meta content='A travel blog.' name='description'/>
<b:include data='blog' name='all-head-content'/>
<link href='{{ site.baseurl }}/favicon.png' rel='shortcut icon'/>
<link href='https://cdn.rawgit.com/dreampulse/computer-modern-web-font/master/fonts.css' rel='stylesheet' type='text/css'/>
<title>travel - Dedunu Dhananjaya</title>
@dedunumax
dedunumax / aws_rds_unused_lambda_function.py
Last active Jul 6, 2020
This AWS Lambda function will scan for RDS instances with no connections for last 14 days using boto3 and stop them. - https://www.dedunu.info/2020/07/unused-rds-lambda.html
View aws_rds_unused_lambda_function.py
"""RDS-Unused AWS Lambda Function
It will go through the REGION's RDS instances and check on CloudWatch for the unused
instances and will stop them.
"""
import json
from datetime import datetime, timedelta
from multiprocessing import Process, Pipe
import boto3
@dedunumax
dedunumax / create_privatebin.py
Last active Jun 19, 2020
Sample program to create PrivateBin notes using Python 3. It might come handy in automation. Code is based on https://github.com/r4sas/PBinCLI repository. Thanks a lot @r4sas! https://www.dedunu.info/2020/06/create-privatebin-using-python-3.html
View create_privatebin.py
"""
This script creates a PrivateBin using Python 3.
Code is based on https://github.com/r4sas/PBinCLI repository.
Thanks a lot @r4sas!
Below modules should be installed in the environment.
requests
base58
pycryptodome
"""
View virtual.sh
function virt() {
osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"Ubuntu\""
ssh -Ap 5001 vuser@virtual-server
osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"One Dark\""
}
View production_bridge.sh
function prod() {
ssh -A luser@laptop -C 'osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"Red Alert\""'
ssh -A buser@bridge.company.org
ssh -A luser@laptop -C 'osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"Ubuntu\""'
}
View pg_loader_sample.load
LOAD DATABASE
FROM mysql://root:Password123@mysqldb.example.com/real_db
INTO pgsql://postgres:Password456@pgserver101.example.com/adventure_db
WITH include drop, create tables
SET search_path to 'public'
INCLUDING ONLY TABLE NAMES MATCHING 'user'
View pg_loader_example.load
LOAD DATABASE
FROM mysql://<mysql_user>:<mysql_password>@<mysql_host>/<source_databases>
INTO pgsql://<postgres_user>:<postgres_password>@<postgres_host>/<target_database>
WITH INCLUDE DROP, CREATE TABLES
SET search_path to 'public'
INCLUDING ONLY TABLE NAMES MATCHING 'sample_table'
View terraform_err.tf
Acquiring state lock. This may take a few moments...
Error: Error locking state: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed
status code: 400, request id: L2CH7KK3QCAEHSC1TJ1VLBMNBRVV4CQNSO5AEMVJY66Q9ASUAAJN
Lock Info:
ID: 21e2b2bb-c123-2383-eece-7a5eaab4f645
Path: s3/path/to/the/state/file
Operation: OperationTypePlan
Who: username@hostname
Version: 0.11.14
View current_trx.sql
SELECT *
FROM information_schema.innodb_trx
WHERE trx_mysql_thread_id = CONNECTION_ID()\G
View slow_postgres.sql
SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes'
ORDER BY duration DESC;
You can’t perform that action at this time.