Skip to content

Instantly share code, notes, and snippets.

View morteza's full-sized avatar
🍱

Morteza Ansarinia morteza

🍱
  • Luxembourg
View GitHub Profile
@morteza
morteza / build-protege5-app-bundle
Last active August 29, 2015 14:03
Create app bundle for Protege 5.0 from its binary distribution
#!/bin/bash
# Copy this into extracted `protege/` directory and execute in Terminal. Done!
# `Protege.app` will be available in the parent directory.
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROTEGE_DIR=$CURRENT_DIR
cd $PROTEGE_DIR
@morteza
morteza / weighted_random.scala
Created May 31, 2018 14:10 — forked from TJC/weighted_random.scala
Solution to scala-melb challenge, Mar 14 2012
// This is a fairly ugly solution; in a hurry and didn't spend much time on it.
import scala.util.Random
case class WeightedItem[T](item: T, weight: Double)
val items = Seq(WeightedItem("Red", 1d/6), WeightedItem("Blue", 2d/6),
WeightedItem("Green", 3d/6) )
def weightedSelection[T](
@morteza
morteza / fibs.scala
Last active June 6, 2018 07:15
Fibonacci Sequence in Scala with Immutable Stream
val fibs = 0 #:: fibs.scan(1)(_ + _)
fibs take 5 toList
@morteza
morteza / coords2labels.py
Created January 23, 2021 22:41
Convert MNI coords to a Harvard-Oxford labels using spherical masking
# %%
# A basic funtion to convert MNI coords (x,y,z) to harvard oxford "labels" using spherical masking.
# input:
# - list of coords of size N*3
# output:
# - list of labels of size N
import numpy as np
from nilearn import datasets