Skip to content

Instantly share code, notes, and snippets.

View saschagrunert's full-sized avatar

Sascha Grunert saschagrunert

View GitHub Profile
#[macro_use]
extern crate nom;
#[derive(Debug, PartialEq)]
pub struct MacAddress<'a>(&'a u8, &'a u8, &'a u8, &'a u8, &'a u8, &'a u8);
#[derive(Debug, PartialEq)]
pub enum EtherType {
IPv4,
ARP,
@saschagrunert
saschagrunert / example.c
Last active March 30, 2018 13:09
Either example with structs
#include "include/Func.h"
#include <stdio.h>
struct baz { int value; };
EITHER(struct baz *, baz, char, bax);
int main(void) {
struct baz value = { 3 };
Either(baz, bax) result = Left_baz_bax(&value);
double average(const std::vector<uint32_t> & input) {
return std::accumulate(input.cbegin(),
input.cend(),
0) / (double)input.size();
}
double average(const std::vector<int> & input){
return std::reduce(std::execution::par,
input.cbegin(),
input.cend(),
0) / (double)input.length();
}
#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
// Create a vector
std::vector<uint32_t> v = {1, 2, 3, 4, 5};
// Filter by copying
std::vector<uint32_t> res;
#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
// Create a vector
std::vector<uint32_t> v = {1, 2, 3, 4, 5};
// Filter by erase-remove
v.erase(std::remove_if(v.begin(),
#include <iostream>
#include <vector>
auto average(const std::vector<uint32_t> & input) -> double;
int main(void) {
// Create a vector
std::vector<uint32_t> v = {9, 8, 3};
// Get the average
#include <iostream>
#include <numeric>
#include <vector>
int main(void) {
// Create a vector
std::vector<std::string> v{"foo", "bar"};
// Fold by reference
std::string res = "";
> make frontend
Compiling webapp v0.3.0 (file:///home/sascha/webapp.rs)
Finished release [optimized] target(s) in 11.86s
Garbage collecting "app.wasm"...
Processing "app.wasm"...
Finished processing of "app.wasm"!
If you need to serve any extra files put them in the 'static' directory
in the root of your crate; they will be served alongside your application.
You can also put a 'static' directory in your 'src' directory.
impl Renderable<LoginComponent> for LoginComponent {
fn view(&self) -> Html<Self> {
html! {
<div class="uk-card uk-card-default uk-card-body uk-width-1-3@s uk-position-center",>
<form onsubmit="return false",>
<fieldset class="uk-fieldset",>
<legend class="uk-legend",>{"Authentication"}</legend>
<div class="uk-margin",>
<input class="uk-input",
placeholder="Username",