Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
rawr

Vanessasaurus vsoch

💭
rawr
View GitHub Profile
@vsoch
vsoch / index.php
Last active Aug 16, 2022
Generate RSS feed for files in a directory folder. Put this file in a folder with files, modify the $allowed_ext variable to customize your extensions, and $feedName, $feedDesc, $feedURL, and $feedBaseURL. Then navigate to the folder on the web to see the xml feed. Done!
View index.php
<?php
header('Content-type: text/xml');
/*
Runs from a directory containing files to provide an
RSS 2.0 feed that contains the list and modification times for all the
files.
*/
$feedName = "My Audio Feed";
$feedDesc = "Feed for the my audio files in some server folder";
@vsoch
vsoch / decorators.py
Created Dec 3, 2020
An example for how to customize login-required (in this case, to use a session based token instead)
View decorators.py
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.shortcuts import render, resolve_url
from myapp.settings import cfg
from myapp import settings
from urllib.parse import urlparse
import uuid
def login_is_required(
@vsoch
vsoch / main.go
Last active Oct 13, 2021
Embedded fields in structs
View main.go
package main
import (
"fmt"
)
type Fruit struct {
Name string
Color string
}
View latex-jekyll-site.yaml
name: generate-site
on:
pull_request: []
push:
branches:
- "main"
jobs:
Update:
@vsoch
vsoch / Singularity
Last active Jun 28, 2021
A quick tutorial on how to generate a Singularity image with loadcaffee
View Singularity
Bootstrap: docker
From: ubuntu:16.04
%runscript
. /torch/install/bin/torch-activate
exec /bin/bash
%labels
MAINTAINER vsochat@stanford.edu
@vsoch
vsoch / singularity-hub-badge.md
Created Apr 26, 2021
How to generate the Singularity Hub Archive Badge!
@vsoch
vsoch / vcademy_mutual_information.m
Last active Apr 5, 2021
Mutual Information for Image Registration: an example of why maximizing mutual information is preferable over minimizing the least sum of squares for aligning two images from different modality.
View vcademy_mutual_information.m
% Mutual Information
% This shows why mutual information is important for registration, more-so
% than another metric like the least sum of squares.
% VSoch July 2013
% First, let's read in two pickle images that we want to register
% Note - this is a picture I found on google search, and I transformed it in
% photoshop by moving it down and right, and then CONTROL+I to get the inverse
pickle1 = imread('pickle1.png');
pickle2 = imread('pickle2.png');
@vsoch
vsoch / dinosaur.lp
Last active Mar 21, 2021
My first logic program - am I a dinosaur (requires clingo)
View dinosaur.lp
% clingo dinosaur.lp
% These are blanket facts, statements that each of these is living
% I think these are called atoms
living(vanessa).
living(fernando).
living(maria).
% This tells use size of arms for each living thing
armsize(vanessa, "small").
armsize(fernando, "large").
View joblib_vs_pickle.py
from sklearn.externals import joblib
import time
import numpy
import pickle
bigarray = numpy.zeros([190,91,190])
bigarray = bigarray.flatten()
### Saving
@vsoch
vsoch / snakemake-debugging.sh
Created Oct 20, 2020
Snakemake Debugging on Google Cloud
View snakemake-debugging.sh
# This is a small script (that typically I copy paste) on a Google Cloud instance
# to set up an environment to mimic a worker. It includes installing snakemake,
# retrieving a package with the working directory (which typically has the
# version of snakemake I aim to develop or debug, and then interactively debugging
# or doing this.
sudo apt-get install -y wget bzip2 ca-certificates gnupg2 git
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
sudo chown -R $USER /opt
bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda