Skip to content

Instantly share code, notes, and snippets.

View robertodr's full-sized avatar
🤡
Clowning around

Roberto Di Remigio Eikås robertodr

🤡
Clowning around
View GitHub Profile
@robertodr
robertodr / configuration.nix
Last active September 29, 2022 08:48
NixOS configuration for minimal fresh installation on the Framework
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[
"${builtins.fetchGit { url = "https://github.com/NixOS/nixos-hardware.git"; }}/framework/12th-gen-intel"
@robertodr
robertodr / sgdisk.md
Created September 28, 2022 18:18
Formatting with `sgdisk`
DISK='/dev/disk/by-id/disk1'

sgdisk --zap-all ${DISK}

# syntax: --new=partnum:start:end
# syntax: --typecode=partnum:{hexcode|GUID}

# EFI system partition
sgdisk --new=1:1M:+1G --typecode=1:EF00 ${DISK}
@robertodr
robertodr / flake.nix
Last active December 14, 2023 12:36
Sample Nix flake using mach-nix
{
description = "veloxchem-hpc";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
pypi-deps-db = {
url = "github:DavHau/pypi-deps-db/a8ea7f774b76d3b61237c0bc20c97629a2248462";
flake = false;
};
mach-nix = {
@robertodr
robertodr / configuration.nix
Created September 13, 2021 13:37
Caddy on NixOS
{ config, pkgs, options, ... }:
let
baseConfig = {
allowUnfree = true;
};
unstable = import <nixos-unstable> { config = baseConfig; };
in
{
imports = [
@robertodr
robertodr / dftd3-gradient-profile.py
Created April 7, 2021 08:18
Example profiling script for D3 gradient with JAX
import cProfile
from dftd3.dftd3 import D3Configuration, D3_derivatives
def main(order, config, charges, coordinates):
_ = D3_derivatives(order, config, charges, *coordinates)
coordinates = [
@robertodr
robertodr / dftd3-pre-jax-profile.py
Created April 7, 2021 08:03
Example profiling script for pyDFTD3 v2.0a0
import cProfile
from dftd3.dftd3 import d3
def main(charges, coordinates, functional, damping):
_, _, _ = d3(charges, coordinates, functional=functional, damp=damping)
coordinates = [
@robertodr
robertodr / cube-slider.py
Created March 3, 2021 12:44
Visualize two cube files with an interactive slider
from ipywidgets import interact, fixed, widgets
@interact(mol_xyz=fixed(pyridine_xyz), cube=widgets.SelectionSlider(options=["HOMO", "LUMO"], description="MO"))
def draw_geometry_and_cube(mol_xyz, cube):
# Adapted from: https://adreasnow.com/Cheat%20Sheets/Python/Psi4Interactive/#viewing-psi4-molecules-with-cubes-py3dmol
# read volumetric data
with open(f"{cube}.cube", "r") as f:
cube = f.read()
try: dict
except: from UserDict import UserDict as dict
class Xlator(dict):
""" All-in-one multiple-string-substitution class """
def _make_regex(self):
""" Build re object based on the keys of the current dictionary """
return re.compile("|".join(map(re.escape, self.keys( ))))
def __call__(self, match):
@robertodr
robertodr / update-runtest.md
Last active January 14, 2020 22:35
Update to runtest v2
  1. Compile LSDALTON.
  2. Select a test (e.g. ddynam). Tests that use v1 of runtest are declared using the CMake macro add_lsdalton_runtest_v1. Choose one and cd to its folder.
  3. Run it with ./test -b /build/folder
  4. Edit the test script:
    • Adjust imports. Screenshot from 2020-01-14 23-21-57
    • Declare filters as a list not an object. Screenshot from 2020-01-14 23-24-27
    • Run the tests, looping over lists of inputs if necessary. Accumulate the exit code into the ierr variable. Screenshot from 2020-01-14 23-24-27