Skip to content

Instantly share code, notes, and snippets.

View shared_ptr_set.cpp
#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 Jan 10, 2016
Rotate a matrix clockwise by 90 degrees
View rotate_matrix.py
"""
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):
View gist:74fe776e82e781f66a4c
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()
View HeapSort.go
package main
import (
"fmt"
"math/rand"
"time"
"errors"
"log"
)