Skip to content

Instantly share code, notes, and snippets.

View saethlin's full-sized avatar
🦀

Ben Kimock saethlin

🦀
View GitHub Profile
@saethlin
saethlin / unused_imports.rs
Created October 12, 2017 20:46
rustc unused imports bug
#[macro_use]
extern crate derive_more;
use std::ops::{Add, Sub, Div, Mul};
#[derive(Debug, Clone, Copy, Add, Mul)]
pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
@saethlin
saethlin / window.rs
Created October 16, 2017 20:26
This kills the rustfmt
use std::fmt::Debug;
use widget::Widget;
use xcb;
pub struct Window {
connection: xcb::Connection,
id: u32,
widgets: Vec<Box<Widget>>,
}
@saethlin
saethlin / all_cargo.txt
Last active October 18, 2017 18:43
stats on Rust build configs
╰ ➤ find | grep Cargo.toml | xargs wc -l | sort -n
4 ./src/tools/tidy/Cargo.toml
6 ./src/tools/remote-test-client/Cargo.toml
6 ./src/tools/remote-test-server/Cargo.toml
8 ./src/tools/cargotest/Cargo.toml
8 ./src/tools/linkchecker/Cargo.toml
9 ./src/libarena/Cargo.toml
9 ./src/libfmt_macros/Cargo.toml
9 ./src/libgraphviz/Cargo.toml
9 ./src/librustc_platform_intrinsics/Cargo.toml
import numpy as np
from scipy.misc import imsave
max_y = 0
max_x = 0
with open('Stego_3.txt') as f:
contents = f.readlines()
coordinates = []
@saethlin
saethlin / termbox_bug.rs
Last active December 6, 2017 00:09
termbox bug?
//! ```cargo
//! [dependencies]
//! termbox_simple = "0.2.0"
//! ```
extern crate termbox_simple;
use termbox_simple::Termbox;
use std::sync::{Arc, Mutex};
use std::thread;
@saethlin
saethlin / uhhhhhhh.rs
Created December 7, 2017 02:04
What trait bounds? These trait bounds
error[E0599]: no method named `for_each` found for type `std::boxed::Box<websocket::<unnamed>::Future<Error=websocket::WebSocketError, Item=(websocket::client::async::Framed<websocket::client::async::TlsStream<tokio_core::net::TcpStream>, websocket::async::MessageCodec<websocket::OwnedMessage>>, websocket::header::Headers)> + 'static>` in the current scope
--> src/main.rs:31:10
|
31 | .for_each(|_| println!("test"));
| ^^^^^^^^
|
= note: the method `for_each` exists but the following trait bounds were not satisfied:
`std::boxed::Box<websocket::<unnamed>::Future<Error=websocket::WebSocketError, Item=(websocket::client::async::Framed<websocket::client::async::TlsStream<tokio_core::net::TcpStream>, websocket::async::MessageCodec<websocket::OwnedMessage>>, websocket::header::Headers)>> : websocket::<unnamed>::Stream`
`std::boxed::Box<websocket::<unnamed>::Future<Error=websocket::WebSocketError, Item=(websocket::client::async::Framed<websocket::client::async::Tl
Total time: 16.4064 s
File: neufeld_plots.py
Function: main at line 1
Line # Hits Time Per Hit % Time Line Contents
==============================================================
1 @profile
2 def main():
3 1 168872.0 168872.0 1.0 import numpy as np
4 1 108349.0 108349.0 0.7 import matplotlib
@saethlin
saethlin / rip-openssl.txt
Created January 23, 2018 05:07
openssl build failure
error: failed to run custom build command for `openssl v0.7.14`
process didn't exit successfully: `/home/ben/discord-rs/target/debug/build/openssl-52416aa69a800e6e/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-unknown-linux-gnu")
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
TARGET = Some("x86_64-unknown-linux-gnu")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
@saethlin
saethlin / tokio_struggles.rs
Created January 30, 2018 20:27
rustfmtpls
let runner = ClientBuilder::new(&url)
.unwrap()
.add_protocol("rust-websocket")
.async_connect_secure(None, &core.handle())
.and_then(|(duplex, _)| {
let (sink, stream) = duplex.split();
stream.filter_map(|message| {
match message {
OwnedMessage::Text(t) => {
if let Ok(Standard(slackmessage)) = serde_json::from_str::<slack_api::Message>(&t) {
@saethlin
saethlin / logs.txt
Created February 16, 2018 07:59
tinaun/discord-rs basic_chatbot logs
DEBUG 2018-02-16T07:58:37Z: discord::async: connected to discord w/ heartbeat 41250ms.
DEBUG 2018-02-16T07:58:37Z: discord::async: send: Object({"d": Object({"compress": Bool(true), "large_threshold": Number(250), "properties": Object({"$browser": String("Discord library for Rust"), "$device": String("discord-rs"), "$os": String("linux"), "$referrer": String(""), "$referring_domain": String("")}), "token": String("Bot MTc2MTM1Njg4NjY2NzQyNzg0.DTQ_hg.HRKyVQHLOLtEKwexb0j_tmoroso"), "v": Number(6)}), "op": Number(2)})
DEBUG 2018-02-16T07:58:38Z: discord::model: Unhandled keys: Game has Object({"timestamps": Object({"start": Number(1518755284048)})})
DEBUG 2018-02-16T07:58:38Z: discord::model: Unhandled keys: Game has Object({"assets": Object({"large_image": String("spotify:702ea459eef6df07fec7756a0a38b2452e9c9d4d"), "large_text": String("Reflection (Deluxe)")}), "details": String("Everlasting Love"), "flags": Number(48), "party": Object({"id": String("spotify:83888634339528704")}), "session_id": String("ed449fa5