Skip to content

Instantly share code, notes, and snippets.

View vishr's full-sized avatar
🎯
Focusing

Vishal Rana vishr

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am vishr on github.
  • I am vishr (https://keybase.io/vishr) on keybase.
  • I have a public key whose fingerprint is 53F1 DD5B 0967 D764 766A 791F 2227 6FFB B2AA DBB6

To claim this, I am signing this object:

package test
import (
"sort"
"testing"
)
type (
People []*Person
Person struct {
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
var sock = null;
var wsuri = "ws://localhost:3000";
window.onload = function() {
sock = new WebSocket(wsuri);
@vishr
vishr / ProducerConsumer.java
Created December 4, 2011 17:34
Simplest Producer-Consumer
/**
*
*/
package com.qwata.concurrency;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
@vishr
vishr / dfs.py
Created December 4, 2011 06:59
Tree Traversal - Depth First Search
from collections import defaultdict
def recursive_dfs(tree, node, path=[]):
"""
Recursive depth first search
"""
path.append(node)
for child in tree[node]:
path = recursive_dfs(tree, child, path)
return path
@vishr
vishr / bfs.py
Created December 4, 2011 06:05
Tree Traversal - Breadth First Search
from collections import defaultdict
def iterative_bfs(tree, node, path=[]):
"""
Iterative breadth first search
"""
queue = [node]
while queue:
n = queue.pop(0)
path.append(n)
# Repairing mongod in Ubuntu:
sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
@vishr
vishr / BasicJavaCode.java
Created July 20, 2011 01:18
Basic Java Programs
import java.util.Arrays;
/**
* @author Vishal Rana
*
*/
public class BasicJavaCode {
// Factorial
public int factorial(int x) {