Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonas Platte jplatte

View GitHub Profile
@jplatte
jplatte / examples_breakit.rs
Created Oct 22, 2020
Rust ICE could not fully normalize
View examples_breakit.rs
use my_crate::{Const, Trait};
fn main() {
let _ = Const::<1>::assoc_fn();
}
View preprocess.rs
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,
View request_data.rs
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
jplatte / ruma-events.md
Last active Oct 11, 2019
ruma-events notes
View ruma-events.md

ruma-events

Overview

  • 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/input_handler.rs b/anvil/src/input_handler.rs
index 1d91554..e4a63fa 100644
--- a/anvil/src/input_handler.rs
+++ b/anvil/src/input_handler.rs
@@ -131,12 +131,14 @@ impl<B: InputBackend> InputHandler<B> for AnvilInputHandler {
self.running.store(false, 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);
View keybase.md

Keybase proof

I hereby claim:

  • I am jplatte on github.
  • I am jplatte (https://keybase.io/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_; }
TAG(X);
@jplatte
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),
std::forward<Then>(then),
@jplatte
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