Skip to content

Instantly share code, notes, and snippets.

@elubow
elubow / keybase.md
Created October 29, 2014 17:06
Keybase

Keybase proof

I hereby claim:

  • I am elubow on github.
  • I am elubow (https://keybase.io/elubow) on keybase.
  • I have a public key whose fingerprint is CFEC 78CB 0701 57AB AF5C D569 6932 03C1 F066 DB8A

To claim this, I am signing this object:

@elubow
elubow / check_aggregate_nsq_depths.py
Created November 26, 2014 17:37
Check Aggregate NSQ Depths in Nagios
#!/usr/bin/env python2.7
import sys
import logging
import functools
import time
import tornado.options
import tornado.ioloop
import nsq_data
require 'rubygems'
require 'optparse'
require 'tinder'
NotificationConfig = {
:campfire => {
:subdomain => 'subdomain',
:email => '135abc0cd5e0124cdc2993c79ff83h897baae260f',
:pass => 'secret',
:room => 'Room',
#!/usr/bin/env ruby
require 'erb'
rsyslog_block = %{#
# <%= virtual_host %>
#
$InputFileName /var/log/httpd/<%= virtual_host %>-error.log
$InputFileTag <%= virtual_host %>_error
$InputFileStateFile stat-<%= virtual_host %>-error.log
@elubow
elubow / Step by step
Created November 18, 2010 17:05
jruby capistrano
elubow@beacon (master) adserver$ cap -d deploy
triggering start callbacks for `deploy'
* == Currently executing `multistage:ensure'
*** Defaulting to `production'
* == Currently executing `production'
* == Currently executing `deploy'
* == Currently executing `deploy:update'
** transaction: start
* == Currently executing `deploy:update_code'
updating the cached checkout on all servers
query = Hash.new
if @bid_request[:geo][:dma].is_a? Fixnum
# {$or:[ {field:{$in:[X]}} , {field:{$size:0}}]}
query[:dma_codes] = {:$in => [@bid_request[:geo][:dma]]}
# query[:dma_codes] = { :$size => 0 }
# query[:dma_codes] = {:$or => [{:$in=>[@bid_request[:geo][:dma]]}, {:$size=>0}] }
# query[:dma_codes] = {:$or => [{:$in => [@bid_request[:geo][:dma]]}, {:$size=>0}]}
# query[:dma_codes] = {:$in => [{:$in=>[@bid_request[:geo][:dma]]}], :$size=>0 }
# query[:dma_codes] = {"$or" => [ {'dma_codes' => { "$in" => [X]}}, {'dma_codes' => { "$size" => 0}}]}
@elubow
elubow / flume-site-agent.xml
Created February 3, 2011 20:10
Flume Configuration files
<!-- a1 (agent) -->
<configuration>
<property>
<name>flume.master.servers</name>
<value>$master_IP</value>
<description>This is the address for the config servers status server (http)</description>
</property>
<property>
<name>flume.collector.event.host</name>
@elubow
elubow / gist:825135
Created February 13, 2011 21:14 — forked from mraleph/gist:825124
std::string tag_key, tag_value;
bool has_tags = false;
map<string,string> tags;
if (!args[1]->IsUndefined()) {
Local<Object> tagsObj = args[1]->ToObject();
Local<Array> tagNames = tagsObj->GetPropertyNames();
uint32_t length = tagNames->Length();
for (uint32_t i=0; i<length;i++) {
Local<String> v8TagKey = tagNames->Get(i)->ToString();
Local<String> v8TagValue = tagsObj->Get(v8TagKey)->ToString();
-- Log line
-- {"exchange_id":"4cc877b81badf422af000010","exchange_user_id":"MTY4Mjk2NTk2eDAuODA2IDEyOTc4MDI5NTh4MTI2NDc5NjY2MA","bid_id":"00cc4341-facb-4ec1-a403-d5309472d70e","bid_amount":"2.05","win_amount":1.369999968133322,"ad_ids":"4d237a731badf45c8200011a,4d237ac81badf45c85000006,4d4c64c0e32b132113000013,4d23807a1badf45c85000299","wv":"2","logged_at":"2011-02-15T23:36:31.386Z"}
REGISTER file:/home/hadoop/lib/pig/piggybank.jar;
DEFINE EXTRACT org.apache.pig.piggybank.evaluation.string.EXTRACT();
RAW_LOGS = LOAD 'file:/home/hadoop/logs/adserver.log' USING TextLoader AS (line:chararray);
LOGS_BASE= foreach RAW_LOGS generate FLATTEN(EXTRACT(line,'{"exchange_id":"(.*[^"])","exchange_user_id":"(.*[^"])","bid_id":"(.*[^"])","bid_amount":"(.*[^"])","win_amount":(.*),"ad_ids":"(.*[^"])","wv":"(.*[^"])","logged_at":"(.*[^"])"}')) AS (exchange_id:chararray,exchange_user_id:chararray,bid_id:chararray,bid_amount:float,win_amount:float,ad_ids:chararray,wv:int,logged_at:chararray);
WIDGET_VERSION_ONLY = FOREACH LO
@elubow
elubow / gist:2008708
Created March 9, 2012 21:08
Nagios Passive Check
# Send the passive service check back to Nagios
logger.debug("Constructing the Nagios result string")
nag_message = config.get('nagios','message')
nag_status = 0
logger.info("Passive check result sent to Nagios")
except Exception, e:
nag_status = 2
nag_message = "%s" % (e)