Skip to content

Instantly share code, notes, and snippets.

View verma's full-sized avatar
💭
Working from home because the virus is out to get us!

Uday Verma verma

💭
Working from home because the virus is out to get us!
View GitHub Profile
@verma
verma / message.log
Created March 14, 2012 00:41
Twisted logging problem
2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] Server Shut Down.
2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] Server Shut Down.
2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] Server Shut Down.
2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] Server Shut Down.
2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] Server Shut Down.
2012-03-13 19:39:14-0500 [-] 2012-03-13 19:39:14-0500 [-] 2012-0
@verma
verma / test.py
Created March 14, 2012 00:50
A simple program running a dummy service
# test.py
from twisted.application import internet, service
from twisted.python import log
from twisted.python.logfile import DailyLogFile
from twisted.internet.task import LoopingCall
import os
@verma
verma / gist:2304994
Created April 4, 2012 19:36
Normalize an Angle
static inline real_t NormalizeAngle(real_t rAngle) {
real_t a = std::fmod(rAngle, 2 * pd::math::PI);
if (IsGreaterOrEqual(a, pd::math::PI))
a = -2 * pd::math::PI + a;
else if (IsLessOrEqual(a, -pd::math::PI))
a = 2 * pd::math::PI + a;
return a;
}
@verma
verma / fswatcher.py
Created April 10, 2012 19:38
FileSystem Directory Watcher
# fswatcher.py
# Watches a particular directory for files with corresponding .lock files
#
from twisted.internet import reactor
import os
class DirectoryWatcher(object):
def __init__(self, dirname, interval=1.0):
self.dirname = dirname
@verma
verma / write_rtp.cpp
Created June 27, 2012 18:43
Write variable length rtp data to a file
void write_rtp(std::ostream& os, const char *rtp_data, int length) {
unsigned short len = htons((unsigned short)length);
os.write((char*)&len, sizeof(len));
os.write(rtp_data, length);
}
@verma
verma / default_call_flow.rb
Created September 11, 2012 20:22
A simple DSL example for Call-flow generation
TxIVR do
say "Hello, good morning"
play "http://s3.amazon.com/verma/company.mp3"
dialog do
play "http://s3.amazon.com/verma/menu.mp3"
option key: "1", speech: "balance" do
say do
get "http://vendor.com/newcall/balance"
@verma
verma / generated.js
Created September 11, 2012 21:16
Testing class inheritance in Coffeescript
var Bye, Greeting, Hello,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Greeting = (function() {
function Greeting() {}
Greeting.prototype.initialize = function() {
return this.message = "Hello";
{
"name": "elastic-queries",
"version": "0.0.1",
"description": "Elastic query tests",
"dependencies": {
"underscore": "1.4.2",
"elasticsearchclient": "*",
"express": "3.x",
"consolidate": "*",
"jade": "*"
PREFACE.
In giving to the public this volume, it has been the
design to present the operations of the Bureau of the Nation-
al Detective Police during the war, so far as it is proper to
make them known to the people. It is not a book of roman-
tic adventures, but a narrative of fscts in tha secret history
of the conflict, and mainly an exposure of the manifold and
gigantic frauds and crimes of both the openly disloyal and
the professed friends of the Repubfio. Many reports are
introduced, some of which are lengthy, and portions of them
@verma
verma / gist:4245558
Created December 9, 2012 15:19
Find all agents who have an average score above a certain threshold.
SELECT SUM(IF(average_score>65,1,0)) AS above_threshold, COUNT(*) AS total FROM
( SELECT agent_id, AVG(score) AS average_score
FROM recordings
JOIN evaluations ON recordings.id = evaluations.recording_id
GROUP BY agent_id) AS T;