Skip to content

Instantly share code, notes, and snippets.

View mattgaidica's full-sized avatar
💭
Spending most my time at https://github.com/Neurotech-Hub

Matt Gaidica, Ph.D. mattgaidica

💭
Spending most my time at https://github.com/Neurotech-Hub
View GitHub Profile
namespace :tddium do
desc "post_build_hook"
task :post_build_hook do
return unless ENV["TDDIUM_MODE"] == "ci"
return unless ENV["TDDIUM_BUILD_STATUS"] == "passed"
dir = File.expand_path("~/.heroku/")
heroku_email = ENV["HEROKU_EMAIL"]
heroku_api_key = ENV["HEROKU_API_KEY"]
current_branch = `git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-`.strip
class Myapi < Sinatra::Application
ActiveRecord::Base.default_timezone = :utc
configure :development, :test do
set :host, 'localhost:9999'
set :force_ssl, false
end
configure :staging do
set :host, 'my-api-staging.herokuapp.com'
set :force_ssl, true
function r = formatBytes(bytes)
s = {'B', 'KB', 'MB', 'GB', 'TB'};
e = floor(log(bytes)/log(1024));
r = sprintf(['%.2f ',s{e+1}], (bytes/(1024^floor(e))));
>> ml = 1.3;
>> ap = -3.3;
>> dv = 7.5;
>> S = ratBrainAtlas(ml,ap,dv)
S =
struct with fields:
coronal: [1×1 struct]
sagittal: [1×1 struct]
horizontal: [1×1 struct]
function [idx, val] = closest(testArr,val)
tmp = abs(testArr - val);
[~, idx] = min(tmp);
val = testArr(idx);
function colors = mycmap(filename,varargin)
% read image
A = imread(filename);
% set number of elements to return
n = size(A,2);
if ~isempty(varargin)
n = varargin{1};
end
rows = 3;
cols = 4;
figure;
for iRow = 1:rows
    for iCol = 1:cols
        subplot(rows,cols,prc(cols,[iRow iCol]));
        title(['Subplot ',num2str(prc(cols,[iRow iCol]))],'fontSize',14);
        text(0.5,0.5,[num2str(iRow),', ',num2str(iCol)],...
            'HorizontalAlignment','center','fontsize',14);
function p = prc(cols,rc)
% rc = desired [row,col] position of subplot
p = (rc(1) * cols) - (cols - rc(2));
function cb = cbAside(ax,labelText,cbColor,caxisVals)
cbOffset = .001;
cb = colorbar(ax,'Location','east');
% % cb.FontSize = 8;
gcaPos = ax.Position;
cbPos = cb.Position;
set(cb,'position',[gcaPos(1) + gcaPos(3) + cbOffset gcaPos(2) cbPos(3)/2 gcaPos(4)]);
set(cb,'YAxisLocation','right');
cb.Color = 'r';
function colors = linesUM(nColors,onlySecondary)
if ~exist('nColors','var')
nColors = Inf;
end
if ~exist('onlySecondary','var')
onlySecondary = false;
end
% maize & blue + BRIGHT colors, n=8
primaryUMcolors = [254 202 48;...