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
# search for the disk in the system | |
lsblk -f | |
# create a file system on the drive | |
mkfs.ext4 /dev/nvme0n1 | |
# mount to some folder | |
sudo mount /dev/nvme0n1 /media/storage_ssd/ | |
# add line to /etc/fstab file |
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 math import cos, asin, sqrt | |
def distance(lat1, lon1, lat2, lon2): | |
# https://en.wikipedia.org/wiki/Haversine_formula | |
p = 0.017453292519943295 | |
a = 0.5 - cos((lat2-lat1)*p)/2 + cos(lat1*p)*cos(lat2*p) * (1-cos((lon2-lon1)*p)) / 2 | |
return 12742 * asin(sqrt(a)) | |
def closest(data, v): | |
return min(data, key=lambda p: distance(v['lat'],v['lon'],p['lat'],p['lon'])) |
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
# save/load objects in python | |
import pickle | |
def save_obj(obj, name ): | |
with open('obj/'+ name + '.pkl', 'wb') as f: | |
pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL) | |
def load_obj(name ): | |
with open('obj/' + name + '.pkl', 'rb') as f: | |
return pickle.load(f) |
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 os | |
import json | |
from pprint import pprint | |
def save_image_set_txt(path, index): | |
f = open(path, 'w') | |
for ind in index: | |
f.write(ind+'\n') | |
f.close() |
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
# libs | |
from phue import Bridge | |
import speech_recognition as sr | |
import time | |
# mapping some hue values to colors | |
color_hue = {'red':0, 'yellow':12750, 'green': 25500, 'blue':46920,'purple':56100} | |
# support commands | |
command_list = ['red', 'yellow', 'green', 'blue', 'purple'] |
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
# set parameters for grid search | |
parameters_dtc = { | |
'max_depth': list(range(1,20)), | |
'criterion': ['gini', 'entropy'], | |
'splitter': ['best', 'random'], | |
'max_features' : list(range(1,15)) | |
} | |
gs = GridSearchCV(DTC(), param_grid = parameters_dtc, cv = cv) | |
#mesure time of search |
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 cvxpy import * | |
import numpy as np | |
#current level | |
level = np.array([[5,5,10,10,10],[5,5,10,20,10],[0,5,5,10,5],[0,0,0,5,0]]) | |
# desired level | |
desired_level = np.ones([4,5])*6 | |
# inflow - outflow matrix (inflow positive, outflow negative) |
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 cvxpy import * | |
import numpy | |
numpy.random.seed(1) | |
n = 20 | |
x1 = Variable(n) | |
x2 = Variable(n) | |
a = Variable(n) | |
objective = Minimize(2*x1 + 3*a) |
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
#read from file | |
fname = "educated_people.txt" | |
with open(fname) as f: | |
educated_people = f.read().splitlines() | |
f.close | |
fname = "birthdate.txt" | |
with open(fname) as f: | |
birthdate = f.read().splitlines() | |
f.close |