Check app.py for
postgresql:///sample_db
<— the name of your new database is the thing after the 3 slashes. Use this in step 2.In terminal (and maybe not necessarily in the dir of your file, just anywhere?), type:
createdb sample_db
NOTE: (Yes, it doesn't matter what directory you're in when you run createdb.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### WAYS TO LOOP OVER TWO THINGS AT ONCE IN PYTHON: | |
cats = ["fluffy", "puffy", "muffy"] | |
dogs = ["fido", "rover", "bowser"] | |
# jinja-specific way, won't work in regular python: | |
# | |
# {% for cat in cats %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Cell(val y: Int, val x: Int) { | |
fun neighbors() = listOf(Cell(y, x - 1), Cell(y - 1, x), Cell(y, x + 1), Cell(y + 1, x)) // WNES | |
} | |
data class Garden(val cells: List<List<Int>>) { | |
val nRows = cells.size | |
val nCols = cells[0].size | |
fun findCenterCells() = listOf( | |
Cell((nRows - 1) / 2, (nCols - 1) / 2), // NW |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Single abstract-method interface for a way to fly. */ | |
fun interface FlyBehavior { | |
fun fly() | |
} | |
// implementations of the single-method interface | |
val FlyWithWings = FlyBehavior { println("I'm flying!") } | |
val FlyNoWay = FlyBehavior { println("No way") } | |
val FlyRocketPowered = FlyBehavior { println("Rocket!!!!!!") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
/** Single instruction for state machine. */ | |
data class Instruction(val opcode: String, val operand: Int) | |
/** Marker exception raised during state machine runs. */ | |
class Answer(val result: Int) : Throwable() | |
val lines = File("8.txt") | |
.readLines() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Course(val name: String, val start: Short, val end: Short) | |
/** For list of courses, print best schedule for a single classroom. | |
* | |
* The best schedule for a classroom is the one that has the most classes | |
* scheduled for it, with no classes overlapping with another class. | |
*/ | |
fun bestSchedule(classes: MutableList<Course>): List<String> { | |
val schedule = mutableListOf<String>() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.* | |
/** Graph node for undirected graphs. | |
* | |
* @property value the value of the node. | |
* @property adjacent a set of the adjacent nodes for this one. | |
**/ | |
class Node( | |
private val value: Any, |
http://api.joelburton.com/recipes/brownies?color=red
URL: "resource" : "/recipes/brownies"
REST "resource" (subject)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class POJO(dict): | |
def __getattr__(self, attr): | |
return self[attr] | |
def __setattr__(self, attr, val): | |
try: | |
super().__getattr__(self, attr) | |
super().__setattr__(self, attr, val) | |
except AttributeError: | |
self[attr] = val |
NewerOlder