Skip to content

Instantly share code, notes, and snippets.

View ian-p-cooke's full-sized avatar

Ian P. Cooke ian-p-cooke

View GitHub Profile
@ian-p-cooke
ian-p-cooke / float_record_parser.rs
Last active July 4, 2018 17:38
example parser with nom
#[macro_use]
extern crate nom;
use std::str;
use nom::{digit, recognize_float, space, line_ending, IResult};
use nom::types::CompleteStr;
#[derive(Debug)]
struct FloatRecord {
timestamp: u64,
@ian-p-cooke
ian-p-cooke / doubles_and_int.rs
Created July 6, 2018 14:14
example of parsers abstracting over multiple nom input types
#[macro_use]
extern crate nom;
use nom::types::{CompleteByteSlice, CompleteStr};
use nom::{digit, recognize_float, space, IResult};
use std::str;
pub trait NomInput<'a, U: nom::AsChar>:
Clone
+ nom::Slice<std::ops::Range<usize>>
@ian-p-cooke
ian-p-cooke / add_wsl_exclusions.ps1
Last active June 30, 2024 05:27
powershell script to add WSL exclusions
$win_user = "ipc"
$linux_user = "ipc"
$package = "CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc"
$base_path = "C:\Users\" + $win_user + "\AppData\Local\Packages\" + $package + "\LocalState\rootfs"
$dirs = @("\bin", "\sbin", "\usr\bin", "\usr\sbin", "\home\" + $linux_user + "\.cargo\bin")
$dirs | ForEach { Add-MpPreference -ExclusionProcess ($base_path + $_ + "\*") }
Add-MpPreference -ExclusionPath $base_path
@ian-p-cooke
ian-p-cooke / rustc.log
Created August 5, 2018 15:44
rustc loading codegen error
c:\msys64\home\ipc\rust>rustup toolchain link latest-stage2 build\x86_64-pc-windows-gnu\stage2
c:\msys64\home\ipc\rust>rustup default latest-stage2
info: default toolchain set to 'latest-stage2'
c:\msys64\home\ipc\rust>rustup which rustc
C:\Users\ipc\.rustup\toolchains\latest-stage2\bin\rustc.exe
c:\msys64\home\ipc\rust>rustc -vV
rustc 1.29.0-dev
#[derive(Message)]
struct Batch {
key: String,
messages: Vec<String>
}
struct RedisListTailer {
redis: Addr<Redis>,
key: String,
current_index: isize,
@ian-p-cooke
ian-p-cooke / slog_envlogger_actix_web_test.rs
Last active September 6, 2018 11:40
enabling crate level logging not working for actix-web
extern crate actix_web;
extern crate slog_envlogger;
use actix_web::actix;
use actix_web::fs::NamedFile;
use actix_web::middleware;
use actix_web::HttpRequest;
use actix_web::Result;
use actix_web::{server, App};
extern crate sxd_document;
extern crate sxd_xpath;
use std::error::Error;
use sxd_document::parser;
use sxd_xpath::evaluate_xpath;
use sxd_xpath::Value;
use sxd_document::dom::Document;
pub struct XmlFixDictionary<'a> {
struct GracefulTlsStream {
inner: Arc<Mutex<TlsStream<TcpStream, ClientSession>>>,
}
impl Write for GracefulTlsStream {
fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
let mut guard = self.inner.lock().unwrap();
guard.write(buf)
}
#![deny(warnings, rust_2018_idioms)]
use futures::Future;
use hyper::client::connect::{Destination, HttpConnector};
use tower_grpc::Request;
use tower_hyper::{client, util};
use tower_util::MakeService;
use std::error::Error;
/// The request message containing the user's name.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HelloRequest {
#[prost(string, tag="1")]
pub name: std::string::String,
}
/// The response message containing the greetings
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HelloReply {
#[prost(string, tag="1")]