Skip to content

Instantly share code, notes, and snippets.

@Ironlenny
Ironlenny / Cargo.toml
Created September 14, 2020 01:39
Weird compiler error
[package]
name = "rupart"
version = "0.1.0"
edition = "2018"
[dependencies]
structopt = "0.2"
failure = ">=0.1.5"
md-5 = ">=0.8"
rayon = ">=1.0.3"
INFO 2020-06-07 00:32:17,099 [application.do_command_line:245]:Running Lutris 0.5.6
INFO 2020-06-07 00:32:17,099 [startup.check_driver:62]:Using X.Org
INFO 2020-06-07 00:32:17,099 [startup.check_driver:64]:Running Mesa driver 20.0.7 on Radeon RX 580 Series (POLARIS10, DRM 3.36.0, 5.6.14-1-default, LLVM 10.0.0) (0x67df)
INFO 2020-06-07 00:32:17,100 [startup.check_driver:77]:GPU: 1002:67DF 148C:2378 using amdgpu drivers
INFO 2020-06-07 00:32:17,116 [startup.check_vulkan:132]:Vulkan is supported
INFO 2020-06-07 00:32:17,117 [dxvk.get_dxvk_versions:22]:Updating DXVK versions
DEBUG 2020-06-07 00:32:17,334 [http.get:65]:GET https://lutris.net/api/runtime
INFO 2020-06-07 00:32:17,334 [lutriswindow.toggle_connection:642]:Connected to lutris.net as Ironlenny
DEBUG 2020-06-07 00:32:17,345 [http.get:65]:GET https://lutris.net/api/games/library/Ironlenny
DEBUG 2020-06-07 00:32:17,362 [store.get_missing_media:212]:Requesting missing icons from API for wargaming-game-center, dreamfall-c
// This is a naive re-implementation of Dr. James S. Plank's gflib:
// http://to web.eecs.utk.edu/~jplank/plank/gflib/
// use ndarray::Array2;
pub use ndarray::Array2;
mod reed_solomon {
static prim_poly_16: i16 = 0210013;
static Modar_w: i16 = 16;
static Modar_nw: i16 = 65536;
@Ironlenny
Ironlenny / backup.sh
Created July 17, 2019 20:42
Backup files to Google Drive
#!/bin/sh
# Author: Jacob Riddle
# Email: useafterfree.consulting@gmail.com
#
# This script will backup a file to Google Drive. Each time this script is
# called it will create a compressed archive of the path, given as an argument,
# in /tmp. Each archive will have an accompanying checksum file for integrety
# verification. It will name the archive according to the following scheme:
#
@Ironlenny
Ironlenny / lib.rs
Created April 29, 2019 07:03
Touble Calling `Arc::new()` In Rayon Thread
// This is an implementation of
// [Parity Volume Set Specification 2.0](
// http://parchive.sourceforge.net/docs/specifications/parity-volume-spec/article-spec.html)
#![allow(dead_code, unused_must_use)]
use crc32fast::Hasher;
use exitfailure::ExitFailure;
use failure::ResultExt;
use itertools::Itertools;
use md5::{Digest, Md5};
@Ironlenny
Ironlenny / code.rs
Last active April 29, 2019 05:38
Creating `Arc`s Inside `rayon` Threads
// First Stage: Create file ids and partial bodies for FileDescription. Send
// file ids, partial bodies and file readers to the correct channels.
fn create_file_id(&self, files: Vec<PathBuf>) -> Result<(), ExitFailure> {
let (tx_main, _) = &self.main; // sender for create_main()
let (tx_input, _) = &self.input; // sender for create_input()
let (tx_fd, _) = &self.file_description; // sender for create_fd()
for file in files {
let tx_main = tx_main.clone();
let tx_input = tx_input.clone();
@Ironlenny
Ironlenny / gist:28d5f086617761fc0891fb74c4475ef6
Last active April 29, 2019 06:52
rayon::spawn/Arc::new() error
error[E0277]: `std::sync::mpsc::Sender<Header<'a, Body<'a>>>` cannot be shared between threads safely
--> src/lib.rs:182:13
|
182 | spawn(move || {
| ^^^^^ `std::sync::mpsc::Sender<Header<'a, Body<'a>>>` cannot be shared between threads safely
|
= help: within `CreatorPipeline<Header<'a, Body<'a>>, std::sync::Arc<[u8; 16]>, (std::sync::Arc<[u8; 16]>, std::path::PathBuf, u64), (std::vec::Vec<u8>, u64, std::vec::Vec<u8>), Block, Body<'a>>`, the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Sender<Header<'a, Body<'a>>>`
= note: required because it appears within the type `(std::sync::mpsc::Sender<Header<'a, Body<'a>>>, std::sync::mpsc::Receiver<Header<'a, Body<'a>>>)`
= note: required because it appears within the type `CreatorPipeline<Header<'a, Body<'a>>, std::sync::Arc<[u8; 16]>, (std::sync::Arc<[u8; 16]>, std::path::PathBuf, u64), (std::vec::Vec<u8>, u64, std::vec::Vec<u8>), Block, Body<'a>>`
= note: required because of the requireme
@Ironlenny
Ironlenny / Cargo.toml
Last active December 20, 2018 18:42
bcachectl
[package]
name = "bcachectl"
version = "0.1.0"
authors = ["Foo <foo@example.com>"]
edition = "2018"
[dependencies]
structopt = "0.2"
failure = ""
exitfailure = ""
@Ironlenny
Ironlenny / nasfs.c
Created December 8, 2016 22:13
C function to read a bson encoded file
static int nas_initalize(const char *path)
{
int error = 0;
bson_reader_t *reader = bson_reader_new_from_file(path, &bson_error);
if (!reader) {
fprintf (stderr, "ERROR: %d.%d: %s\n",
bson_error.domain, bson_error.code, bson_error.message);
}
super_block = bson_reader_read(reader, NULL);
bson_iter_init(&iter, super_block);
@Ironlenny
Ironlenny / test_meta_db.c
Created October 21, 2016 21:45
The test driver
#include <tap.h>
#include "../../nasfs_driver/meta_db.h"
#include <stdbool.h>
#include <lmdb.h>
#include <sys/stat.h>
const char db_file[] = "./meta_db";
MDB_env *env = NULL;
MDB_dbi *dbi = NULL;
int result = 0;