Skip to content

Instantly share code, notes, and snippets.

@PHPirates
PHPirates / Knitr.R
Last active September 6, 2018 15:46
Script to let Knitr generate LaTeX from R code
# author: Sten Wessel
# Instructions:
# Put this file on the same level as your LaTeX file
# Put your R scripts in a folder scripts/
# [IntelliJ] If you want to run your R scripts, make a run configuration as with working directory the folder this file is in
# In your R script, make comments like "## ---- part.a ----" to define sections
# In this file, edit the definition of R script content (the HOMEWORK.1 list)
# In the preamble in your LaTeX file, add the following:
#
@PHPirates
PHPirates / IntegerEuclidsToLaTeX.kt
Last active January 11, 2018 15:47
Adapted IntegerEuclids to print LaTeX
import java.math.BigInteger
/**
* The extended euclidian algorithm for two numbers (BigIntegers included). Also prints a LaTeX tabular of all the steps.
*
* Looks for `ax + by = gcd(a, b)` where `a` and `b` are the input variables.
* [gcd] contains the gcd, [x] and [y] contain `x` and `y` as seen in the previous expression.
*
* @author Ruben Schellekens
* @author Thomas Schouten
@PHPirates
PHPirates / result.png
Last active May 20, 2018 13:55
Simple tikz block schemas
result.png
@PHPirates
PHPirates / StuffContainer.kt
Last active March 7, 2018 19:11
Example of use of replaceWith in Kotlin
class StuffContainer(val context: Context?) {
private val prefs = android.preference.PreferenceManager.getDefaultSharedPreferences(context)
/** This is stuff. */
var stuff: Boolean
get() = prefs.getBoolean("stuffkey", false)
set(value) {
prefs.edit().putBoolean("stuffkey", value).apply()
}
@PHPirates
PHPirates / git-bundles.md
Last active March 7, 2023 14:28
How to use git bundles

Let machine M be the Main machine with the repo, and A the Auxiliary machine which wants to help out.

First time setup

  1. Machine M creates bundle with complete repo:
git bundle create repo.bundle HEAD master
  1. M sends repo.bundle to A.
  2. A clones repo from bundle:
@PHPirates
PHPirates / multiple-git-user-ssh.rst
Last active October 28, 2018 20:18
Set up another git user with ssh
  1. Generate new ssh key pair

    ssh-keygen -t rsa -b 4096 -C "[email protected]"
  2. Give it a different name than default, e.g. id_rsa_iam.

  3. Add this key to the ssh agent, cd ~/.ssh and ssh-add id_rsa_iam

    If you get the error 'Could not open a connection to your authentication agent.' then start the ssh-agent with

@PHPirates
PHPirates / keybase.md
Created June 29, 2018 11:01
Keybase proof

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@PHPirates
PHPirates / sample-bibtex.tex
Created July 29, 2018 09:16
Sample file for testing bibtex bibs.
\begin{filecontents}{main.bib}
@Book{knuth1990,
author = {Knuth, Donald E.},
title = {The {\TeX}book},
year = {1990},
isbn = {0-201-13447-0},
publisher = {Addison\,\textendash\,Wesley},
}
\end{filecontents}
@PHPirates
PHPirates / levmar.log
Created August 3, 2018 10:15
Attempt at using levmar
download libblas.dll, libblas.lib, liblapack.dll, liblapack.lib from https://icl.cs.utk.edu/lapack-for-windows/lapack/#libraries_mingw to lib/
Add to `stack.yaml`:
extra-deps:
- bindings-levmar-1.1.0.5
# - levmar-1.2.1.8 -- Does not support base 4.9 at the moment. A more up to date fork is used
- github: PHPirates/levmar
commit: f36ef9ae1c0d44950a28a445d4f459257f77dd4d
@PHPirates
PHPirates / updating-python.rst
Last active March 8, 2019 12:12
How to update Python and projects with dependencies on Windows

Updating Python (This step Windows only)

  1. Install a new python version from https://www.python.org/downloads/windows/ the 64 bit web installer
  2. Make sure your PATH only contains the paths to the new version
  3. Delete the old python
  4. Restart your pc and test in cmd with python -V

Updating the basic Python packages

  1. Update global setuptools by running in cmd (sudo) python -m pip install -U setuptools. If this fails with a PermissionError, try pip install setuptools --upgrade --ignore-installed.