Skip to content

Instantly share code, notes, and snippets.

View ExpHP's full-sized avatar

Michael Lamparski ExpHP

View GitHub Profile
import numpy as np
import timeit

def measure(s):
	ts = timeit.repeat(s, globals=globals())
	print(f'{s:>20}: {min(ts):>6.3f}s ({ts})')


x = 2
@ExpHP
ExpHP / module-proposals-birds-eye.md
Last active August 24, 2017 18:36
module proposals from a birds-eye view

Proposals

  • TODO: internals threads
  • [Automatically Usable External Crates – cramertj]
    • TODO
  • TODO: more internals threads
  • TODO: where was that initial proposal for automodules?
    • (IIRC it defaulted to pub for directories?)
    • (wasn't this niko?)
  • TODO: more internals threads
@ExpHP
ExpHP / a.py
Created August 29, 2017 19:08
numpy memory leak
from __future__ import print_function
import objgraph
import numpy as np
print('--------------------------------------------------')
print('Numpy info:')
print()
print(np.__version__)
print()
np.show_config()
$ cabal test
Preprocessing library arithmoi-0.5.0.1...
Preprocessing test suite 'spec' for arithmoi-0.5.0.1...
Linking dist/build/spec/spec ...
/usr/bin/ld: cannot find -lHStagged-0.8.5-DG0qxw3gXxx4NfDcDx4Iai
/usr/bin/ld: cannot find -lHSregex-tdfa-1.2.2-JFeutuWiS2vGBM4qXQlqio
/usr/bin/ld: cannot find -lHSregex-base-0.93.2-AYjYAsBidAc8f5XNm9b2Aa
/usr/bin/ld: cannot find -lHSparsec-3.1.11-1CA7c0vSU7tJHGhveOjoXR
/usr/bin/ld: cannot find -lHStext-1.2.2.2-3ENqlljngKa6xj1Go2fVWq
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
@ExpHP
ExpHP / Main.hs
Created September 2, 2017 19:12
sieveSmallestFactor benchmark
module Main where
import Math.NumberTheory.Primes.Factorisation
import Data.Word
import Text.Printf
import System.CPUTime
data P = P { unP :: !Word64 }
oldWay :: FactorSieve -> Integer -> Integer
@ExpHP
ExpHP / cargo-deps.py
Created September 14, 2017 00:16
cargo-deps.py
#!/usr/bin/env python3
import os
import sys
# Prints cargo deps (each name-version pair), gathered recursively.
# I couldn't find anything that does this in cargo.
def main():
import argparse
@ExpHP
ExpHP / notes.md
Last active August 15, 2018 01:27

Deploying the rust compiler to Blue Gene

Luckily for us, powerpc64-unknown-linux-gnu is a supported target triple, and we can download the toolchain through rustup.

If a firewall prevents the use of rustup on the remote machine, you can download the toolchain on your own your own machine:

$ rustup toolchain add 1.20.0-powerpc64-unknown-linux-gnu
$ cd ~/.rustup/toolchains/1.20.0-powerpc64-unknown-linux-gnu/
$ tree -d -L 2
@ExpHP
ExpHP / notes.md
Last active September 14, 2017 15:52

Deploying the rust compiler to Blue Gene

Luckily for us, powerpc64-unknown-linux-gnu is a supported target triple, and we can download the toolchain through rustup.

If a firewall prevents the use of rustup on the remote machine, you can download the toolchain on your own machine

[ lampam@arch-t430s ] ~
$ rustup toolchain add 1.20.0-powerpc64-unknown-linux-gnu
$ cd ~/.rustup/toolchains/1.20.0-powerpc64-unknown-linux-gnu/
@ExpHP
ExpHP / tempdir.rs
Last active October 5, 2017 23:46
tempdir wrapper
//! Shim around the `tempdir` crate which doesn't delete the
//! directories on unwind, in order to facilitate debugging.
extern crate tempdir;
pub use tempdir::TempDir as ActualTempDir;
use ::std::io::Result;
use ::std::path::{Path, PathBuf};
/// Wrapper around `tempdir::TempDir` that does not destroy the directory on unwind.
#[derive(Debug)]
@ExpHP
ExpHP / 0-toc.md
Last active September 9, 2020 18:09
Phonopy band unfolding tools