Skip to content

Instantly share code, notes, and snippets.

## Plot heatmap in the style of Fig 1B-2:
## dx.doi.org/10.1371/journal.pgen.1006224.g001
library(ggplot2)
## Mock data of 50 rows, 10 columns and 2 strands.
value <- function(mean_ = 0, length_ = 10) {
dnorm(seq(-1, 3, length = length_), mean = mean_, sd = 0.2)
}
noise <- function(length_ = 10) {
rnorm(length_, mean = 0, sd = 0.1)
@omsai
omsai / wait-for-cpus.sh
Created June 22, 2016 21:29
Informal bash scheduler for compute server
#!/bin/bash
# Informal scheduler for our shared compute server.
#
# Run with "-h" for usage.
show_help () {
name=$(basename $0)
echo -e "Usage: $name [OPTION]
Informal scheduler for our shared compute server.
@omsai
omsai / raster.R
Last active May 7, 2016 21:15
10um linescan with 100x objective (modified from https://github.com/omsai/microscope-optical-input)
## Calculate power distribution of laser scanning photo-activation device
##
## Laser beam symbols used are from the beam power formula:
## [1] en.wikipedia.org/wiki/Gaussian_beam#Power_through_an_aperture
##
## References:
## [2] radiantzemax.com/kb-en/Goto50125.aspx
## [4] en.wikipedia.org/wiki/Beam_diameter#D4.CF.83_or_second_moment_width
## [5] en.wikipedia.org/wiki/Normal_distribution
##
@omsai
omsai / Makefile
Last active November 20, 2015 03:06
commit :
git add labnotes*.org
git add Makefile
git commit -m "ENH: Record up to $(shell date +%Y-%m-%dT%H:%M)"
git push
.phony : commit
@omsai
omsai / pdflp.sh
Created October 15, 2015 03:15
Print double sided PDF documented interactively with HP DeskJet F4480
#!/bin/bash
# Use realpath for tilde expansion
pdf_file=$(realpath "${1}")
# Usage message if file does not exist
if ! [ -e "${pdf_file}" ] ; then
echo -e "Usage: $(basename $0) <pdf_file>
Double-sided printing. First prints the odd pages in reverse order,
@omsai
omsai / emerge_info
Last active October 8, 2015 16:44
Gentoo Linux ebuild for Woolz libraries and executables for image processing. Patched configure.ac per https://autotools.io/autoconf/arguments.html
$ emerge --info
Portage 2.2.20.1 (python 2.7.9-final-0, default/linux/x86/13.0/desktop, gcc-4.8.5, glibc-2.20-r2, 3.18.7-gentoo i686)
=================================================================
System uname: Linux-3.18.7-gentoo-i686-Intel-R-_Core-TM-_i5-4200U_CPU_@_1.60GHz-with-gentoo-2.2
KiB Mem: 16547692 total, 6993780 free
KiB Swap: 4456444 total, 4456312 free
Timestamp of repository gentoo: Wed, 07 Oct 2015 19:30:01 +0000
sh bash 4.3_p39
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash: 4.3_p39::gentoo
@omsai
omsai / update-release.sh
Created September 9, 2015 03:08
My shitty script to update Micro-Manager release on GNU/Linux. Better is: https://micro-manager.org/wiki/How_To_Build_Micro_Manager_From_Source_On_Ubuntu_13.10
#!/usr/bin/env sh
# Update to the latest Micro-Manager release.
#
# - Download and unpack the source tarball from GitHub mirror.
# - Update 3rdpartypublic svn repo.
# - Unpack ImageJ to new versioned directory.
# - Compile and install Micro-Manager to the ImageJ directory.
# Read the current release version
@omsai
omsai / TS13_lineage_prune_0.txt
Last active September 10, 2015 02:10
Print graphviz ontology in tabbed plain text using Python pandas
embryo eye
embryo trunk mesenchyme
embryo branchial arch
embryo hindgut diverticulum
embryo heart
embryo gut endoderm
embryo head
embryo surface ectoderm
embryo neural ectoderm
embryo otic placode
@omsai
omsai / mv-spaces-dashes.sh
Created July 22, 2015 20:06
Recursively replace spaces with dashes for GNU Make.
# Replace all spaces in file names with dashes.
find . -name "* *" -type f | \
while IFS= read -r f ; do \
mv "$f" "$(dirname "$f")/$(basename "$f" | tr ' ' -)" ; \
done
@omsai
omsai / Makefile
Created July 22, 2015 20:05
Create center cropped thumbnail images
# Create thumbnails in another directory. Center resize and crop
# images to 150x150.
OBJDIR := ../tabs-square
IMG_SRC := $(wildcard *.jpg)
OBJS := $(addprefix $(OBJDIR)/,$(IMG_SRC))
$(OBJDIR)/%.jpg : %.jpg
convert \
$< \