Skip to content

Instantly share code, notes, and snippets.

@sitag
sitag / HelloWorld.kt
Created November 25, 2019 05:06 — forked from mitchwongho/HelloWorld.kt
A trivial Gradle build file for a Kotlin application
fun main(args: Array<String>) {
MyFirstClass("Hello, My First Class").out()
}
class MyFirstClass(val message: String) {
fun out() {
println(message)
}
}
@sitag
sitag / distcorr.py
Created September 5, 2019 23:22 — forked from satra/distcorr.py
Distance Correlation in Python
from scipy.spatial.distance import pdist, squareform
import numpy as np
from numbapro import jit, float32
def distcorr(X, Y):
""" Compute the distance correlation function
>>> a = [1,2,3,4,5]
>>> b = np.array([1,2,9,4,4])
use std::collections::HashMap;
// escaping the borrow checker
fn test(h:&mut HashMap<String, i64>) -> &mut i64 {
{
let matched:Option<&mut i64> = h.get_mut("B");
if matched.is_some() {
// assignment to raw pointer side steps the borrow checker
let v:*mut i64 = matched.unwrap();
@sitag
sitag / parallel_op_vec.rs
Created July 27, 2015 00:44
[rust] operating on a vector in parallel with unsafe rust
#![feature(unique)]
use std::thread::spawn;
// operating on a vector in parallel
fn main() {
let mut data:Vec<u32> = vec![1u32, 2, 3];
println!("{:?}", data);
let head = data.as_mut_ptr();
let mut guards = (0..3).map(|i|