Skip to content

Instantly share code, notes, and snippets.

View asvignesh's full-sized avatar

Vignesh A Sathiyanantham asvignesh

View GitHub Profile
@asvignesh
asvignesh / ContainsTest.java
Last active August 29, 2015 14:21
Java List Contains for Custom Object Type
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by Vignesh on 26-05-2015.
*/
public class ContainsTest {
public static void main(String[] args) {
@asvignesh
asvignesh / functions.php
Created May 27, 2015 14:55
Embed your GIST code in your WordPress blog post without using any plugins
<?php
/**
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
@asvignesh
asvignesh / PortOpenTest.Java
Last active August 29, 2015 14:22
How to check whether the particular port is in use
import java.io.IOException;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
/**
* Created by Vignesh on 26-05-2015.
*/
public class PortOpenTest {
@asvignesh
asvignesh / ExpandDatastore.java
Created August 8, 2015 17:15
Expand the VMFS Datastore to its maximum size
import com.asvignesh.common.MyException;
import com.vmware.vim25.DatastoreHostMount;
import com.vmware.vim25.HostScsiDisk;
import com.vmware.vim25.VmfsDatastoreExpandSpec;
import com.vmware.vim25.VmfsDatastoreOption;
import com.vmware.vim25.mo.*;
import java.rmi.RemoteException;
/**
@asvignesh
asvignesh / SamplePsModule.cs
Created August 27, 2015 14:27
PowerShell Module
using System;
using System.Management.Automation;
namespace SamplePsModule
{
[Cmdlet(VerbsCommon.Get, "Vignesh")]
public class SampleGet : Cmdlet //Must inherit Cmdlet
{
//Parameters
[Parameter(Mandatory = true)]
@asvignesh
asvignesh / MySql-Backup-Postscript.sh
Created November 28, 2017 06:48
Pre and Post script for MySQL server consistent* backup
#!/bin/bash
mysql -u <user> -p<Password> -e 'unlock tables;'
if [ $? -gt 0 ]; then
echo "Failed running mysql unfreeze"
exit 1
else
echo "success"
exit 0
@asvignesh
asvignesh / Build_seed_iso
Created January 6, 2018 07:42
Samples to create a cloud-init configuration ISO.
$ genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
@asvignesh
asvignesh / ec2-metadata Options
Last active October 6, 2020 16:39
EC2 Metadata of instance
Options:
--all Show all metadata information for this host (also default).
-a/--ami-id The AMI ID used to launch this instance
-l/--ami-launch-index The index of this instance in the reservation (per AMI).
-m/--ami-manifest-path The manifest path of the AMI with which the instance was launched.
-n/--ancestor-ami-ids The AMI IDs of any instances that were rebundled to create this AMI.
-b/--block-device-mapping Defines native device names to use when exposing virtual devices.
-i/--instance-id The ID of this instance
-t/--instance-type The type of instance to launch. For more information, see Instance Types.
-h/--local-hostname The local hostname of the instance.
@asvignesh
asvignesh / delete_Snapshots.py
Created January 28, 2018 11:22
Delete old EBS snapshots using Boto3 AWS Lambda Python
from datetime import datetime, timedelta, timezone
import boto3
class Ec2Instances(object):
def __init__(self, region):
print("region "+ region)
self.ec2 = boto3.client('ec2', region_name=region)
@asvignesh
asvignesh / PaginationParams.java
Created April 10, 2018 15:04
PaginationParams.java
package viewmodel;
import play.mvc.QueryStringBindable;
import java.util.Map;
import java.util.Optional;
public class PaginationParams implements QueryStringBindable<PaginationParams> {
private int page;
private int offset;