Skip to content

Instantly share code, notes, and snippets.

@banbh
banbh / plot_several_functions.R
Created July 15, 2022 01:27
Example of plotting several functions using the tidyverse
library(tidyverse)
bind_rows(
trig = enframe(list(a = sin, b = cos)),
other = enframe(list(a = log, b = sqrt)),
.id = 'id') %>%
group_by(id, name) %>%
summarise(x = seq(1,10,len=100),
y = value[[1]](x),
.groups = 'drop') %>%
@banbh
banbh / lt_aux_two.lean
Created December 8, 2019 20:19
Proving lt_aux_two using transitivity
lemma lt_aux_two (a b : mynat) : succ a ≤ b → a ≤ b ∧ ¬ (b ≤ a) :=
begin
intro h,
split,
exact le_trans _ _ _ (le_succ_self a) h,
intro h2,
exact not_succ_le_self _ (le_trans _ _ _ h h2),
end
@banbh
banbh / serial.R
Created August 25, 2019 20:45
Reading Arduino serial data from R
library(serial)
# See https://www.arduino.cc/reference/en/language/functions/communication/serial/begin/
# SERIAL_8N1 (default) = n,8,1
con <- serialConnection(name = "test",
port = "COM3",
mode = "9600,n,8,1",
newline = 0,
translation = "binary")
@banbh
banbh / file1.py
Created January 19, 2014 22:13 — forked from anonymous/file1.py
dir
ls
ls *.py
cd Docs/
ls
cd Python/
ls
%load test.py
static void Foo()
{
//Action<Action<int>, Action<string>> a = (a1, a2) => Example(3, a1, a2);
//var aa = a.MergeYields().AsEnumerable();
var x = MergeYields<int, string>((a1, a2) => Example(3, a1, a2));
Func<int, IEnumerable<Either<int, string>>> f = n =>
MergeYields<int, string>((a1, a2) => Example(n, a1, a2))
.AsEnumerable();
var tb = new TransformManyBlock<int, Either<int, string>>(f);
ITargetBlock<int> intSink = null;
\documentclass[11pt]{article}
\title{Hello World}
\begin{document}
This is a test $x^2$. A real test
\[
\int_0^1 e^{-t}dt.
\]
\end{document}
import System.Random
rollDice = getStdRandom (randomR (1,6))
main = do roll <- rollDice
print roll
sg <- getStdGen
let rl = randomRs (1,6) sg
print $ take 5 rl
public class Test {
public static void main(String[] args) throws Exception {
System.out.println("Hello world!");
}
}