Skip to content

Instantly share code, notes, and snippets.


Jonas Platte jplatte

View GitHub Profile
jplatte /
Created Oct 22, 2020
Rust ICE could not fully normalize
use my_crate::{Const, Trait};
fn main() {
let _ = Const::<1>::assoc_fn();
use actix_service::{Service, Transform};
use futures_util::future::{self, FutureExt as _, LocalBoxFuture};
use std::{cell::RefCell, future::Future, rc::Rc};
#[derive(Clone, Debug)]
pub struct Preprocess<F>(pub F);
pub struct PreprocessService<S, F> {
service: Rc<RefCell<S>>,
f: F,
use actix_web::{dev::Payload, FromRequest, HttpRequest, HttpResponse};
use futures_util::future;
use std::ops::{Deref, DerefMut};
#[derive(Clone, Debug)]
pub struct ReqData<T: Clone + 'static>(pub T);
impl<T: Clone + 'static> Deref for ReqData<T> {
type Target = T;
jplatte /
Last active Oct 11, 2019
ruma-events notes



  • There is a hierarchy of event traits: Event > RoomEvent > StateEvent
  • There is a Rust type for each kind of event (each allowed value for the 'type' field of the json representation), including custom [room / state] events
  • There is also a content type for each event type
  • In addition, there are "special" event types:
    • the Event, RoomEvent and StateEvent enums from collections::all contain every event type
View gist:21e45bf90b77dd8a35084bafec167f79
swaymsg -t get_tree | jq -r '.nodes[] | select([recurse(.nodes[]?, .floating_nodes[]?) | .focused] | any) | .name'
View anvil-fmt.diff
diff --git a/anvil/src/ b/anvil/src/
index 1d91554..e4a63fa 100644
--- a/anvil/src/
+++ b/anvil/src/
@@ -131,12 +131,14 @@ impl<B: InputBackend> InputHandler<B> for AnvilInputHandler {, Ordering::SeqCst);
#[cfg(feature = "tty_lauch")]
- KeyAction::VtSwitch(vt) => if let Some(ref mut session) = self.session {
- info!(log, "Trying to switch to vt {}", vt);

Keybase proof

I hereby claim:

  • I am jplatte on github.
  • I am jplatte ( on keybase.
  • I have a public key ASCw2BYUeQV-zliaUjaXzxRVVInsM9e0JG8EhDTe6XYd1Qo

To claim this, I am signing this object:

View algebra-cxx14_example.cpp
#include <algebra_cxx14.hpp>
#include <cmath>
#include <iostream>
using namespace std;
using namespace algebra_cxx14::exports;
#define TAG(_name_) struct _name_ { static constexpr const char* name = #_name_; }
jplatte / guard.hpp
Last active Jul 21, 2016
Guards for Boost Hana
View guard.hpp
#include <boost/hana.hpp>
#include <type_traits>
namespace hana = boost::hana;
template <typename Cond, typename Then>
constexpr auto guard(Cond&& cond, Then&& then)
return hana::eval_if(std::forward<Cond>(cond),
jplatte / enum_str.hpp
Last active Feb 25, 2020
Enum to string and string to enum conversion, DRY-style
View enum_str.hpp
#ifndef _ENUM_STR_HPP_
#define _ENUM_STR_HPP_
#include <initializer_list>
#include <map>
#include <stdexcept>
#include <string>
#include <type_traits>
namespace _enum_str