Skip to content

Instantly share code, notes, and snippets.

#include <set>
#include <string>
#include <memory>
#include <iostream>
#include <functional>
template< typename T >
struct shared_ptr_comparator {
bool operator()(const std::shared_ptr<T> &a, const std::shared_ptr<T> &b) const {
return std::less<T>()(*a, *b);
@arjun-menon
arjun-menon / rotate_matrix.py
Last active January 10, 2016 10:19
Rotate a matrix clockwise by 90 degrees
"""
Rotate a matrix clockwise by 90 degrees
"""
def iter_matrix_outline(n):
for j in range(0, n):
yield (0, j)
for i in range(1, n):
yield (i, n-1)
for j in range(n-2, -1, -1):
@arjun-menon
arjun-menon / gist:74fe776e82e781f66a4c
Created July 10, 2014 10:32
Flask & SQLite3 experiment
from flask import Flask, request
import sqlite3, time
app = Flask("Twitter clone")
def add_tweet(tweet):
moment = timeString = time.strftime("%Y-%m-%d %H:%M %p", time.localtime())
c.execute("INSERT INTO tweets VALUES('Guest', ?, ?)", (tweet, moment))
conn.commit()
@arjun-menon
arjun-menon / HeapSort.go
Created March 6, 2014 20:24
Heap Sort in Go
package main
import (
"fmt"
"math/rand"
"time"
"errors"
"log"
)