Skip to content

Instantly share code, notes, and snippets.

View BenSchZA's full-sized avatar
🎯
Focusing

Benjamin Scholtz BenSchZA

🎯
Focusing
View GitHub Profile
# Setup of Ghost Blog on Digital Ocean
# Increase swap: see https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-22-04
sudo swapon --show
free -h
df -h
sudo fallocate -l 1G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
@BenSchZA
BenSchZA / state_history.py
Created May 11, 2021 12:36
Access cadCAD state_history
import numpy as np
def p_predator_births(params, substep, state_history, previous_state):
'''Predator Births Policy Function
The predator birth rate (rate of predators born per unit of time) is a product of
the prey population and the predator birth parameter plus a random variable.
i.e. the larger the prey population, the higher the predator birth rate
'''
@BenSchZA
BenSchZA / notebook.ipynb
Created September 4, 2020 13:53
mc-run-hotfix
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BenSchZA
BenSchZA / notebook.ipynb
Created September 3, 2020 20:38
monte-carlo-run-debug
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BenSchZA
BenSchZA / live-component-render-error.log
Created August 24, 2020 22:01
Phoenix LiveComponent rendering error
** (ArgumentError) cannot convert component AppWeb.Component.Statistic with id nil to HTML.
A component must always be returned directly as part of a LiveView template.
For example, this is not allowed:
<%= content_tag :div do %>
<%= live_component @socket, SomeComponent %>
<% end %>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BenSchZA
BenSchZA / shell.nix
Created August 18, 2020 08:23
Nix derivation for Python Jupyter environment
with import <nixpkgs> { };
(let
cadCAD = pkgs.callPackage ./cadCAD.nix { inherit (pkgs) ; };
python = pkgs.python38.override {
packageOverrides = python-self: python-super: {
buildPythonPackage = python-super.buildPythonPackage.overridePythonAttrs
(oldAttrs: { doCheck = !pkgs.stdenv.isDarwin; });
};
};
@BenSchZA
BenSchZA / filter_association.ex
Last active August 17, 2020 08:46
Filter by has_many association
from(record in Domain.DHR.DeviceHistoryRecord,
left_join: failures in assoc(record, :failures), on: failures.device_history_record_id == entry.id,
where: ilike(failures.type, ^"%#{query}%"),
distinct: entry.id
)
/nix/store/75cr8j05iha71zzbyz1sxajmadbhxllz-sat-env/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:56:10: fatal error: 'DiskArbitration/DADisk.h' file not found
#include <DiskArbitration/DADisk.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
10:06:04.842 [error] Could not compile file system watcher for Mac, try to run "clang -framework CoreFoundation -framework CoreServices -Wno-deprecated-declarations c_src/mac/*.c -o priv/mac_listener" manually inside the dependency.