Skip to content

Instantly share code, notes, and snippets.

View llvtt's full-sized avatar

Luke Lovett llvtt

  • Unspun
  • Tokyo, Japan
View GitHub Profile
@llvtt
llvtt / clean-branches.sh
Created August 15, 2018 16:56
Clean up orphaned git branches
#!/bin/bash
if [ "$1" = "rm" ]; then
branches_file=${2:-"orphaned-branches.txt"}
echo "Removing branches specified in $branches_file"
while read branch; do
git branch -D $branch
done < $branches_file
exit 0
fi
@llvtt
llvtt / MongoRecordReaderTest.java
Created December 5, 2014 19:46
MongoRecordReaderTest.java
package com.mongodb.hadoop.splitter;
import com.mongodb.*;
import com.mongodb.hadoop.input.MongoInputSplit;
import com.mongodb.hadoop.input.MongoRecordReader;
import com.mongodb.hadoop.util.MongoClientURIBuilder;
import org.bson.BasicBSONObject;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@llvtt
llvtt / gist:ccaf44ef54b7c702cb99
Created November 22, 2014 00:19
mongo-orchestration.config
{
"releases": {
"27-nightly": "/mnt/jenkins/mongodb/master-nightly/master-nightly-release/bin",
"26-release": "/mnt/jenkins/mongodb/26/26-release/bin",
"24-release": "/mnt/jenkins/mongodb/24/24-release/bin",
"22-release": "/mnt/jenkins/mongodb/22/22-release/bin",
"20-release": "/mnt/jenkins/mongodb/20/20-release/bin"
},
"last_updated": "2014-08-29 20:57:00.000000"
}
@llvtt
llvtt / gist:91aa8782094507e1de34
Created November 22, 2014 00:13
mongo-orchestration-setup.sh
# mongo-orchestration-setup.sh
#
# Set up a MongoDB configuration on Jenkins. This script should be run only
# after server.py has started.
#
# Arguments:
# ----------
# 1. release (as defined in the --config file to server.py) [required]
# 2. configuration (single_server|replica_set|sharded) [required]
# 3. authentication (auth|noauth) [optional: defaults to "noauth"]
@llvtt
llvtt / gist:cd79ef60891655be5bdd
Created November 7, 2014 01:02
Customized Solr DocManager
# Copyright 2013-2014 MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@llvtt
llvtt / gist:218bcac23e6c0ea52e41
Last active August 29, 2015 14:07
Mongo Orchestration links demo session

curl -XPOST http://localhost:8889/v1/replica_sets -d@configurations/replica_sets/basic.json

{
    "auth_key": null,
    "id": "9662ad30-8742-4738-81a5-ef79d14b8781",
    "links": [
        {
            "href": "/v1/replica_sets/9662ad30-8742-4738-81a5-ef79d14b8781",
            "method": "GET",

"rel": "get-replica-set-info"

@llvtt
llvtt / custom_flattening.py
Last active August 29, 2015 14:06
DocumentFormatter for flattening documents for use in Solr. Does not include array indices.
from mongo_connector.doc_managers.formatters import DocumentFlattener
class DocumentFlattenerUnordered(DocumentFlattener):
"""Formatter that completely flattens documents, but does not unwind arrays.
Order of elements within arrays is not recorded.
An example:
{"a": 2,
"b": {
@llvtt
llvtt / reddit2mongo
Last active May 7, 2016 19:06
Stream Reddit posts into MongoDB
#!/usr/bin/env python
import datetime
import optparse
import sys
import praw
import praw.helpers
import pymongo
import requests.exceptions
@llvtt
llvtt / mongo-connector
Last active August 29, 2015 13:56
mongo-connector init script (tested on CentOS 6.5)
#!/bin/bash
#
# mongo-connector Start Mongo Connector
#
# chkconfig: 345 90 25
# description: Mongo Connector replicates data from MongoDB to external
# database systems.
### BEGIN INIT INFO
# Provides: mongo-connector
@llvtt
llvtt / upload.py
Created February 21, 2014 00:31
upload.py
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#