Skip to content

Instantly share code, notes, and snippets.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from datetime import datetime"
]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dudarev
dudarev / gist:10f94ac617aab949ecc5
Created October 20, 2014 19:56
Some ways to select k random elements from a list
"""
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
@dudarev
dudarev / gist:bf7067f713a1e0fa901b
Created September 17, 2014 08:56
m101js.hw5.4.js
db.zips.aggregate([
{$project:
{
first_char: {$substr : ["$city",0,1]},
pop: 1
}
},
{$match:
{
first_char: {$lt: 'A'}
@dudarev
dudarev / gist:3315ceb427fe9ed3425b
Created September 17, 2014 08:54
m101js.hw5.3.js
db.grades.aggregate([
{$unwind: '$scores'},
{$match:
{"scores.type": {$in: ["exam", "homework"]}}},
{$group:
{
_id: {
'student_id': '$student_id',
'class_id': '$class_id'
},
@dudarev
dudarev / record.py
Created June 3, 2014 09:34
Take screenshots regularly
#! /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"
# 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
@dudarev
dudarev / gist:4348689
Last active January 29, 2017 09:56 — forked from evildmp/gist:3094281
Django deployment with nging and uwsgi

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

  • virtualenv
  • Django
  • nginx
  • uwsgi
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.
"""
import xml.dom.minidom
from exceptions import QueryRequired
import experiment
import analysis
class Result(object):
experiment_xml = None
analysis_xml = None
pass