Skip to content

Instantly share code, notes, and snippets.

// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@riless
riless / waya-dl-setup.sh
Created November 20, 2017 12:33 — forked from mjdietzx/waya-dl-setup.sh
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
@riless
riless / install_robo3t.sh
Created February 25, 2018 18:56
install robo3t 1.2.1
VERSION=1.2.1
HASH=3e50a65
BASENAME=robo3t-$VERSION-linux-x86_64-$HASH
cd /opt/
wget https://download.robomongo.org/$VERSION/linux/$BASENAME.tar.gz
sudo tar -xzf $BASENAME.tar.gz -C /opt
rm $BASENAME.tar.gz
sudo ln -fs /opt/$BASENAME/bin/robo3t /usr/bin/robo3t
cat > ~/.local/share/applications/robo3t.desktop <<EOL
@riless
riless / install_cudnn_v7.0.5.sh
Last active February 26, 2018 21:39
install_cudnn_v7.0.5
#!/usr/bin/env bash
CUDNN_TAR_FILE="cudnn-8.0-linux-x64-v7.tgz"
wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.0.5/${CUDNN_TAR_FILE}
tar -xzvf ${CUDNN_TAR_FILE}
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-8.0/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64/
sudo chmod a+r /usr/local/cuda-8.0/lib64/libcudnn*
# set environment variables
@riless
riless / decorators.py
Created June 18, 2018 10:37
Time a block of code in python
from contextlib import contextmanager
import time
@contextmanager
def timer(title, decimals=6):
t0 = time.time()
yield
print('"{}" - done in {:.{}f}s'.format(title, time.time() - t0, decimals))
@riless
riless / decorators.py
Created June 18, 2018 10:56
Time a block of code and store the elapsed time in a variable
import time()
class Timer:
def __init__(self, title, decimals=6):
self.title = title
self.decimals = decimals
def __enter__(self):
self.start = time.time()
return self
@riless
riless / tf_list_devices.sh
Created June 25, 2018 14:54
List TensorFlow GPU devices
python -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"
@riless
riless / CIS_bdpm_parser.py
Created November 1, 2018 22:19
CIS_bdpm Parser
# pip3 install requests pandas
import requests
import pandas as pd
import os
import sqlite3
if __name__ == '__main__':