Skip to content

Instantly share code, notes, and snippets.

View eywalker's full-sized avatar
🌴
vacation = coding in a difference place

Edgar Y. Walker eywalker

🌴
vacation = coding in a difference place
View GitHub Profile
@eywalker
eywalker / check_dep.py
Created November 19, 2020 03:21
Check and print all dependent entries on the target (restricted table)
import collections
from datajoint.table import FreeTable
class _RenameMap(tuple):
""" for internal use """
pass
def check_dep(table, restr=None):
@eywalker
eywalker / git-split.sh
Created November 12, 2020 11:39
Git utility to split a file with history tracked: based on https://stackoverflow.com/a/53849651
#!/bin/sh
if [[ $# -ne 2 ]] ; then
echo "Usage: git-split.sh original copy"
exit 0
fi
git mv $1 $2
git commit -n -m "Split history $1 to $2"
REV=`git rev-parse HEAD`
@eywalker
eywalker / nnfabrik.py
Created November 10, 2020 20:46
A convenient way to use `my_nnfabrik`
# importing the tables here is a trick to get IntelliSense to work
from nnfabrik.main import Fabrikant, Trainer, Dataset, Model, Seed, my_nnfabrik
# define nnfabrik tables here
my_nnfabrik("nnexplore_nnfabrik", context=locals())
@eywalker
eywalker / multi_conn.py
Created July 1, 2020 15:19
Using multiple database connections
import datajoint as dj
from getpass import getpass
def clone_conn(conn):
conn_info = conn.conn_info
return dj.Connection(host=conn_info['host'], user=conn_info['user'], password=conn_info['passwd'],
init_fun=conn.init_fun, use_tls=conn_info['ssl'])
conn2 = clone_conn(dj.conn())
@eywalker
eywalker / sample1.js
Created March 31, 2020 03:05
Node.js Callback vs Promise vs Async
const mysql = require('promise-mysql'); // use promisified version of mysql connector
const config = require('./config');
const _ = require('lodash');
const db_conn = {
host: config.dbHost,
user: config.dbUser,
password: config.dbPass
};
@eywalker
eywalker / pinwheel.py
Last active June 25, 2019 13:03
Create color pinwheel
import cmocean
import numpy as np
# resolution of the pin wheel - gives back reolution x resolution image
resolution = 1000
xv, yv = np.meshgrid(np.linspace(-1, 1, resolution), np.linspace(-1, 1, resolution))
theta = np.arctan2(yv, xv)
r = np.sqrt(yv**2 + xv**2)
fig = plt.figure(dpi=300)
@eywalker
eywalker / dj_alter_table.py
Last active March 3, 2021 17:13
Adding/drop new non primary-key attributes to a table in DataJoint
"""
The following is provided as a convenience utility to be able to add/drop non primary key attributes
to an existing DataJoint table. Both function should work as is - you can simply copy and paste them and
start using it without worrying about importing dependencies.
WARNING! These functions are NOT officially supported by DataJoint and make use of DataJoint internal logic
that is considered to be NOT part of the public API. These functions may cease to work or worse yet result
in unexpected results without any prior notice, and therefore should be used with atmost care.
We are working to add such "ALTER" method to DataJoint Python officially, and you can track the discussion/progress
@eywalker
eywalker / nvidia-docker-compose
Created August 16, 2016 21:34
nvidia-docker-compose
#!/usr/bin/env python3
# Modifies the "base" `docker-compose.yml` file to make use of NVIDIA GPUs as made
# available through `nvidia-docker`. If you execute this script without any argument,
# it will look for `docker-compose.yml.base` file in the current directory and
# creates `docker-compose.yml` with appropraite devices, volumes, etc, while
# incorporating existing configurations as found in `docker-compose.yml.base`.
# Alternatively, you can invoke the script as:
# $ ./nvidia-docker-compose filename
# which will base the creation of `docker-compose.yml` on the passed in
# `filename`
" Configure Vundle {{{
set nocompatible " be iMproved, required
filetype off " required
set runtimepath+=~/.vim/bundle/Vundle.vim
call vundle#begin() " installs plugins in default location
" let Vundle manage Vundle
" Required:
Plugin 'VundleVim/Vundle.vim'