Skip to content

Instantly share code, notes, and snippets.

View bast's full-sized avatar
🦀
rusting

Radovan Bast bast

🦀
rusting
View GitHub Profile
@bast
bast / sphinx-latex.def
Created November 20, 2021 02:56
Singularity recipe to generate pdf from Sphinx lesson
Bootstrap: docker
From: ubuntu:21.04
%files
requirements.txt
%post
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt install -y texlive texlive-fonts-extra latexmk
@bast
bast / luks-encrypted-root-on-nixos.org
Created June 13, 2021 15:58 — forked from walkermalling/luks-encrypted-root-on-nixos.org
Nix Setup with LUKS encrypted root

Setting up NixOs with LUKS encrypted root

Here are my working notes on getting a system up and running.

WARNING: You can run into a hidden problem that will prevent a correct partition setup and /etc/nixos/configuration.nix from working: if you are setting up a UEFI system, then you need to make sure you boot into the NixOS installation from the UEFI partition of the bootable media. You may have to enter your BIOS boot selection menu to verify this. For example, if you setup a NixOS installer image on a flash drive, your BIOS menu may display several boot options from that flash drive: choose the one explicitly labeled with “UEFI”.

References

I used these resources:

@bast
bast / runtest-example.py
Created June 1, 2021 08:52
Test script example.
#!/usr/bin/env python
# srdft_lda_molhes
# ----------------
# Molecule: Ethane
# Wave Function: srDFT (LDA) / STO-3G
# Test Purpose: Test analytical molecular hessian and dipole gradient
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
@bast
bast / literal-myst.txt
Created April 20, 2021 13:00
Nested literalincludes
# Sample episode in MyST Markdown
``````{challenge} some challenge
`````{tabs}
````{tab} some tab
```{literalinclude} conf.py
:language: python
:emphasize-lines: 5-10
:linenos:
import cProfile
from dftd3.dftd3 import D3Configuration, d3
def main(config, charges, coordinates):
d3_au = d3(config, charges, *coordinates)
coordinates = [
@bast
bast / example.py
Created March 24, 2021 09:30
Comparing dictionaries in Python
# https://github.com/seperman/deepdiff
from deepdiff import DeepDiff
d1 = {"something": 1, "another": 2, "yet another": 3}
d2 = {"something": 2, "another": 2, "yet another": 3}
difference = DeepDiff(d1, d2, ignore_order=True)
print(difference)
d1 = {"something": 1, "another": 2, "yet another": 3}
@bast
bast / fn-as-argument.rs
Created April 11, 2020 15:00
Show how to pass function as argument in Rust.
struct Point {
x: f64,
y: f64,
}
fn custom(p1: &Point, p2: &Point) -> f64 {
let dx = p2.x - p1.x;
let dy = p2.y - p1.y;
let d = dx * dx + dy * dy;
return d.sqrt();
@bast
bast / custom-allocation.f90
Created February 27, 2020 14:39
Allocates a chunk of memory. Can be used to test memory high water mark tools.
! /usr/bin/time -v ./a.out
program example
implicit none
integer(8), parameter :: mw = 1000000 ! 200 MW or 1525 MB
real(8), allocatable :: a(:)
print *, 'will try to allocate', 200*mw, 'double precision floats'
@bast
bast / cmake.sh
Created February 18, 2020 12:18
How to get a recent CMake.
wget -qO- https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.tar.gz | tar xz
mv cmake-3.16.4-Linux-x86_64 cmake
# you can load this in a script that needs CMake
export PATH=$HOME/cmake/bin:$PATH
cmake --version
# cmake version 3.16.4