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
# Run the following command to start jupyter with custom password | |
## The current directory will be mapped to the /home/jovyan in the docker | |
## User is granted root access | |
## New password can be set using its hash, hash of password can be obtained by: | |
### from IPython.lib import passwd | |
### passwd("this_is_a_password") #Output: 'sha1:9743a64265c5:5775f49cb5577d50234260a661cb520b1dc07ed3' | |
docker run -p 8888:8888 --user root -e NB_GID=100 -e GRANT_SUDO=yes -v "$PWD":/home/jovyan jupyter/scipy-notebook:hoangmt start-notebook.sh --NotebookApp.password='sha1:9743a64265c5:5775f49cb5577d50234260a661cb520b1dc07ed3' -d | |
# Save changes to the running container by commiting its image | |
# get hash of the container to be commited | |
docker ls |
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 attr | |
from datetime import datetime | |
from attr import fields | |
@attr.s(slots=True) | |
class Small: | |
a = attr.ib(type=float, metadata={'JSON':'A'}) | |
@attr.s(slots=True) | |
class TestField: |
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 timeit | |
setup=''' | |
import random, bisect | |
from collections import deque | |
random.seed('slartibartfast') | |
s = [random.random() for i in range(1000)] | |
timsort = sorted |
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 datetime import datetime as dt | |
from multiprocessing import Pool | |
from tqdm import tqdm | |
from features import * | |
from sklearn.metrics import mean_squared_error | |
import sys | |
def cv_model(args): | |
'''Cross validate a predefined model with a given time series | |
Note: receive one args so that it can be call by worker pool easily''' |
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
url = "%s/timeseries/%s/typeClass/%d/resolution/%d/" \ | |
% (endpoint, asset_id, type_class, resolution_id) | |
params = {'from': from_date, 'to': to_date} | |
url = url + "?" + urllib.urlencode(params) | |
# b64Val = base64.b64encode(username+":"+password) | |
# response.headers['Authorization'] = "Basic %s" %b64Val | |
resp = requests.get(url, params, auth=(username, password)).json() |
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
DATA_DIR = "appleoutput40" | |
SC_DATA_DIR = "split_appleoutput40" | |
VAL_PERCENTAGE = 0.2 | |
from os.path import normpath, basename | |
from shutil import copyfile | |
import random | |
import os | |
subdir_imgs = [(subdir, files) for subdir, dirs, files in os.walk(DATA_DIR) if len(files)>50] |
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
[InfluxMeasurement("consumption")] | |
public class ConsumptionMeasurement:InfluxMeasurementBase | |
{ | |
[InfluxTimestamp] | |
public override DateTime Timestamp { get; set; } | |
[InfluxTag("assetguid")] | |
public Guid AssetGuid { get; set; } | |
[InfluxTag("consumptiontype")] |
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
# [filter size, stride, padding] | |
#Assume the two dimensions are the same | |
#Each kernel requires the following parameters: | |
# - k_i: kernel size | |
# - s_i: stride | |
# - p_i: padding (if padding is uneven, right padding will higher than left padding; "SAME" option in tensorflow) | |
# | |
#Each layer i requires the following parameters to be fully represented: | |
# - n_i: number of feature (data layer has n_1 = imagesize ) | |
# - j_i: distance (projected to image pixel distance) between center of two adjacent features |
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
#!/bin/bash | |
#List current running docker images | |
echo "Select one of the following running images:" | |
echo -e "Number \t Name" | |
echo $(docker ps | tail -n +2| awk -F ' ' '{printf("%7d %s\n", NR, $2)}') | |
read -p "Enter the process number:" selectedID | |
selectedID=$(($selectedID + 1)) | |
#Get Docker process ID of the specified docker image name | |
DOCKER_ID=$(docker ps | tail -n +$selectedID | head -1 | awk '{print $1}') | |
docker exec -it $DOCKER_ID /bin/bash |