Skip to content

Instantly share code, notes, and snippets.

@drewverlee
drewverlee / sudoku.py
Created October 2, 2012 15:32 — forked from jtratner/sudoku.py
Sudoku Solver/Checker - Udacity CS258
def get_subgrids(three_rows):
""" splits given set of three rows into subgrids"""
return zip(*[(row[0:3], row[3:6], row[6:]) for row in three_rows])
def check_sudoku(sudoku):
try:
def check_row(row):
""" checks that the row contains 1 and only 1 element from 1 to 9 and
that the total count == 9"""
counts = [0 for x in range(10)]
for i in range(9):
Traceback (most recent call last):
File "/home/drew/.virtualenvs/petal/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
return self.wsgi_app(environ, start_response)
File "/home/drew/.virtualenvs/petal/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/drew/.virtualenvs/petal/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/home/drew/.virtualenvs/petal/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/drew/.virtualenvs/petal/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
from petalapp import db
ROLE_USER = 0
ROLE_ADMIN = 1
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80))
email = db.Column(db.String(150), unique=True)
role = db.Column(db.SmallInteger, default=ROLE_USER)
@drewverlee
drewverlee / class inheritance
Created November 16, 2012 17:45
personType.cpp|86 col 5 error| type ‘personType’ is not a direct base of ‘docterType’$
#include <iostream>
#include <string>
using namespace std;
class personType
{
public:
void print() const;
@drewverlee
drewverlee / homework
Created December 1, 2012 23:26
trying to do problem b, getting the following errors, not examples in the book. Not sure if small syntax issue or something larger.
26.cpp|30 col 6 error| ‘template<class type> class strange’ used without template parameters
26.cpp|30 col 32 error| invalid use of template-name ‘strange’ without an argument list
26.cpp|30 col 41 error| ISO C++ forbids declaration of ‘rightObject’ with no type [-fpermissive]
26.cpp|30 col 52 error| ‘bool operator==(const int&)’ must have an argument of class or enumerated type
//a.Write a statement that declares sObj to be an object of type strange
//such that the private member variables a and b are of type int.
//b. Write a statement that shows the declaration in the class strange to
@drewverlee
drewverlee / gist:4448144
Created January 3, 2013 22:42
code and heroku logs
def download_s3(file_title):
s3conn = boto.connect_s3(app.config["AWS_ACCESS_KEY_ID"],app.config["AWS_SECRET_ACCESS_KEY"])
bucket = s3conn.get_bucket(app.config["S3_BUCKET"])
key = bucket.get_key(file_title)
seconds = 60*5
url = key.generate_url(expires_in=seconds)
return url
# then
# g.url = download_s3('some_title')
@drewverlee
drewverlee / Heroku logs
Created January 9, 2013 21:44
All i see is a Get request to api/login
2013-01-09T21:35:29+00:00 heroku[deployhooks]: Notified New Relic about the deploy
2013-01-09T21:35:34+00:00 heroku[web.1]: Starting process with command `newrelic-admin run-program gunicorn -b "0.0.0.0:55287" -w 3 runserver:app `
2013-01-09T21:35:37+00:00 app[web.1]: 2013-01-09 21:35:37 [2] [INFO] Starting gunicorn 0.15.0
2013-01-09T21:35:37+00:00 app[web.1]: 2013-01-09 21:35:37 [2] [INFO] Listening at: http://0.0.0.0:55287 (2)
2013-01-09T21:35:37+00:00 app[web.1]: 2013-01-09 21:35:37 [2] [INFO] Using worker: sync
2013-01-09T21:35:37+00:00 app[web.1]: 2013-01-09 21:35:37 [5] [INFO] Booting worker with pid: 5
2013-01-09T21:35:37+00:00 app[web.1]: 2013-01-09 21:35:37 [6] [INFO] Booting worker with pid: 6
2013-01-09T21:35:37+00:00 app[web.1]: 2013-01-09 21:35:37 [7] [INFO] Booting worker with pid: 7
2013-01-09T21:35:42+00:00 heroku[web.1]: State changed from starting to up
2013-01-09T21:37:10+00:00 heroku[slugc]: Slug compilation started
@drewverlee
drewverlee / gist:4525193
Created January 13, 2013 17:25
Naming conventions
class SurveySection(db.Model):
"""
Survey_section has a one-to-many relationship with User_survey_section
"""
id = db.Column(db.Integer, primary_key=True)
user_survey_sections = db.relationship('User_survey_section', backref="survey_section",
lazy='dynamic')
name = db.Column(db.String(45))
#include "Text.h"
// **************************************************************
// Name : Drew Verlee
// Acess ID : fd4544
// Assign : lab01
// **************************************************************
Text::Text ( const char *charSeq)