Skip to content

Instantly share code, notes, and snippets.

View post2web's full-sized avatar

Ivelin Angelov post2web

  • Intuit Inc
  • Mountain View, CA
View GitHub Profile
#durty timing stuff around the code
import time
class Timer:
times = {}
@staticmethod
def start(key=''):
if key not in Timer.times:
Timer.times[key] = {'start': False, 'sum': 0}
from IPython import display
plt.plot(data)
display.clear_output(wait=True)
display.display(plt.gcf())
import tensorflow as tf
batch_size = 2
get_single_xy_timeout = 10
train_timeout = 3
n_epochs = 5
n_threads = 5
# dummy function simulating loading, preprocessing
# and other operations needed for the X and Y
@post2web
post2web / tf_rotating_gpu_buffer.py
Created February 10, 2017 02:28 — forked from TimZaman/tf_rotating_gpu_buffer.py
Tensorflow Rotating GPU Buffer
# Implementation of a rotating buffer on the GPU of size 2.
import threading
import tensorflow as tf
from tensorflow.python.client import timeline
import numpy as np
import time
params = {
'batch_size': 128,
'seg_len': 4000,
def lrelu(x, leak=0.1):
f1 = 0.5 * (1 + leak)
f2 = 0.5 * (1 - leak)
return f1 * x + f2 * abs(x)
def lrelu(x, leak = 0.1):
return tf.maximum(leak*x, x)
@post2web
post2web / prime_numbers
Created May 5, 2017 17:07
a fast prime number generator
def find_primes(n):
is_prime = np.ones(n, dtype=bool)
# remove 0 and 1 because we know they are not prime
is_prime[0:2] = False
# start from number 2
for number in range(2 , n):
if number**2 > n: break
if is_prime[number]:
is_prime[number*2::number] = False
@post2web
post2web / commands
Last active May 9, 2017 23:24
commands
# download a file with max bandwidth
aria2c --file-allocation=none -c -x 10 -s 10 URL
# disk inventory
ncdu
@post2web
post2web / mount_external_drive.sh
Last active November 7, 2017 04:58
ubuntu mount external drive journaled filesystem
## list all drives and find /dev/sdXY for the external
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
## Install hfsprogs to read HFS+ (apple's file system)
sudo apt-get install hfsprogs
## mount
sudo mount -t hfsplus -o force,rw /dev/sdXY /media/external
## or
sudo mount -t exfat -o force,rw /dev/sdXY /media/external
## if the drive was improperly unmounted or a little corrupted
# sudo fsck.hfsplus -f /dev/sdXY
@post2web
post2web / figure axis
Last active October 30, 2017 20:52
default figure and axis
fig = plt.gcf() # get current figure
ax = plt.gca() # get current axis
Generate a rsa keypair:
# ssh-keygen
then copy it on the server with one simple command:
# ssh-copy-id hostname
you can now log in without password:
# ssh hostname