Skip to content

Instantly share code, notes, and snippets.

View ayourtch's full-sized avatar
💭
hacking some Rust

Andrew Yourtchenko ayourtch

💭
hacking some Rust
View GitHub Profile
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
use int_enum::IntEnum;
use std::convert::TryFrom;
use serde::{Deserialize, Serialize};
use serde_json::Result;
use bincode::Options;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, IntEnum)]
enum DT {
@ayourtch
ayourtch / vpp-artifact-versioning.txt
Created July 2, 2020 12:35
VPP artifact versioning
DEB artifact versions, in DEB sort order applied, currently:
19.08.2-release <--- in fdio/release
19.08.2-2~g220e40541~b2500 |
19.08.2-1~g99fa5f722~b2499 | <--- fdio/1908
19.08.1-release <--- in fdio/release
19.08.1-402~g0830008b3~b2497 |
19.08.1-401~g8e4ed521a~b2496 |
...
@ayourtch
ayourtch / version-compare.c
Created June 2, 2020 17:27
A quick hack to show the sorting of the package versions by apt and rpm
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static int order(char c)
{
if (isdigit(c))
return 0;
@ayourtch
ayourtch / test.md
Created May 18, 2020 14:36
FEATURE.yaml changes since 20.05-rc0

Patches that changed FEATURE.yaml definitions

| @c extras/deprecated/netmap/FEATURE.yaml || | 7db6ab03d | misc: deprecate netmap and ixge drivers |

diff --git a/extras/deprecated/netmap/FEATURE.yaml b/extras/deprecated/netmap/FEATURE.yaml
new file mode 100644
index 000000000..e23e5c243
--- /dev/null
+++ b/extras/deprecated/netmap/FEATURE.yaml
@ayourtch
ayourtch / cpp custom codegen v0.01
Created February 28, 2020 11:10
CPP custom codegen
#ifndef INCLUDE_CUSTOM_CODEGEN
#define INCLUDE_CUSTOM_CODEGEN
// #define CAT(a, ...) CCG_PRIMITIVE_CAT(a, __VA_ARGS__)
#define CCG_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
#define EXCEPTION_CHECK_N(x, n, ...) n
#define EXCEPTION_CHECK(...) EXCEPTION_CHECK_N(__VA_ARGS__, USUAL_HANDLING,)
#define DEFAULT_EXCEPTION SPECIAL_PROC(~)
#define SPECIAL_PROC(x) x, EXCEPTION_HANDLING,
/* run this through CPP to see what this is all about */
/* this would be a separate include file but for simplicity we leave it here */
#define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
#define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
#define EXCEPTION_CHECK_N(x, n, ...) n
#define EXCEPTION_CHECK(...) EXCEPTION_CHECK_N(__VA_ARGS__, USUAL_HANDLING,)
#define DEFAULT_EXCEPTION SPECIAL_PROC(~)
extern crate chrono;
extern crate diesel;
use super::flextimestamp::FlexTimestamp;
use super::flexuuid::FlexUuid;
use super::models;
use super::schema;
use diesel::pg::PgConnection;
use diesel::prelude::*;
#!/bin/sh
#
# A little naive probe script for RaspberryPI
# Written by Andrew Yourtchenko (ayourtch@gmail.com)
# public domain
#
#
# Save this file as "/usr/local/bin/run-probe"
# Add "/usr/local/bin/run-probe &" to your /etc/rc.local, before the "exit 0" line
@ayourtch
ayourtch / rustfest-nannou-workshop.rs
Created November 9, 2019 16:53
Nannou workshop at RustFest
use nannou::prelude::*;
fn main() {
nannou::app(model).update(update).view(view).run();
}
struct Model {
a: WindowId,
thing_x: f32,
thing_y: f32,