Skip to content

Instantly share code, notes, and snippets.

View durka's full-sized avatar

Alex Burka durka

View GitHub Profile
@durka
durka / halve.rs
Last active October 19, 2020 23:15 — forked from anonymous/playground.rs
Rust macro that splits a list of expressions in half (at compile time)
/// strategy:
/// - first copy the list of exprs -- the copy will just be used as a counter
/// - then, starting with all the exprs in a "left" list and an empty "right" list:
/// - move one expr at a time from "left" to "right", and decrement the counter _twice_
/// - when the counter is zero, the halving is complete
/// - if there were an odd number of exprs, a compile error tells you about it
/// the macro is in continuation passing style, so you pass in a macro invocation and it will be called
/// twice, first with the "left" and then with the "right" (enclosed in square brackets) inserted as the last argument
macro_rules! halve {
// internal rules
@durka
durka / index.html
Created March 4, 2020 04:15 — forked from darwin/index.html
Welcome to comix!
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:1200px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<drawing t="translate(0,31)">
@durka
durka / playground.rs
Created February 21, 2018 23:39 — forked from anonymous/playground.rs
How to get around lockstep iteration restrictions
#![feature(trace_macros)] trace_macros!(true);
macro_rules! doc_items {
(@distribute $docs:tt $($item:item)*) => {
$(doc_items!(@output $docs $item);)*
};
(@output [$($doc:expr),*] $item:item) => {
$(#[doc=$doc])*
$item
};
@durka
durka / main.rs
Last active January 28, 2019 02:14
static BUTTON: AtomicBool = AtomicBool::new(false);
#[entry]
fn main() {
let mut cp = cortex_m::Peripherals::take().unwrap();
let dp = stm32f30x::Peripherals::take().unwrap();
let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
fn toggle_between_A_and_B_while_keeping_value(&mut self) {
*self = match self {
E::A { value } => { E::B { value: mem::replace(value, S::dummy()) } }
E::B { value } => { E::A { value: mem::replace(value, S::dummy()) } }
};
}
macro_rules! group_attr {
(#[cfg($attr:meta)] $($yes:item)*) => {
$(#[cfg($attr)] $yes)*
}
}
@durka
durka / _main.rs
Last active September 4, 2018 05:24
fn main() -> ! {
let (mut delay, mut leds): (Delay, Leds) = aux5::init();
loop {
foreach!($
state => [on off]
period => [500 100]
{
for led in 0..8 {
leds[led].$state();
\section{References}
\vspace{-1.4em}
\setlength{\tabcolsep}{.075in}
\renewcommand{\arraystretch}{3}
\begin{tabular}{@{}l b{3.1in}}
\makecell[l]{
Dr.\ Katherine J. Kuchenbecker \\
Max Planck Institute for Intelligent Systems \\
\plus 49 711 689-3510 \\
\url{kjk@is.mpg.de} \\
\setlength{\tabcolsep}{.05in}
\renewcommand{\arraystretch}{3}
\begin{tabular}{@{}l b{3.1in}}
\makecell[l]{
Dr.\@ Katherine J. Kuchenbecker \\
Max Planck Institute for Intelligent Systems \\
+49 711 689-3510 \\
\url{kjk@is.mpg.de} \\
\url{https://hi.is.mpg.de/person/kjk}
} & {\raggedright Dr.\@ Kuchenbecker was my academic advisor at the University of Pennsylvania from 2013-2018 and now directs the Haptic Intelligence Department at MPI-IS.\par} \\
\raggedright
\begin{tabular}{l m{3.25in}}
\makecell[l]{
Dr. Katherine J. Kuchenbecker \\
Max Planck Institute for Intelligent Systems \\
+49 711 689-3510 \\
\url{kjk@is.mpg.de} \\
\url{https://hi.is.mpg.de/person/kjk}
} &
Dr. Kuchenbecker was my academic advisor at the University of Pennsylvania from 2013-2018 and now directs the Haptic Intelligence Department at MPI-IS. \\ \\