Skip to content

Instantly share code, notes, and snippets.

View kinnala's full-sized avatar
🏛️

kinnala

🏛️
View GitHub Profile
@kinnala
kinnala / examples.md
Last active May 27, 2024 12:57
Authoring STACK-type questions using Coderunner

Authoring STACK-type questions using CodeRunner

CodeRunner is a Moodle plugin for programming assignments. However, after the plugin is deployed, it can be quite easily repurposed into a STACK-type math assignment checker with the checking logic implemented, e.g., in the Python language.

Example

After creating the CodeRunner question

@kinnala
kinnala / configuration.nix
Last active August 8, 2022 06:42
Minimal vim-configuration with nix syntax highlighting
environment.systemPackages = with pkgs; [
((vim_configurable.override {}).customize {
name = "vim";
vimrcConfig.packages.myplugins = { start = [ vimPlugins.vim-nix ]; };
vimrcConfig.customRC = ''
set nocompatible
set hlsearch
set backspace=indent,eol,start
syntax on
filetype plugin indent on
@kinnala
kinnala / main.py
Created July 12, 2022 13:10
Fake white-on-black console using Tkinter
from tkinter import Tk, Text, END
from tkinter.font import Font
class Game:
def __init__(self,
width=80,
height=24,
title="Untitled",
@kinnala
kinnala / gist:199d1c2ab9a234a6cf28ee994329e429
Created May 10, 2022 11:31
Connect to eduroam AP that has best signal strength by fixing BSSID
nmcli con down eduroam
nmcli con modify eduroam 802-11-wireless.bssid `nmcli d wifi list | grep eduroam | head -n 1 | awk '{print $1}'`
nmcli con up eduroam
@kinnala
kinnala / main.py
Created February 18, 2022 09:33
Dragon curve
# The equations are from: https://en.wikipedia.org/wiki/Dragon_curve
# I start with a line segment (0, 0) to (1, 0) and map the endpoints through f1 and f2.
# Then I have two segments (0, 0) to (0.5, 0.5) and (0.5, 0.5) to (1, 0).
# The endpoints are repeatedly mapped in the for-loop.
import matplotlib.pyplot as plt
import numpy as np
def f1(x):
return 1. / np.sqrt(2) * (
@kinnala
kinnala / README.md
Last active April 6, 2024 18:38
Install Mathematica in NixOS

This is a remainder for myself because I need to run Mathematica once a year. Often the version I use is different from nixpkgs.

First you find a copy of Mathematica_12.1.0_LINUX.sh or similar and find its sha256sum. Then you go to nixpkgs and copy all Mathematica files to a local directory. You need to modify default.nix and wrap its contents into

let pkgs = import <nixpkgs> {};
in pkgs.callPackage (
@kinnala
kinnala / main.tex
Created November 1, 2021 09:21
Single tex source for article and beamer slides
% Ever wanted to turn your latex article source into a quick beamer presentation?
% Add something like the following four lines to the beginning of your document:
%\documentclass{amsart}
%\renewenvironment{frame}{{}}
\documentclass[ignorenonframetext,red]{beamer}
\geometry{paperwidth=480pt,paperheight=300pt}
% Then those parts you want turned into slides wrap with \begin{frame} ... \end{frame}
@kinnala
kinnala / gist:7c12a384f2bad41f77cc1976e155d9ad
Created December 16, 2020 12:48
Compiling UxPlay and ludimus on NixOS

Following environment allows compiling both:

nix-shell -p cmake openssl pkgconfig gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-ugly gst_all_1.gst-plugins-bad pcre.dev avahi-compat gst_all_1.gst-libav libplist libunwind

However, I'm unable to connect with iPad or iPhone even after opening all ports on NixOS. WIP

@kinnala
kinnala / example.py
Last active November 29, 2021 10:33
Quickly parametrize Jupyter Notebooks and extract images and text outputs
# Add these lines to the first cell of Jupyter Notebook
# for argument support
try:
from _run_extract_args import arg
except Exception as e:
arg = [
"0", # nrefs
"P1", # udeg
"P0", # lamdeg
"stab", # "stab" enables stabilization
@kinnala
kinnala / gist:520bcd9f657eaadd3cdcd995e1a8a657
Last active September 18, 2020 07:37
Running Julia in NixOS

These instructions create a conda-shell type of environment for running Julia 1.1. (Derivation originally from https://gist.github.com/tbenst/c8247a1abcf318d231c396dcdd1f5304).

Note: Some Julia packages may fail to install due to missing binary dependencies. The built-in package manager of Julia will normally install these for you but will fail in case of NixOS. You need to "simply" figure out what is missing and add them to the .nix-file.

  1. Write the following expression to a file, e.g., julia-shell.nix:
{ pkgs ? import <nixpkgs> {}}:

let
jupyterPort = pkgs.config.jupyterPort;