Skip to content

Instantly share code, notes, and snippets.

View knedlsepp's full-sized avatar
🍍
🖋️

Josef Kemetmüller knedlsepp

🍍
🖋️
View GitHub Profile
@knedlsepp
knedlsepp / distancePointsAffineSpace.m
Last active August 29, 2015 14:17
Computing the distance of points and an affine space
function d = distancePointsAffineSpace(Points, Space)
lengths = @(X) sqrt(sum(X.^2,2));
d = lengths(Points - projectPointsOntoAffineSpace(Points, Space));
end
function [projectedPoints, coordinates] = projectPointsOntoAffineSpace(Points, Space)
%coordinates are with respect to an orthonormal base located in Space(1,:)
dirVecs = bsxfun(@minus, Space(2:end,:), Space(1,:));
% Orthonormalize the direction vectors;
dirVecs = orth(dirVecs.').';
@knedlsepp
knedlsepp / computeBoundaries.m
Last active August 29, 2015 14:17
Computing the faces and vertices of the boundary of an m-dimensional polytope residing in n-dimensional space.
%% %% Requirements:
%% distancePointsAffineSpace:
%% https://gist.github.com/knedlsepp/3e37f147cb4c94ae6223
%% affineSpaceIntersection:
%% https://github.com/knedlsepp/affineSpaceIntersection/blob/master/affineSpaceIntersection.m
%% uniquetol:
%% http://www.mathworks.com/matlabcentral/fileexchange/27498-unique-with-tolerance/content/uniquetol.m
%% // Read dataset
clear;
data = [ 475. , 605.75, 1.;
571. , 586.5 , 2.;
233. , 558.5 , 3.;
669.5 , 562.75, 4.;
291.25, 546.25, 5.;
759. , 536.25, 6.;
362.5 , 531.5 , 7.;
448. , 513.5 , 8.;
834.5 , 510. , 9.;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knedlsepp
knedlsepp / default.nix
Last active June 15, 2020 16:40
How to pin a nix version in a default.nix file. (Override the pinned version via: nix-shell --arg nixpkgs '<nixpkgs>')
{nixpkgs ? null}:
let
sysPkg = import <nixpkgs> { };
pinnedPkg = sysPkg.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "cf62a27a326a9cdbb01d627b1faaea3a0d5e886c";
sha256 = "1q74ciqq5r17vidw2025x8idsncz9k7w60warrij4q7piaffgvd7";
};
pkgs = if nixpkgs==null then
@knedlsepp
knedlsepp / README.md
Created December 5, 2016 20:50 — forked from mbbx6spp/README.md
How to install Nix in your home directory

Nix

Prerequisites

  • wget is installed
  • tar is installed

Purpose

If you really don't want to install Nix under /nix (or you can't) then you can install Nix

@knedlsepp
knedlsepp / default.nix
Last active November 19, 2017 09:46
nix: Composing overlays
let
lib = (import <nixpkgs> { overlays = []; }).lib;
composeOverlays = lib.foldl' lib.composeExtensions (self: super: {});
in
composeOverlays [(import ./overlay1.nix)
(import ./overlay2.nix)
(self: super: {package30 = self.htop; })
]
{nixpkgs, ngsolveSrc}:
rec {
build = with import <nixpkgs> { };
releaseTools.nixBuild {
name = "ngsolve";
src = ngsolveSrc;
doCheck = true;
preConfigure = ''
echo "Prevent ngsolve from downloading catch manually"
substituteInPlace CMakeLists.txt \
@knedlsepp
knedlsepp / .profile
Created February 5, 2018 01:09 — forked from jahio/.profile
Some useful aliases for installing and working with NixOS
#!/usr/bin/env $SHELL
alias lsblk="lsblk -o MODEL,VENDOR,NAME,LABEL,SIZE,MOUNTPOINT,FSTYPE"
alias gramps="nix-env -p /nix/var/nix/profiles/system --list-generations"
alias nixos-rebuild="nixos-rebuild -j 6 --cores 8"
#
# -j is how many "jobs" or simultaneous computational processes run in tandem
# --cores is how many CPU cores you want to use
# How do you get these values? `cat /proc/cpuinfo` and look at the number of
# returned "CPUs". They're zero indexed, so if you get the last one as object
# number seven (7), you have 8 cores.
@knedlsepp
knedlsepp / default.nix
Created September 5, 2018 22:38
example-nixpkgs-based-docker-image
# Examples taken from:
# https://github.com/NixOS/nixpkgs/blob/c58b11d229f63a85ee1d05fc9940a20fa2b73975/pkgs/build-support/docker/examples.nix
# Usage:
# $ nix-build -A redis
# $ docker load < result
{ nixpkgs ? (builtins.fetchGit {
url = git://github.com/NixOS/nixpkgs-channels;
ref = "nixos-18.09";
rev = "c58b11d229f63a85ee1d05fc9940a20fa2b73975";
})