Instantly share code, notes, and snippets.

View scores-to-roc.py
from sklearn import metrics
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def create_roc_curve(labels, scores, positive_label)
fpr, tpr, thresholds = metrics.roc_curve(labels, scores, pos_label=positive_label)
roc_auc = auc(fpr, tpr)
plt.title('Receiver Operating Characteristic')
View ipython_notebook_in_git.md

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

View merge-keytab.sh
// Merge multiple keytabs into single keytab
$ ktutil
$ ktutil: rkt KEYTAB1.keytab
$ ktutil: rkt KEYTAB2.keytab
$ ktutil: wkt MERGEDKEYTAB.keytab
View ranger_password_reset.py
import md5
user = ''
pass = ''
print md5.new(pass + "{" + user + "}").hexdigest()
View elasticsearch.yml
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,
View hash_generator.py
import hashlib, os
def hashfile(afile, hasher, blocksize=65536):
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
return hasher.hexdigest()
path = raw_input("Enter directory to scan: ")
View kafkaTopic.sh
./kafka-topics.sh --create --zookeeper {HOSTNAME}:2181 --replication-factor 1 --partitions 1 --topic {topicname}
View CreateIndex.cs
var client = new ElasticClient();
var replicas = 0;
var shards = 3;
client.CreateIndex(index, c => c.NumberOfReplicas(replicas).NumberOfShards(shards)
.AddMapping<T>(m => m.MapFromAttributes()));
View csharp-random-string
public class TokenGenerator
{
public static string Generate(int size)
{
// Characters except I, l, O, 1, o, and 0 to decrease confusion when hand typing tokens
var charSet = "abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!@#$%&()";
var chars = charSet.ToCharArray();
var data = new byte[1];
var crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data);
View azcopy-downloadblob
azcopy /Source:https://sourceblobcontainer /Dest:destfolder /SourceKey:storagekey /S
AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer /Dest:C:\myfolder /SourceKey:key /Pattern:abc.txt