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 __future__ import division | |
from matplotlib import pylab as plt | |
import numpy as np | |
MAX = np.inf | |
DEBUG = True | |
# DEBUG = False | |
class Arm: | |
def __init__(self, name, mean, stddev, cost): |
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 sys | |
import os | |
import io | |
from prettytable import PrettyTable | |
def countLines(path, extension) : | |
pt = PrettyTable() | |
pt.field_names = ['filename', '#lines'] | |
total_line = 0 | |
total_files = 0 |
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
// Helper | |
function print(obj) { | |
console.log(obj) | |
} | |
// Mimic Async-Await | |
function coRunner(feedback) { | |
let iterator = this; | |
let result = iterator.next(feedback); |
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
def checktype(*types): | |
def typerror(expect, got): | |
raise TypeError('expecting {}, got{}'.format(expect, type(got))) | |
def checker(fn): | |
def receiver(*args, **kwargs): | |
for _type, arg in zip(types, args): | |
type(arg) is _type or typerror(_type, arg) | |
return fn(*args, **kwargs) | |
return receiver |
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 time | |
from functools import wraps | |
def timeit(comment=None): | |
""" | |
auto establish and close mongo connection | |
""" | |
def decorator(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): |
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
""" | |
Implement a very simple gaussian process for regression task. | |
Credit : http://katbailey.github.io/post/gaussian-processes-for-dummies/ | |
""" | |
import numpy as np | |
import matplotlib.pyplot as pl | |
def prepare_data(n, fn): |
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 __future__ import division | |
from random import random | |
import numpy as np | |
import pandas as pd | |
''' | |
Use regret-matching algorithm to play Scissors-Rock-Paper. | |
''' | |
class RPS: |
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
# Install GPFlow | |
!git clone https://github.com/namoshizun/GPflow.git | |
!mv ./GPflow/gpflow ./ | |
!rm -rf GPflow | |
!pip install multipledispatch | |
!pip install pytest | |
# Install Other libraries | |
!pip install edward |
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 functools | |
import inspect | |
from tqdm import tqdm | |
def print_progress(total=None, enabled=True): | |
def decorator(func): | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
if not enabled or total is None: |
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 vid_utils import Video, concatenate_videos | |
videos = [ | |
Video(speed=1.0, path="C:/temp/my_video_1.mp4"), | |
Video(speed=2.0, path="C:/temp/my_video_2.mp4"), | |
Video(speed=0.5, path="C:/temp/my_video_3.mp4"), | |
] | |
concatenate_videos(videos=videos, output_file=f"C:/temp/output_video.mp4") |
OlderNewer