Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Burka durka

View GitHub Profile
@durka
durka / halve.rs
Last active Oct 19, 2020 — forked from anonymous/playground.rs
Rust macro that splits a list of expressions in half (at compile time)
View halve.rs
/// 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 Mar 4, 2020 — forked from darwin/index.html
Welcome to comix!
View index.html
<!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 Feb 21, 2018 — forked from anonymous/playground.rs
How to get around lockstep iteration restrictions
View playground.rs
#![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
};
View main.rs
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();
View gist:93da08aca55ba6a618c6ebe7e377b387
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()) } }
};
}
View gist:ef51a30adbf962cf4e2d1c6d0879b92c
macro_rules! group_attr {
(#[cfg($attr:meta)] $($yes:item)*) => {
$(#[cfg($attr)] $yes)*
}
}
View _main.rs
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();
View gist:fe9c7e40a39fe5f79b6186f356ca3545
\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} \\
View gist:d05cbfd28ec58283ba4ecb4519d04db6
\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} \\
View gist:9a26e4438ccc7812a948922f968b3204
\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. \\ \\