Skip to content

Instantly share code, notes, and snippets.

View ashee's full-sized avatar

Amitava Shee ashee

View GitHub Profile
@ashee
ashee / jenkins-genpwd.sh
Last active November 18, 2017 00:00
jenkins-genpwd
$ cd ~/.jenkins
$ vim ~/users/ashee/config.xml
<passwordHash>#jbcrypt:xxxxxxxx</passwordHash>
$ jshell --class-path war/WEB-INF/lib/jbcrypt-1.0.0.jar
jshell> import org.mindrot.jbcrypt.*
jshell> BCrypt.hashpw("foo", BCrypt.gensalt())
$8 ==> "$2a$10$jRnBX5Z/rT0cCRI1Dq1rh.RTb8fOzIfVQ7T9emsLMJLKaZUdro17i"
jshell> BCrypt.checkpw("foo", $8)
$9 ==> true
@ashee
ashee / tls-ca.go
Created October 18, 2017 17:20
golang tls with self-signed cert
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net/http"
)
@ashee
ashee / aws-sig4.py
Created September 4, 2017 15:39
AWS signature 4
#!/usr/bin/env python
import os
import ConfigParser
import logging
import requests
from requests_aws4auth import AWS4Auth
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
@ashee
ashee / mvn-mkapp.md
Last active August 30, 2017 13:10
mvn mkapp
@ashee
ashee / spark-submit.sh
Last active June 7, 2017 22:56
AWS EMR Custom Jar Spark Job
# see - http://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-commandrunner.html
# also see (not accurate but worth a read) - https://github.com/awslabs/emr-bootstrap-actions/blob/master/spark/examples/spark-submit-via-step.md
aws emr add-steps --cluster-id j-3GZ6YDD7POJFQ --steps \
Name=DSEMigration,Jar="command-runner.jar",Args=[spark-submit,--deploy-mode,cluster,--master,yarn,--class,org.ithaka.dsemig.DseMig.DseMig,s3://sequoia-install/dse-migration/dsemig_2.11-0.1.0-SNAPSHOT.jar,--jars,/mnt/var/lib/zeppelin/local-repo/com/datastax/spark/spark-cassandra-connector_2.11/2.0.0-M3/spark-cassandra-connector_2.11-2.0.0-M3.jar],ActionOnFailure=CONTINUE
@ashee
ashee / s3del-bulk.rb
Created March 20, 2017 20:50
Bulk delete s3 objects
#!/usr/bin/env ruby
require 'aws-sdk'
BUCKET_NAME = 'YOUR_BUCKET_NAME'
PREFIX = 'your/key/path/'
s3 = Aws::S3::Resource.new(region: 'us-east-1')
bucket = s3.bucket(BUCKET_NAME)
@ashee
ashee / awsips-dnsmasq.md
Last active May 19, 2022 07:19
dnsmasq in osx (macSierra) to resolve aws internal ip's

AWS internal ip's

EMR has components running on internal ip's such as ip-172-23-53-101.ec2.internal. To resolve to the implied public/vpn IP's, setup dnsmasq

Setup dnsmasq

$ brew install dnsmasq

Configure dnsmasq

@ashee
ashee / zeppelin-local.md
Last active January 24, 2017 19:16
Apache Zeppelin local setup

Import Note default size limit

Default size is configured at 1024000 (1MB) which prevents any notebook bigger than a MB to fail. Zeppelin distribution comes with a file /usr/local/Cellar/apache-zeppelin/0.6.2/libexec/conf/zeppelin-env.sh.template Make a copy of this file and rename it to zeppelin-env.sh increasing the size to something bigger.

$ vim /usr/local/Cellar/apache-zeppelin/0.6.2/libexec/conf/zeppelin-env.sh.template

export ZEPPELIN_WEBSOCKET_MAX_TEXT_MESSAGE_SIZE=10240000
@ashee
ashee / pbe.groovy
Created November 19, 2016 00:05
Password Based Encryption
import java.security.*
import javax.crypto.*
import javax.crypto.spec.*
import javax.xml.bind.DatatypeConverter
class PBE {
def secretKey;
def salt = getSalt();
def iterations = 65536 ;
def keySize = 256;
@ashee
ashee / jks-readkey.groovy
Created November 18, 2016 22:57
Read private key from jks keystore
import java.security.Key
import java.security.KeyStore
def console = System.console()
def keystoreName = "amitava.jks"
def keystoreFormat = "JKS"
def keystorePassword = console.readPassword("%s ", "Keystore Password:").toString()
def alias = "amitava"