Skip to content

Instantly share code, notes, and snippets.

@victorhcm
victorhcm / docker_cheat_sheet.sh
Last active July 19, 2018 11:56
(small) docker cheat sheet
#################################################################################
# Authors: Keiller Nogueira, Victor de Melo
#################################################################################
# nvidia-docker seems more stable now and several images are starting to adopt it (including
# [kaixhin](https://github.com/NVIDIA/nvidia-docker/issues/85).
# hence, we suggest to use it instead, as it solves a few issues with gpu passthrough.
# usage: it is only required when creating a container, i.e, with `run` and related arguments
# you're not required to provide $DOCKER_NVIDIA_DEVICES as it will find the devices itself
@victorhcm
victorhcm / annotate_image.py
Created November 19, 2015 00:02
overlay image with annotations.
# coding: utf-8
import matplotlib.pyplot as plt
import Image
img = Image.open('truman-stairs.jpg')
fig, ax = plt.subplots(figsize=(12,12))
ax.imshow(img, aspect='equal')
ax.add_patch(
@victorhcm
victorhcm / argparse_example.py
Created December 2, 2015 00:34 — forked from elmotec/bootstrap_cmdline.py
Minimal python program with logging and argparse.
#!/usr/bin/env python
# encoding: utf-8
"""Minimal python commad line."""
import sys
import argparse
import logging
# The network is used for the video description experiments of S2VT [1].
# Please consider citing S2VT [1] if you use this example in your work.
#
# [1] S. Venugopalan, M. Rohrbach, J. Donahue, R. Mooney, T. Darrell,
# K. Saenko. "Sequence to Sequence - Video to Text." ICCV 2015.
# The data is prepared using framefc7_stream_text_to_hdf5.py
# It is in (32) parallel streams.
name: "s2vt"
layer {
# A yaml constructor is for loading from a yaml node.
# This is taken from @misha 's answer: http://stackoverflow.com/a/15942429
def opencv_matrix_constructor(loader, node):
mapping = loader.construct_mapping(node, deep=True)
mat = np.array(mapping["data"])
mat.resize(mapping["rows"], mapping["cols"])
return mat
yaml.add_constructor(u"tag:yaml.org,2002:opencv-matrix", opencv_matrix_constructor)
# A yaml representer is for dumping structs into a yaml node.
@victorhcm
victorhcm / VGG_FACE_deploy_updated.prototxt
Last active October 4, 2016 09:05
Updated VGG_FACE prototxt
name: "VGG_FACE_16_layer"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 224
input_dim: 224
layer {
name: "data"
type: "Data"
top: "data"
@victorhcm
victorhcm / latency.markdown
Created September 30, 2017 23:26 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@victorhcm
victorhcm / fractalnet-34.png
Last active October 30, 2017 01:12
FractalNet-34 prototxt for visualization at http://dgschwend.github.io/netscope
fractalnet-34.png
@victorhcm
victorhcm / rainbowtable.py
Created January 29, 2018 21:18 — forked from lgommans/rainbowtable.py
A toy rainbow table script
#!/usr/bin/env python3
import sys
from hashlib import md5
from base64 import b64encode
from binascii import hexlify, unhexlify
from time import time
def reduction_function(hash, max_password_length):
@victorhcm
victorhcm / remux_packets.py
Created June 10, 2018 23:27
Remux packets without transcoding
import av
import numpy as np
def write_packets(filename, packets, video_stream):
container = av.open(filename, mode='w')
stream = container.add_stream(template=video_stream)
stream.options = {}
for p in packets:
if p.dts is not None: