Skip to content

Instantly share code, notes, and snippets.

@arnobroekhof
arnobroekhof / models.py
Created May 3, 2015 20:12
PowerDNS Djano Model
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin sqlcustom [app_label]'
# into your database.
from __future__ import unicode_literals
@arnobroekhof
arnobroekhof / EmbeddedCassandraUnitTest.java
Last active August 29, 2015 14:26
Embedded Cassandra Unit test with bound statements
import com.datastax.driver.core.*;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.thrift.transport.TTransportException;
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
#!/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")
@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:
# -*- 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"
---
:hierarchy:
- roles/%{::irn_role}
- common
:backends:
- yaml
:merge_behavior: deeper
:yaml:
:datadir: '/puppet/hieradata/'
@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);
#!/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())
public class ReadVeryBigFile {
public static void main(String[] args) throws Exception {
Runtime runtime = Runtime.getRuntime();
NumberFormat format = NumberFormat.getInstance();
long startedMemory = runtime.freeMemory();
@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')