Skip to content

Instantly share code, notes, and snippets.

View dedunumax's full-sized avatar

Dedunu Dhananjaya dedunumax

View GitHub Profile
@dedunumax
dedunumax / .gitignore Java
Last active March 23, 2024 12:30
A complete .gitignore file for Java.
##############################
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
resource "aws_organizations_policy" "plan_1_policy" {
name = "dedunu-info-backup-plan-1-policy"
type = "BACKUP_POLICY"
content = jsonencode(local.plan1)
}
resource "aws_organizations_policy_attachment" "plan_1_policy_attachment" {
policy_id = aws_organizations_policy.plan_1_policy.id
target_id = "<account-id>"
@dedunumax
dedunumax / SwapInteger.java
Last active February 10, 2024 04:26
Swap two integer variables with out a third variable Java
public class SwapInteger{
public static void main(String args[]){
int a = 5;
int b = 10;
System.out.println("Before swapping.");
System.out.println("a = " + a);
System.out.println("b = " + b);
@dedunumax
dedunumax / FileSizeWebScript.java
Last active January 3, 2024 16:01
Calculates folder size from given nodeRefId.
package org.dedunu.alfresco;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
@dedunumax
dedunumax / Multi-node-Vagrantfile
Last active July 30, 2023 10:20
Multi node sample vagrant file.
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
"""
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
"""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
#!/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.
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.
cat data.csv | awk -F',' '{print " SET \""$1"\" \""$2 "\"\n"}'| /opt/redis-2.8.17/src/redis-cli --pipe