Skip to content

Instantly share code, notes, and snippets.

from copy import copy
import theano as th
import theano.tensor as T
def isshared(node):
"Is there a better way to do this?"
return hasattr(node, 'update')
def unpack_nodes(expr):
"""
from scipy.sparse import linalg
import numpy as np
import map_utils
def dim2w(dim):
return np.arange(-np.ceil((dim-1)/2.), np.floor((dim-1)/2.)+1)
class fractional_modified_laplacian(linalg.LinearOperator):
def __init__(self, dims, kappa, alpha):
@apatil
apatil / theano_second_derivatives.py
Created June 2, 2011 18:19
Attempts to produce second derivative vector (diagonal of Hessian) in Theano
import numpy as np
from theano import tensor as T
import theano
x = T.dvector('x')
z = T.dscalar('z')
y = T.sum(T.cos(x*z))
x_test = np.random.normal(size=10)
@apatil
apatil / lxc-sense
Last active December 14, 2015 08:39
A Linux container based on the stock 'ubuntu' one for Sense.
#!/bin/bash
#
# template script for generating container for LXC
# with username and password 'sense'
# and an ssh key for the root user.
#
# This script consolidates and extends the existing lxc ubuntu scripts
#
#!/bin/bash
# (C) Copyright Canonical 2011,2012
# What lxc container to clone
LXC_BASE=""
# $2 is a path to bind mount e.g. /tmp/foo.
LXC_BIND=""
LXC_DIR=""
UNION="overlayfs"
@apatil
apatil / iptables-failure.js
Last active December 25, 2015 07:19
On Ubuntu 12.04, with Docker version 0.6.3, build b0a49a3, this script will cause iptables failures to prevent launch of some docker containers
#!/usr/bin/env node
var shell = require("shelljs")
var n = 100;
var nPorts = 10;
var port = 40000;
var launchCmds = [];
for (var i = 0; i < n; i++) {
@apatil
apatil / test.sh
Created October 31, 2013 20:15
Reproduction of Docker issue
#!/bin/bash
# I ran this on an EC2 c1.medium instance with Docker version 0.6.3 on Ubuntu 12.04.
# I ran docker -d on tcp port 4243, and delivered 'stop' via the rest api
# because that's what I do in my production setup, but I don't know if that
# makes a difference.
# First, run ubuntu:12.04, and in it do
# echo -e '#!/bin/bash\nsleep 600' > cmd.sh
# chmod +x cmd.sh
# Then commit it and tag it as img-with-cmd
@apatil
apatil / pv
Created November 4, 2016 19:46
apiVersion: v1
kind: PersistentVolume
metadata:
name: projects-share
labels:
app: sense
spec:
capacity:
storage: 12E
accessModes:
@apatil
apatil / tests
Created May 12, 2014 20:03
CoreOS/Docker mount propagation tests
# Test 1:
# Launch data-only container in privileged mode
sudo docker run -i -t --name dataonly --privileged -v /shared ubuntu:14.04 /bin/bash
# in container:
mdir /shared/usr
mount --bind /usr /shared/usr
# Launch client container and attempt to read data from data-only container
sudo docker run -i -t --volumes-from dataonly ubuntu:14.04 /bin/bash
@apatil
apatil / shared-mounts-nodocker.sh
Last active February 2, 2017 11:52
Shared mounts
#!/usr/bin/env bash
ROOTDIR=$PWD
echo "Setting up"
mkdir -p $ROOTDIR/shared
sudo mount --bind $ROOTDIR/shared $ROOTDIR/shared
sudo mount --make-unbindable $ROOTDIR/shared
sudo mount --make-shared $ROOTDIR/shared