Skip to content

Instantly share code, notes, and snippets.

View kinnala's full-sized avatar
🏛️

kinnala

🏛️
View GitHub Profile
@kinnala
kinnala / gist:5ae04c836cf1f548f242
Last active September 18, 2020 07:43
A function for making Mathematica syntax more Lisp'y (joke)
$[x_] := If[SameQ[Head[x], List], x[[1]] @@ Map[$, Rest[x]], x]
@kinnala
kinnala / gist:6376196
Created August 29, 2013 09:50
Soccerway API scraping example
import urllib2
import json
import re
class SoccerwayTeamMatches:
def __init__(self, teamId):
self.teamId = str(teamId)
self.data = {'all': [], 'home': [], 'away': []}
@kinnala
kinnala / gist:7775902
Created December 3, 2013 19:23
FFT w/ Hanning windowing (50% overlap of windows)
def fft_hann(t,pt,M):
"""
Perform FFT with Hanning windowing,
50% overlap of 2^M+1 windows.
The resulting spectra are averaged.
"""
# Amplitude correction of Hanning
ampl_corr = 2.
# Signal length
@kinnala
kinnala / dirichlet_example.m
Last active September 18, 2020 07:41
Solve linear elasticity problem in Matlab
close all;
clear all;
% define geometry
g=[ 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000
-0.7169 -0.1488 0.0706 0.6718 0.5185 0.2480 -0.1849 -0.3201
-0.1488 0.0706 0.6718 0.5185 0.2480 -0.1849 -0.3201 -0.7169
-0.0316 0.4644 0.0376 0.5215 -0.6358 -0.2630 -0.7560 -0.0676
0.4644 0.0376 0.5215 -0.6358 -0.2630 -0.7560 -0.0676 -0.0316
0 0 0 0 0 0 0 0
@kinnala
kinnala / instructions.md
Last active August 7, 2020 09:41
Running Wolfram Engine and Jupyter in a container

Perform the following steps:

docker pull davecwright3/jupyter-mathematica:v1.0
docker run -p 8888:8888 -it davecwright3/jupyter-mathematica:v1.0 /bin/bash
apt-get update
apt-get install libglu1
wolframscript

Then login into your account (get a license here: https://wolfram.com/developer-license). Quit wolframscript with Ctrl-D and run

@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;
@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: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 / 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 / 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 (