Skip to content

Instantly share code, notes, and snippets.

View vpatov's full-sized avatar

Vasia Patov vpatov

View GitHub Profile

Keybase proof

I hereby claim:

  • I am vpatov on github.
  • I am vpatov (https://keybase.io/vpatov) on keybase.
  • I have a public key ASBtAzLjj7dqiI5vudKuVQJQUIHPbAuHDGOMme-e2E3bSwo

To claim this, I am signing this object:

import threading
def accept_connections:
while(True):
connection = server_socket.accept()[0].makefile('wb')
camera.start_recording(connection, format='h264', splitter_port=2,
resize=(640,360))
try:
camera.wait_recording(7*60*60) #assuming this records for 7 hours?
except:
@vpatov
vpatov / loader_7.py
Created August 17, 2017 14:39
Problem 7
grids = []
with open('input_7.txt','r') as f:
while(True):
grid = []
line = f.readline()
if (len(line) < 1):
break
width,height = (int(i) for i in line.split())
for row in range(height):
line = f.readline().strip()
@vpatov
vpatov / loader_6.py
Created August 17, 2017 14:35
Problem 6
with open('input_6.txt','r') as f:
documents = f.read().split('-----')
documents = [doc.split() for doc in documents]
print(documents)
@vpatov
vpatov / loader_4.py
Created August 17, 2017 14:24
Problem 4
import json
with open('input_4.json','r') as f:
tree = json.load(f)
print(tree)
@vpatov
vpatov / loader_3.py
Created August 17, 2017 14:23
Problem 3
"""
If you want to use a dictionary
"""
galaxies = {}
with open('input_3.txt','r') as f:
for line in f:
parts = map(str.strip,line.split(','))
name,x,y,benefit = parts
galaxies[name] = {"x":int(x), "y":int(y), "benefit": int(benefit)}
@vpatov
vpatov / loader_1.py
Created August 17, 2017 14:14
Problem 1
with open('input_1.txt','r') as f:
data = f.read()
print(data)
"""
If you want to use a dictionary
"""
galaxies = {}
for line in open('problem1_input.txt','r'):
parts = map(str.strip,line.split(','))
name,x,y,benefit = parts
galaxies[name] = {"x":int(x), "y":int(y), "benefit": int(benefit)}
"""
"""
Each grid is a 2d-matrix.
Each cell is either '-' or '#'.
"""
grids = []
f = open('problem3_input.txt','r')
while(True):
grid = []
line = f.readline()
if (len(line) < 1):
connections = {
'r1':['h1','r2','r3'],
'r4':['h2','r2','r3']
}
for name_a in names:
if name_a in connections:
for name_b in connections[name_a]:
self.addLink(quaggaContainers[name_a],quaggaContainers[name_b])