Steps with explanations to set up a server using:
- virtualenv
- Django
- nginx
- uwsgi
"""Take third Saturdays of each month. | |
Calculate number of them in odd and even weeks""" | |
from datetime import datetime | |
y = 2012 | |
odd_counter = 0 | |
even_counter = 0 |
### PROMPT #################### | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} |
import xml.dom.minidom | |
from exceptions import QueryRequired | |
import experiment | |
import analysis | |
class Result(object): | |
experiment_xml = None | |
analysis_xml = None | |
pass |
from lxml import objectify | |
from exceptions import QueryRequired | |
def request(query=None, file_name=None): | |
""" | |
Makes a request to CGHub web service or gets data from a file. | |
Returns parsed Response object. | |
""" |
# assume the following directory structure where contents of doc/ | |
# and source/ are already checked into repo., with the exception | |
# of the _build directory (i,e. you can check in _themes or _sources | |
# or whatever else). | |
# | |
# proj/ | |
# source/ | |
# doc/ | |
# remove doc/_build/html if present |
#! /usr/bin/env python | |
""" | |
Take screenshots every SLEEP_TIME seconds. | |
""" | |
import time | |
import subprocess | |
SLEEP_TIME = 10 | |
COMMAND = "import -window root -format png data/{timestamp}.png" |
db.grades.aggregate([ | |
{$unwind: '$scores'}, | |
{$match: | |
{"scores.type": {$in: ["exam", "homework"]}}}, | |
{$group: | |
{ | |
_id: { | |
'student_id': '$student_id', | |
'class_id': '$class_id' | |
}, |
db.zips.aggregate([ | |
{$project: | |
{ | |
first_char: {$substr : ["$city",0,1]}, | |
pop: 1 | |
} | |
}, | |
{$match: | |
{ | |
first_char: {$lt: 'A'} |
""" | |
Some solutions for @bobuk's problem discussed in | |
http://www.radio-t.com/p/2014/10/18/podcast-414/ | |
""" | |
import random | |
L_TEST = [1234, 1, 23, 252, 13523, 829, 2378, 234555, 912394] | |
K_TEST = 3 |