Skip to content

Instantly share code, notes, and snippets.

View jennielees's full-sized avatar

Jennie jennielees

  • Santa Monica, CA
View GitHub Profile
@jennielees
jennielees / FirstPersonController.cs
Last active December 30, 2015 22:19
Stamina/health etc. first person controller with gui
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;
namespace UnityStandardAssets.Characters.FirstPerson
{
[RequireComponent(typeof (CharacterController))]
[RequireComponent(typeof (AudioSource))]
<!DOCTYPE html>
<html>
<head>
<script src="http://fb.me/react-0.13.1.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script src="jsbin.fenofa.js"></script>
@jennielees
jennielees / git-sanity
Last active August 29, 2015 14:21
~/bin/git-sanity
#!/bin/bash
red='\033[0;31m'
yellow='\033[0;33m'
reset='\033[0m'
stopship_found=0
print_found=0
branch=$(git rev-parse --abbrev-ref HEAD)

Web Challenge

The main job of a web server is to listen on a specific port, handle incoming requests for URLs and figure out what to return back.

Iteratively build up your own web server. We'll be doing some of this together in class, but you can get a head-start and a deeper understanding!

A first step would be to write a program that runs on the command line and listens via raw_input for a user-typed keyword. It then looks up a HTML file in a directory depending on the keyword entered, and returns the text of that file back. The interaction would look something like this:

Welcome to my web server! Enter the route you want:
@jennielees
jennielees / gist:be63debf61b95f24cc92
Created April 15, 2015 00:34
Hackbright Full-Stack Prework, part 1
@jennielees
jennielees / rules.txt
Created March 17, 2015 06:59
Civ II Discworld Mod / Jingo Scenario
@jennielees
jennielees / inspect.py
Created March 16, 2015 18:45
inspecting python classes
def get_property_or_default(obj, prefix):
# If any of the properties defined on this object match the prefix, return
# the value of that property.
for key, value in obj.__dict__.iteritems():
if key.startswith(prefix):
return value
# Otherwise, we check that there is exactly one property, and return that
assert len(obj.__dict__) == 1
return value
@jennielees
jennielees / gist:b8f6f03e6fa39e9f0f16
Created March 14, 2015 21:56
Flask-SQLAlchemy Overrides

This was going to be an answer to pallets-eco/flask-sqlalchemy#269 but I realised I was getting further away from answering the actual question.

How to make SQLAlchemy models that are reusable, and compatible with Flask-SQLAlchemy

I looked into doing something similar, in order to use SQLAlchemy models outside the app context and to automatically use some mixins for all models created, as well as to override the default table naming scheme.

Worth noting there are some unmerged PRs around overriding the metadata/base: pallets-eco/flask-sqlalchemy#61

The Model and BaseQuery classes are standalone -- it doesn't look like they require the instantiation, so you could import and inherit from them, or rewrite them to support what you need. The issue is then pulling your custom classes back into the SQLAlchemy() part, since the class names are hardcoded.

@jennielees
jennielees / git-sanity
Created February 26, 2015 18:29
Bash Sanity checker
#!/bin/bash
# If added to $PATH, this file will be available as `git sanity`.
red='\033[0;31m'
yellow='\033[0;33m'
reset='\033[0m'
stopship_found=0
print_found=1
@jennielees
jennielees / .screenrc
Last active August 29, 2015 14:08
Getting screen to have colors and scrollwheel support
term xterm-color
termcapinfo xterm* ti@:te@
defshell -bash