Skip to content

Instantly share code, notes, and snippets.

@nuada
nuada / playbook-nopython.yml
Created July 6, 2016 11:40
Playbook demonstrating simple workaround if target system lacks Python
---
- hosts: all
gather_facts: no
become: yes
pre_tasks:
- name: install python
raw: sudo apt-get install -y -qq python-minimal
roles:
- some_role
@nuada
nuada / launch_terminal.sh
Created May 18, 2016 11:04
Execute command in new Terminal window on Mac OS X using Applescript.
#!/bin/sh
echo 'on run
-- check if Terminal is already running
tell application "System Events"
set isRunning to (exists process "Terminal")
end tell
tell application "Terminal"
-- if Terminal is running create new window
if isRunning then do script ""
@nuada
nuada / make_pkg
Created May 2, 2016 20:16
Make Mac OS X .pkg file from py2app python application.
#!/bin/bash
rm -rf dist build
python setup.py py2app
productbuild --component dist/AppName.app /Applications dist/AppName.pkg
@nuada
nuada / render_html.R
Created April 25, 2016 09:33
Render R script with embedded Markdown to HTML.
#!/usr/bin/Rscript
library(rmarkdown)
rmarkdown::render("your-script.R")
import std.stdio;
import std.file;
import std.path;
import std.process;
import std.algorithm;
import std.parallelism;
void main(string[] args) {
int[string] no_of_reads;
@nuada
nuada / doc_per_target.R
Last active April 14, 2016 07:07
Calculate and plot sequencing coverage per target region (ex. gene).
#!/usr/bin/Rscript
library(foreach)
library(doParallel)
library(iterators)
target_filename <- commandArgs(trailingOnly=T)[1]
doc_filename <- commandArgs(trailingOnly=T)[2]
if (is.na(doc_filename) || !file.exists(doc_filename) || is.na(target_filename) || !file.exists(target_filename)) {
print('Usage: Rscript <script.R> <targets.bed> <doc file>')
@nuada
nuada / rebuild_spotlight.sh
Created February 8, 2016 08:27
Erase and rebuild Spotlight index
sudo mdutil -Ea
@nuada
nuada / log-test.sh
Created November 26, 2015 11:15
BASH script that automatically logs strerr and stdout to given file.
#!/bin/bash
LOG=/path/to/log_file.log
>${LOG}
exec > >(tee -a ${LOG})
trap "kill -9 $! 2>/dev/null" EXIT
exec 2> >(tee -a ${LOG} >&2)
trap "kill -9 $! 2>/dev/null" EXIT
echo Test 1
@nuada
nuada / beeline2plink.sh
Last active November 10, 2015 14:04
Convert Illumina Beeline final report to PLINK format using beelinetools: https://github.com/pgxcentre/beelinetools
@nuada
nuada / gad_import_to_sqlite.sh
Created August 7, 2015 11:11
Import GAD (Genetic Association Database, http://geneticassociationdb.nih.gov/) to SQLite
#!/bin/bash
echo "
CREATE TABLE gadcdc (
'ID' integer,
'ALTNAME' text,
'DISEASE' text,
'DIS_CLAS' text,
'CH_BAND' text,
'GENE' text,