Skip to content

Instantly share code, notes, and snippets.

View supritashankar's full-sized avatar
🙃

Suprita Shankar supritashankar

🙃
  • San Francisco
View GitHub Profile
@supritashankar
supritashankar / resources.py
Created January 25, 2013 14:59
Nested Resources in Django Tastypie
from django.contrib.auth.models import User
from tastypie.resources import ModelResource
from tastypie import fields
from employee.models import Employee, Message
from tastypie.authentication import OAuthAuthentication
from extendedmodelresource import ExtendedModelResource
from django.conf.urls import patterns, url, include
from tastypie.utils import trailing_slash
class UserResource(ModelResource):
@supritashankar
supritashankar / leibniz.py
Created February 3, 2013 04:36
Leibniz formula for pi
from decimal import *
getcontext().prec = 15
t=[]
for i in range(int(raw_input())):
t.append(raw_input())
for i in range(len(t)):
o=t[i]
l=[]
for j in range(int(o)):
p=Decimal((2*j) + 1)
class Info:
def __init__(self, index, name):
self.name = name
self.index = index
def __repr__(self):
return repr((self.name, self.index))
inf1 = Info(2, "two")
inf2 = Info(1, "one")
inf3 = Info(-1, "Minus-one")
def is_valid(grid):
if len(grid)!=81:
return False
for a in grid:
val = int(a)
if type(val)!= int or val == 0:
return False
k = 0
puzzle = [[0 for x in xrange(9)] for x in xrange(9)]
@supritashankar
supritashankar / reversal-string
Created May 16, 2014 01:02
Best way to reverse a string in python!
def reverse(_string):
return ''.join(reversed(_string))
"""
Buckets Robo problem
Attempt #1
"""
begin = -1;
end = len(no_of_buckets);
loc = 0;
while (loc<end) {
switch (color) {
'use strict';
module.exports = function mochacli(grunt) {
// Load task
grunt.loadNpmTasks('grunt-mocha-cli');
// Options
return {
src: ['test/unit/**/*.js'],
@supritashankar
supritashankar / meeting.py
Created February 11, 2016 01:54
Meeting Calendar problem with sets
timeline = {
'1': set([0,1,2,3,4]),
'2': set([3,4,5,6,7]),
'3': set([2,3,4])}
def get_meeting_time(timeline):
"""
get intersection of all the person
"""
@supritashankar
supritashankar / meeting.java
Created February 12, 2016 19:01
MeetingInvite
class Event {
int start;
int end;
}
class myE {
int isStart;
int time;
}
void maxparticipants(event[] events){
To Watch
- The Room
- Brooklyn
- There's no tomorrow
- True Cost
- Ghetto Physics
- Garbage warriors
- P Sainath Corporate hijack of Indian agriculture
Watched