Skip to content

Instantly share code, notes, and snippets.

@arnobroekhof
arnobroekhof / sample.java
Created October 19, 2016 21:38
Change kerberos password using java
/*
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>kerberos-client</artifactId>
<version>2.0.0-M20</version>
</dependency>
*/
public static void main(String[] args) {
KdcConfig config = KdcConfig.getDefaultConfig();
@arnobroekhof
arnobroekhof / cassandra-rebalance.sh
Last active September 28, 2016 10:32 — forked from kintarowins/rebalance.sh
Cassandra node rebalancing script
#!/bin/sh
#this looks up the nodes from the ring and rebalances them automatically
hosts = `/usr/bin/nodetool ring |grep Normal |awk '{print $1}' |xargs echo`
RING_SIZE=$(echo "2^127" | bc)
HOST_NUM=$(echo $hosts | wc -w)
INDEX=0
@arnobroekhof
arnobroekhof / ldap-kerbers-attr-lookup.py
Last active September 2, 2016 21:13
Python script for binding to ldap using kerbers and showing the authenticated users attributes
#!/usr/bin/env python
# Make sure the python-ldap module is installed
# pip install python-ldap
import ldap
import ldap.sasl
#Initialize your connection and force it to use TLS
con = ldap.initialize('ldap://ldap.example.com')
public class ReadVeryBigFile {
public static void main(String[] args) throws Exception {
Runtime runtime = Runtime.getRuntime();
NumberFormat format = NumberFormat.getInstance();
long startedMemory = runtime.freeMemory();
#!/usr/bin/env python
# -*- coding: UTF8 -*-
import json
import urllib2
def make_get_request(url, headers):
req = urllib2.Request(url=url, headers=headers)
return json.loads(urllib2.urlopen(req).read())
@arnobroekhof
arnobroekhof / putObject.java
Last active June 8, 2016 09:58
inputstream to bytearray with md5 hashing ioctx
public void putObject(final InputStream inputStream, final String objectName, final int bufferSize) throws Exception {
int length = inputStream.available();
byte[] buffer = new byte[bufferSize];
int bytesRead;
int offset = 0;
logger.info("Copying file with objectName: {}", objectName);
MessageDigest md = MessageDigest.getInstance("MD5");
while ((bytesRead = inputStream.read(buffer)) > 0) {
md.update(buffer, 0, bytesRead);
---
:hierarchy:
- roles/%{::irn_role}
- common
:backends:
- yaml
:merge_behavior: deeper
:yaml:
:datadir: '/puppet/hieradata/'
# -*- mode: ruby -*-
# vi: set ft=ruby :
PUPPET_DIR="my-puppet-dir"
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
# config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "private_network", ip: "192.168.33.10"
@arnobroekhof
arnobroekhof / rados-cp.py
Last active May 28, 2018 04:13
Copying files to rados
#!/usr/bin/env python
try:
import rados
import sys
import hashlib
import argparse
import os
import logging
except ImportError:
#!/usr/bin/env python
try:
import rados
import sys
import hashlib
import os
except ImportError:
raise ImportError('unable to import modules')
sys.stderr.write("unable to import modules")