Skip to content

Instantly share code, notes, and snippets.

@ankurcha
ankurcha / QosFilter.java
Last active August 29, 2015 14:07
Account level QoSFilter for concurrent connections
package analytics.api;
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
@ankurcha
ankurcha / java_installer.sh
Created September 24, 2014 19:16
Installer script for JDKs
#!/bin/bash
JDK_FILE="jdk-8u20-linux-x64.tar.gz"
JDK_URL="https://s3.amazonaws.com/com.brightcove.rna.repo.dev/${JDK_FILE}"
JDK_ARCHIVE="${HOME}/${JDK_FILE}"
JDKS_DIR="${HOME}/jdks"
JDK_DIR="${JDKS_DIR}/jdk1.8.0_20"
# ensure jdks directory exists
mkdir -p $JDKS_DIR
@ankurcha
ankurcha / knife_dl.sh
Created August 28, 2014 22:00
Function to download and extract cookbook
function knife_dl() {
local packages="$@"
cd ~/chef/cookbooks
for c in ${packages}; do
knife cookbook site download ${c};
tar zxf ${c}*.tar.gz;
rm ${c}-*.tar.gz;
done
}
/*
var context = cubism.context(),
cube = context.cube("https://data.brightcove.com/v1/accounts/8523")
cube.metric("video_view")
*/
cubism_contextPrototype.analytics_api = function(url) {
if (!arguments.length) url = "";
var source = {},
context = this;
@ankurcha
ankurcha / api-agent.conf
Created June 19, 2014 09:30
logstash agent.conf
input {
file {
type => "analytics-api"
path => "/var/log/analytics-api/analytics-api.log"
}
file {
type => "mongos"
path => ["/var/log/mongodb/mongos_rolling.log", "/var/log/mongodb/mongos_historical.log", "/var/log/mongodb/mongos_collector.log"]
}
file {
@ankurcha
ankurcha / remove_db.js
Created April 25, 2014 19:19
This is a set of scripts we use to reliably drop sharded databases on a MongoDB cluster. The reason for doing this is because mongos is very unreliable when it comes to cleanly and reliably dropping stuff.
function removeDB(n) {
flushConfigs();
var colls = findChunkedCollections(n);
colls.forEach(function(coll) {
if(!db.getSisterDB(n).getCollection(coll).exists()) {
print("collection did not exist for chunk: " + n + "." + coll)
getPrimaries().forEach(function(p){
p.getDB(n).createCollection(coll);
});
@ankurcha
ankurcha / backupStatus.json
Last active October 23, 2015 06:11
Script to backup tokumx database to a directory and/or S3.
{
"percent" : 6.297823041677475,
"bytesDone" : NumberLong("22117130240"),
"files" : {
"done" : 8,
"total" : 166
},
"current" : {
"source" : "/var/lib/mongodb_historical11/local_oplog_rs_p15_id__ddfdbfc0_1_19.tokumx",
"dest" : "/backup11/local_oplog_rs_p15_id__ddfdbfc0_1_19.tokumx",
@ankurcha
ankurcha / groovyw.sh
Created August 13, 2013 20:58
Groovy wrapper
#!/bin/sh
GROOVY_VERSION=${$GROOVY_VERSION:-"2.1.6"}
if [ -z "$@" ]; then
echo "No argument specified"
exit 1
fi
if [ ! -f "$@" ]; then
#!/usr/bin/env ruby
def check_require(name)
begin
gem name
rescue Gem::LoadError
# not installed
system("gem install #{name}")
Gem.clear_paths
end
require name
@ankurcha
ankurcha / Readme.md
Created July 19, 2013 21:23
Implementation of the Google Youtube Data API interface * All Channels have a one to one mapping with the entry in the credentialStore. * The refreshing process is managed by the GoogleAuthorizationFlow api client.
  • All Channels have a one to one mapping with the entry in the credentialStore.
  • The refreshing process is managed by the GoogleAuthorizationFlow api client.