Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
ports="6379 6380 6381 6382 6383 6384 6385"
for port in ${ports}
do
t0=$(redis-cli -p $port info | grep command | cut -d : -f 2 | tr -d ‘\r’)
sleep 1
t1=$(redis-cli -p $port info | grep command | cut -d : -f 2 | tr -d ‘\r’)
val=$(($t1$t0))
echo “$port,$val”
@elubow
elubow / gist:4658869
Created January 28, 2013 20:49
SiriProxy stack trace
Create server for iPhone connection
start conn #<SiriProxy::Connection::Iphone:0x000000058a0700 @signature=1019, @processed_headers=false, @output_buffer="", @input_buffer="", @unzipped_input="", @unzipped_output="", @unzip_stream=#<Zlib::Inflate:0x000000058a04f8>, @zip_stream=#<Zlib::Deflate:0x000000058a04d0>, @consumed_ace=false, @name="iPhone", @ssled=false>
[Info - Plugin Manager] Plugins laoded: [#<SiriProxy::Plugin::Hue:0x000000058a7938 @manager=#<SiriProxy::PluginManager:0x000000058a80b8 @plugins=[...]>>]
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
[Info - iPhone] Received Object: SpeechPacket
@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)
@elubow
elubow / blogger.template
Created August 10, 2011 14:51
Blogger Standard Template
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
<b:if cond='data:blog.isMobile'>
<meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
<b:else/>
<meta content='width=1100' name='viewport'/>
</b:if>
-- 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: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();
@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>
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 / 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
#!/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