Skip to content

Instantly share code, notes, and snippets.

@dedunumax
dedunumax / .gitignore Java
Last active December 8, 2023 08:25
A complete .gitignore file for Java.
View .gitignore Java
##############################
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
@dedunumax
dedunumax / Multi-node-Vagrantfile
Last active July 30, 2023 10:20
Multi node sample vagrant file.
View Multi-node-Vagrantfile
Vagrant.configure("2") do |config|
config.vm.define "master" do |master|
master.vm.box = "ubuntu/trusty64"
master.vm.hostname = "master.local"
master.vm.network "private_network", ip: "192.168.2.2"
end
config.vm.define "slave1" do |slave1|
slave1.vm.box = "ubuntu/trusty64"
slave1.vm.network :private_network, ip: "192.168.2.3"
@dedunumax
dedunumax / create_privatebin.py
Last active July 16, 2023 16:09
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://github.com/dedunu/blog/blob/main/2020/2020-06-19-create-privatebin-using-python-3.md
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
"""
@dedunumax
dedunumax / aws_rds_unused_lambda_function.py
Last active July 16, 2023 15:48
This AWS Lambda function will scan for RDS instances with no connections for last 14 days using boto3 and stop them. -https://github.com/dedunu/blog/blob/main/2020/2020-07-04-unused-rds-lambda.md
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
View grep_test.sh
#!/bin/bash
printf 'a\na\nb\nc\nd\nd' > file1
printf 'b\nd' > file2
echo 'Test Case 1, without sort command:'
grep -F -f file2 -v file1 | uniq
echo 'Test Case 1, with sort command:'
grep -F -f file2 -v file1 | sort |uniq
@dedunumax
dedunumax / remove_all_followers.py
Last active December 15, 2022 13:57
Remove all the followers from your twitter account.
View remove_all_followers.py
import tweepy
__author__ = 'dedunumax'
'''
This script will remove all the followers from your twitter account. For that first it will block user one by one and
then unblock them. If you are following your followers, you won't be subscribed to them anymore once you run this job.
Rub this script carefully.
Install tweepy module using pip. To install tweepy run below command in your terminal.
@dedunumax
dedunumax / redis-insert.sh
Created November 16, 2014 06:55
This command will insert first two columns of data.csv file into Redis database as key/value pair.
View redis-insert.sh
cat data.csv | awk -F',' '{print " SET \""$1"\" \""$2 "\"\n"}'| /opt/redis-2.8.17/src/redis-cli --pipe
View RDS.tf
resource "aws_db_instance" "mydb" {
engine = "mysql"
engine_version = "5.6.40"
instance_class = "db.t1.micro"
name = "initial_db"
username = "example"
password = "1234"
allocated_storage = "20"
publicly_accessible = "true"
}
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>
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\""'
}