Skip to content

Instantly share code, notes, and snippets.

iamtrk /
Last active Aug 29, 2015
JDBC Connection pool implemented in C3PO.
public class ConnectionPool {
private ComboPooledDataSource cpds;
private static ConnectionPool datasource;
private ConnectionPool() throws IOException, SQLException ,PropertyVetoException{
cpds = new ComboPooledDataSource();
iamtrk / JAVA Code
Last active Dec 25, 2015
bloomreach Wine selection problem Solution
View JAVA Code
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
iamtrk / primes.js
Created Jul 23, 2013
Prime numbers code written in Node.js
View primes.js
var fs = require("fs");
function getPrimes(max) {
var sieve = [], i, j, primes = [];
for (i = 2; i <= max; ++i) {
if (!sieve[i]) {
// i has not been marked -- it is prime
for (j = i << 1; j <= max; j += i) {
sieve[j] = true;
iamtrk / app.js
Last active Dec 20, 2015
Simple wiring of mongoose, Node.js and express
View app.js
var express = require('express')
, http = require('http')
, foodlist = require('./foodlist');
var app = express();
app.set('port', process.env.PORT || 3000);
iamtrk / MongoDB
Created Jul 16, 2013
Mongo DB info queries
View MongoDB
db.isMaster().maxBsonObjectSize() -- > upper limit on the size of a document
iamtrk / query.txt
Last active Dec 19, 2015
M101J from 10Gen Education -> Final exam
View query.txt
Final: Question 2
Please use the Enron dataset you imported for the previous problem. For this question you will use the aggregation framework to figure out pairs of people that tend to communicate a lot(list Top5 pairs).
Query :
iamtrk / chat.js
Last active Dec 19, 2015
A Simple chat server implemented in Node.js
View chat.js
//fs module is required for writing conversations and host info logging.
var net = require('net');
var fs = require('fs');
var sockets = [];
var people = {};
// Hosts are saved in hosts file and conversation is saved in conversation file.
var hosts = 'hosts.txt';
var conv = 'conversation.txt';
var server = net.createServer(function(socket){