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: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
# 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
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
@dudarev
dudarev / .bashrc
Created January 12, 2012 13:44 — forked from troolee/.bashrc
prompt
### 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)]/"
}
@dudarev
dudarev / gist:1431275
Created December 4, 2011 21:07
Number of Saturdays in odd and even weeks
"""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
@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'}