Skip to content

Instantly share code, notes, and snippets.

View hkmoon's full-sized avatar

HongKee Moon hkmoon

  • MPI-CBG
  • Dresden
View GitHub Profile
@hkmoon
hkmoon / StreamMap.java
Last active September 15, 2015 08:57
Java 8: stream(), map() and collect()
// In Java 8, there are stream(), map() and collect() for better collection manipulation
ArrayList<String> list = new ArrayList<>();
for(Person person : people)
{
list.add( person.getNickName() );
}
// The above code is shortened with the below
List<String> list = people.stream().map( Person::getNickName ).collect( Collectors.toList() );
@hkmoon
hkmoon / private.xml
Created October 5, 2015 20:19
Key mappings for Karabiner
<?xml version="1.0"?>
<root>
<item>
<name>Mapping hjkl on left up down and right</name>
<identifier>private.mapping_hjkl_on_arrow</identifier>
<autogen>__KeyToKey__
KeyCode::H, ModifierFlag::CONTROL_L,
KeyCode::CURSOR_LEFT
</autogen>
<autogen>__KeyToKey__
@hkmoon
hkmoon / Check.java
Created December 14, 2015 15:23
UTF-8 filesystem check
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* Created by moon on 12/8/15.
*/
public class Check
{
@hkmoon
hkmoon / ROIHdf5.java
Created August 9, 2017 07:56
ROI in HDF4ImageLoader
void process(File hdf5, SpimDataMinimal spimData, Interval roi) {
AbstractSequenceDescription<?, ?, ?> sequenceDescription = spimData.getSequenceDescription();
Hdf5ImageLoader hdf5Loader = new Hdf5ImageLoader(hdf5, /* hdf5 partitions */ null, sequenceDescription);
for (TimePoint timepoint : sequenceDescription.getTimePoints().getTimePointsOrdered()) {
for (BasicViewSetup setup : sequenceDescription.getViewSetupsOrdered()) {
RandomAccessibleInterval<UnsignedShortType> img = hdf5Loader.getSetupImgLoader(setup.getId()).getImage(timepoint.getId(), 0); // full res
RandomAccessibleInterval<UnsignedShortType> imgRoi = Views.interval(img, roi);
// process imgRoi here, it will be lazily loaded when accessed
}
}
@hkmoon
hkmoon / byobuCommands
Created June 22, 2018 08:36 — forked from jshaw/byobuCommands
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@hkmoon
hkmoon / vm-resize-hard-disk.md
Created July 1, 2019 11:08 — forked from christopher-hopper/vm-resize-hard-disk.md
Resize a Hard Disk for a Virtual Machine provisioned using Vagrant from a Linux base box to run using VirutalBox.

Resize a Hard Disk for a Virtual Machine

Our Virtual Machines are provisioned using Vagrant from a Linux base box to run using VirutalBox. If the Hard Disk space runs out and you cannot remove files to free-up space, you can resize the Hard Disk using some VirtualBox and Linux commands.

Some assumptions

The following steps assume you've got a set-up like mine, where:

export TRINITY_HOME="singularity exec /home/vagrant/Trinity-v2.8.4.simg Trinity"
mkdir trinityrnaseq
cd trinityrnaseq
git init
git remote add -f origin https://github.com/trinityrnaseq/trinityrnaseq.git
git config core.sparseCheckout true
echo "sample_data/test_Trinity_Assembly" >> .git/info/sparse-checkout
git pull origin master
mv sample_data/test_Trinity_Assembly/* .
export TRINITY="sudo singularity exec /home/vagrant/Trinity-v2.8.4.simg Trinity"
cd sample_data
$TRINITY --samples_file samples.PE.txt --seqType fq --max_memory 1G --output trinity_test_samples_PE
@hkmoon
hkmoon / Vagrantfile
Last active August 22, 2019 09:22
Simple Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
####################################################
# You can do this entire process while running on the filesystem you want to resize (yes, it's safe and fully supported). There is no need for rescue CDs or alternate operating systems.
#
@hkmoon
hkmoon / bootstrap.sh
Last active September 10, 2019 11:38
Simple vagrant bootstrap.sh
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y python-pip python3-pip
pip install numpy biopython
pip3 install numpy biopython
# create Trinity output, DATA, scripts folder
sudo -S -u vagrant mkdir -p /vagrant/output
sudo -S -u vagrant ln -s /vagrant/output output