This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
#include <cstdlib> | |
template<class T> | |
T read_urandom() | |
{ | |
union { | |
T value; | |
char cs[sizeof(T)]; | |
} u; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Credits to: | |
- https://linux.die.net/man/2/setcontext | |
- https://stackoverflow.com/questions/8456085/why-cant-i-ignore-sigsegv-signal | |
*/ | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <signal.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def previous_current_next(iterable): | |
"""Make an iterator that yields an (previous, current, next) tuple per element. | |
Returns None if the value does not make sense (i.e. previous before | |
first and next after last). | |
""" | |
iterable=iter(iterable) | |
prv = None | |
cur = iterable.next() | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a vector of evenly spaced numbers. | |
vector<double> range(double min, double max, size_t N) { | |
vector<double> range; | |
double delta = (max-min)/double(N-1); | |
for(int i=0; i<N; i++) { | |
range.push_back(min + i*delta); | |
} | |
return range; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A wrapper function to capture STDOUT and STDERR into strings. | |
# | |
# Heavily inspired by | |
# https://github.com/JuliaStats/RCall.jl/blob/c1ff136864964cf2ac04b679f0c1b3b243df7e37/src/iface.jl#L35-L46 | |
# referred to by the issue comment | |
# https://github.com/JuliaLang/julia/issues/12711#issuecomment-133045787 | |
# | |
# The Base.start_reading(stream, cb) requires fixes in Base. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# git-remote-github-add: A bash function to quickly add a GitHub fork as a remote to your | |
# git repository. | |
# | |
# Copyright 2020 Morten Piibeleht | |
# | |
# License: MIT | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>KaTeX rendering bug example</title> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous"> | |
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script> | |
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
partition(f, xs) | |
Partitions a collection according to a predicate `f`. Similar to `filter`, but returns | |
the both the elements for which `f` is `true` and for which it is `false`, in two different | |
collections. | |
Returns a tuple of vectors, where the first vector contains the elements for which `f` is true | |
and the second the elements for which `f` is false. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2019 Morten Piibeleht | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this | |
# software and associated documentation files (the "Software"), to deal in the Software | |
# without restriction, including without limitation the rights to use, copy, modify, merge, | |
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | |
# to whom the Software is furnished to do so, subject to the following conditions: | |
# | |
#The above copyright notice and this permission notice shall be included in all copies or | |
#substantial portions of the Software. |
NewerOlder