- Intel Xeon E3-1231 v3 = $256.99
- [Intel Core i7-3770 3.4GHz (3.9GHz Turbo) LGA 115] (http://www.newegg.com/Product/Product.aspx?Item=N82E16819116502) = $299.99
This file contains 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
FROM ubuntu:12.04.5 | |
RUN apt-get update | |
RUN apt-get install -y build-essential | |
RUN apt-get install -y openssh-server git curl python-dev libpq-dev wget | |
RUN wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - | |
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' >> /etc/apt/sources.list | |
RUN apt-get -y update | |
RUN apt-get install -y postgresql-9.3 |
This is a 5-minute crash course to start using vagrant. We will host our vagrant files in /home/USER/vms
. That's
my convention working with many vagrant machines.
vagrant: https://docs.vagrantup.com/v2/installation/
virtualbox: https://www.virtualbox.org/wiki/Downloads
This file contains 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 Minheap(object): | |
def __init__(self, array): | |
self._array = [None] + array | |
self.build_heap() | |
def parent_of(self, i): | |
return i//2 | |
def children_of(self, i): | |
return 2*i, (2*i)+1 | |
def build_heap(self): | |
for i in xrange(len(self._array)//2, -1, -1): |
This file contains 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 random | |
def q_select(numbers, ith): | |
if len(numbers) < 2: | |
return numbers[0] | |
# Chooses a pivot uniformly from random | |
p_index = random.randint(0, len(numbers)-1) | |
pivot = numbers[p_index] | |
# Before the partition, swap the pivot with the last element | |
numbers[p_index], numbers[-1] = ( |
This file contains 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 pqdict | |
def dijkstra(graph, source, target=None): | |
""" | |
Computes the shortests paths from a source vertex to every other vertex in | |
a graph | |
""" | |
# The entire main loop is O( (m+n) log n ), where n is the number of | |
# vertices and m is the number of edges. If the graph is connected |
This file contains 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
""" | |
>>> a = [[1,2], [3,3], [4]] | |
>>> o = [] | |
>>> for x in a: | |
... o.extend(x) | |
... | |
>>> o | |
[1, 2, 3, 3, 4] | |
stuff = set([ '%s.%s' % (prefix, type) for type in types(suffix) if prefix in get_types(given_type) ])
# how do I know where I can split this onto multiple lines?
and my answer is at the expression.
>>> [x
... for
This file contains 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 re | |
text1 = "alphanumeric@example.org" | |
text2 = "alphanumeric@long.subdomain.more.subdomain.domain.org" | |
r1 = re.compile(r'[a-zA-Z0-9]+@[a-zA-Z]+\.[a-zA-Z]+(\.[a-zA-Z]+)*') | |
print(r1.match(text1).group()) | |
print(r1.match(text2).group()) | |
print("part 2 - compare with and without (?:") |
This file contains 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
// api.js | |
var Job = function(settings, jq) { | |
var createJob = function(args) { | |
return $.ajax({ | |
url: "https://yeukhon.me/api/job", | |
type: "POST", | |
crossDomain: true, | |
data: { | |
job_name: args.job_name, |