Skip to content

Instantly share code, notes, and snippets.

View imadi's full-sized avatar

Adithya Krishna imadi

View GitHub Profile
@imadi
imadi / Dockerfile
Created September 9, 2020 05:51 — forked from tcnksm/Dockerfile
Dockerfile for apache container
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y apache2
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
RUN echo 'Hello, docker' > /var/www/index.html
@imadi
imadi / curl-get-status-code-and-response-body.sh
Last active June 19, 2020 03:33 — forked from maxclaus/curl-get-status-code-and-response-body.sh
Curl - Get status code and response body
LC_CTYPE=C
URL="http:/www.google.com"
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" $URL)
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -E 's/HTTPSTATUS\:[0-9]{3}$//')
# extract the status
File f = new File("/Users/adithyakrishna/playroom/graphql-service-two/test.tgf")
def list = f.collect { it }
def dependencyList = []
for (int i = 1; i < list.size(); i++) {
if (list.get(i) == "#") {
break
}
def dependencyName = list.get(i).split(" ")[1]
dependencyList.add(dependencyName.substring(0, dependencyName.lastIndexOf(":")))
@imadi
imadi / mvn.tree.parse.groovy
Created May 29, 2020 08:46 — forked from vasporig/mvn.tree.parse.groovy
Maven dependency tree parsing in groovy
def treeFile = new File('tree.txt')
class Node{
String name;
Node parent;
def children= [];
String toString(){name}
}
@imadi
imadi / GetDateFormat.groovy
Created November 15, 2017 08:05
Gets the dateformat from a given string
def getDateFormat(dateString) {
Map<String, String> DATE_FORMAT_REGEXPS = new HashMap<String, String>() {
{
put("^\\d{8}\$", "yyyyMMdd");
put("^\\d{1,2}-\\d{1,2}-\\d{4}\$", "dd-MM-yyyy");
put("^\\d{4}-\\d{1,2}-\\d{1,2}\$", "yyyy-MM-dd");
put("^\\d{1,2}/\\d{1,2}/\\d{4}\$", "MM/dd/yyyy");
put("^\\d{4}/\\d{1,2}/\\d{1,2}\$", "yyyy/MM/dd");
put("^\\d{1,2}\\s[a-z]{3}\\s\\d{4}\$", "dd MMM yyyy");
put("^\\d{1,2}\\s[a-z]{4,}\\s\\d{4}\$", "dd MMMM yyyy");
@imadi
imadi / s3_up.groovy
Created October 17, 2017 05:21 — forked from atomsfat/s3_up.groovy
Upload to S3 with Groovy
/* Script to upload files to S3.
* @author Tomas Salazar
*/
@GrabResolver(name='jets3t', root='http://www.jets3t.org/maven2', m2Compatible='true')
@Grab(group='net.java.dev.jets3t', module='jets3t', version='0.9.0')
import org.jets3t.service.impl.rest.httpclient.RestS3Service
import org.jets3t.service.security.AWSCredentials
import org.jets3t.service.model.*
accessKey = 'Cambiar'
@imadi
imadi / gist:80c1fe379a1ad192221199b794d7f392
Created January 27, 2017 03:18 — forked from fdmanana/gist:832610
The CouchDB replicator database

1. Introduction to the replicator database

A database where you PUT/POST documents to trigger replications and you DELETE to cancel ongoing replications. These documents have exactly the same content as the JSON objects we used to POST to /_replicate/ (fields "source", "target", "create_target", "continuous", "doc_ids", "filter", "query_params".

Replication documents can have a user defined "_id". Design documents (and _local documents) added to the replicator database are ignored.

The default name of this database is _replicator. The name can be changed in the .ini configuration, section [replicator], parameter db.

2. Basics

@imadi
imadi / validate_credit_card.js
Created January 25, 2017 10:08 — forked from DiegoSalazar/validate_credit_card.js
Luhn algorithm in Javascript. Check valid credit card numbers
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@imadi
imadi / SoapUISessions.groovy
Created January 22, 2017 03:04
Using session id in between requests in SoapUI using groovy script
def testStep= testRunner.runTestStepByName("User")
def response = testStep.response
def cookies = response.responseHeaders["Set-Cookie"].toString()
String cookie = cookies.split(";")[0]
def regex = /(JSESSIONID=[A-Za-z0-9.]+)/
matcher = ( cookies =~ regex )
def jsessionId
if(matcher.find()){ jsessionId = matcher[0][0] }
log.info("sessionId : " + jsessionId)
//get UserAddress
@imadi
imadi / Unzip.groovy
Last active October 17, 2017 05:22
Unzip only specific files without directories using AntBuilder
def builder = new AntBuilder()
builder.unzip(src: srcPath, dest: destPath) {
mapper(type: "flatten")
patternset() {
include(name: "**/*.mp3")
}
}