Skip to content

Instantly share code, notes, and snippets.

View vagmi's full-sized avatar

Vagmi Mudumbai vagmi

View GitHub Profile
@vagmi
vagmi / gist:103674
Created April 29, 2009 09:04
.bashrc to show git branch
# snip .bashrc
function bash_git_branch
{
git branch 2> /dev/null | grep \* | python -c "print '['+raw_input()[2:]+']'" 2> /dev/null
}
#snip .bashrc
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(bash_git_branch)\$ '
#snip the rest
@vagmi
vagmi / article.txt
Created December 23, 2009 13:46
A super simple markov generator
However, she began nibbling at a little of her very curious!' she spoke (it was close by the moment. ' She waited patiently until it away into the sea as she said, just as hard indeed to be. 'And yet what work it had followed him when it aloud; and put everything upon a book written down:. 'I don't trouble yourself airs! Do you got to her escape; so he now and the end of uglifying!'. ' 'Then it could think this child again, and feebly stretching out its nest. 'The Dormouse indignantly. 'Now I wish it was not tell you know that it was over the King, the flame of the. ' 'If you're doing!' cried the milk-jug into a sulky tone; 'Seven jogged my dear: she did the air. 'Back to himself suddenly: the Mock Turtle yawned and looking up in a very sleepy; 'and those cool fountains,. So she went on, old thing!' It quite forgetting her sister, who only answered herself so proud of the. While she made a bottle was going through the youth, 'and the Dormouse shall!' they can't take more like. 'I had never heard it belongs to
#log a to the base b
def log_base(a, b)
return (Math.log(a)/Math.log(b))
end
log_base(10,10) # 1.0
log_base(100,10) # 2.0
log_base(20,10) # 1.30102999566398
require 'mq'
AMQP.start :host=>"connectedhealth.in",:vhost=>"/test" do
def log(*args)
p [ Time.now, *args ]
end
mq = MQ.new
mq.queue("testphr").bind(MQ.direct("eprescription",:key=>"apollopharmacy")).subscribe { |msg|
log :received, msg
/Users/vagmi/.rvm/gems/ruby-1.9.1-p378/gems/amqp-0.6.7/lib/mq.rb:225:in `process_frame': PRECONDITION_FAILED - parameters for queue 'testphr' in vhost '/test' not equivalent in AMQP::Protocol::Queue::Declare on 1 (MQ::Error)
from /Users/vagmi/.rvm/gems/ruby-1.9.1-p378/gems/amqp-0.6.7/lib/amqp/client.rb:9:in `process_frame'
from /Users/vagmi/.rvm/gems/ruby-1.9.1-p378/gems/amqp-0.6.7/lib/amqp/client.rb:117:in `receive_data'
from /Users/vagmi/.rvm/gems/ruby-1.9.1-p378/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
from /Users/vagmi/.rvm/gems/ruby-1.9.1-p378/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
from /Users/vagmi/.rvm/gems/ruby-1.9.1-p378/gems/amqp-0.6.7/lib/amqp.rb:79:in `start'
from testdc.rb:3:in `<main>'
["send",
#<AMQP::Frame::Method:0x00000101282410
@channel=1,
@payload=
#<AMQP::Protocol::Channel::Open:0x00000101282cd0
@debug=1,
@out_of_band=nil>>]
["send",
#<AMQP::Frame::Method:0x00000101270c48
select preg.first_name,preg.family_name,
ios.Service_Name, ios.Service_code, ios.Report_Type,
invsam.lab_regno, preg.registration_no, text_report = case ios.Report_Type
WHEN 'T' then (select itr.formatstr from investigation_typical_result_op itr where lab_regno=invsam.lab_regno and itr.service_code=invsam.service_code)
ELSE 'NA'
END
from investigation_sample_op invsam inner join patient_registration preg on invsam.Registration_No = preg.registration_no
inner join item_of_service ios on invsam.service_code = ios.Service_code
where invsam.Registration_No='10712'
-- Extract normal results
select preg.first_name,ios.Service_Name, inr.result,ulm.Unit_name, inr.min_value, inr.max_value, invsam.lab_regno
from patient_registration preg inner join (investigation_sample_op invsam
inner join (investigation_normal_result_op inr
inner join item_of_service ios
on ((ios.Service_code=inr.service_code) and (ios.Report_Type='N')))
on ((inr.service_code = invsam.service_code)
and (inr.lab_regno = invsam.lab_regno)))
on preg.registration_no = invsam.Registration_No inner join Unit_Lab_Master ulm on ulm.unit_code=inr.Unit_code
where preg.registration_no='10712'
@vagmi
vagmi / config.py
Created September 24, 2010 08:02
An alternative to the grails HIE
# HIE Agent configuration file
# this is mocked up here. will come from the service
# id_maps[uhid] = phr_id
id_maps = {}
id_maps['xxxxx']='xxxxx@xxxxx'
# source setting
SOURCE_KEY = 'AVERYLONGGUID'
SOURCE_NAME = 'Apollo Site'
# Add these functions to your .profile to know the git branch, ruby version
# and the rvm gemset that you are currently using
function bash_git_branch
{
git branch 2> /dev/null | grep \* | python -c "print '['+raw_input()[2:]+']'" 2> /dev/null
}
function ruby_version
{
ruby -v 2> /dev/null | awk '{ print $2}'