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
@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 / 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--) {