Skip to content

Instantly share code, notes, and snippets.

View saethlin's full-sized avatar
🦀

Ben Kimock saethlin

🦀
View GitHub Profile
error[E0277]: the trait bound `({float}, ndarray::ArrayBase<ndarray::OwnedRepr<_>, ndarray::Dim<[usize; 1]>>): std::ops::Fn<()>` is not satisfied
--> src/star.rs:76:73
|
76 | let (flux_quiet, integrated_ccf) = limb_integrals.zip(profiles).fold(
| ^^^^ the trait `std::ops::Fn<()>` is not implemented for `({float}, ndarray::ArrayBase<ndarray::OwnedRepr<_>, ndarray::Dim<[usize; 1]>>)`
error[E0277]: the trait bound `({float}, ndarray::ArrayBase<ndarray::OwnedRepr<_>, ndarray::Dim<[usize; 1]>>): std::ops::FnOnce<()>` is not satisfied
--> src/star.rs:76:73
|
76 | let (flux_quiet, integrated_ccf) = limb_integrals.zip(profiles).fold(
function datatype,var, flag0, descriptor=desc, help=hlp, Tname = tname
;+
; NAME:
; DATATYPE()
;
; PURPOSE:
; Returns the data type of a variable.
;
; EXPLANATION:
; This routine returns the data type of a variable in a format specified
@saethlin
saethlin / gist:d6e6d4a202d7d74d16029e00b0594a8b
Created August 6, 2017 22:11
Python stdlib import-all timer (Windows)
Measure-Command {python -c "import string, re, difflib, textwrap, unicodedata, stringprep, rlcompleter, struct, codecs, datetime, calendar, collections, collections.abc, heapq, bisect, array, weakref, types, copy, pprint, reprlib, enum, numbers, math, cmath, decimal, fractions, random, statistics, itertools, functools, operator, pathlib, os.path, fileinput, stat, filecmp, tempfile, glob, fnmatch, linecache, shutil, macpath, pickle, copyreg, shelve, marshal, dbm, sqlite3, zlib, gzip, bz2, zipfile, tarfile, csv, configparser, netrc, xdrlib, plistlib, hashlib, hmac, secrets, os, io, time, argparse, getopt, logging, logging.config, logging.handlers, getpass, platform, errno, ctypes, threading, multiprocessing, concurrent, concurrent.futures, sched, queue, dummy_threading, _thread, _dummy_thread, socket, ssl, select, selectors, asyncio, asyncore, asynchat, signal, mmap, email, json, mailcap, mailbox, mimetypes, base64, binhex, binascii, quopri, uu, html, html.parser, html.entities, xml, xml.etree.ElementTree, xml.
@saethlin
saethlin / main.rs
Created July 22, 2017 18:53
Rust-XCB demo
extern crate xcb; // Make sure you add xcb to your Caro.toml dependencies
fn main() {
// First thing you have to do is get a connection. You can pass an argument
// but if you just leave it as None you'll connect to the display device you're currently on
let (connection, screen_num) = xcb::Connection::connect(None).unwrap();
let setup = connection.get_setup();
let screen = setup.roots().nth(screen_num as usize).unwrap();
@saethlin
saethlin / window.rs
Last active July 11, 2017 04:11
rust xcb Window
pub struct Window {
connection: xcb::base::Connection,
window: xcb::xproto::Window,
foreground: xcb::Drawable,
pub width: u16,
pub height: u16,
}
impl Window {
pub fn new(width: u16, height: u16) -> Self {
@saethlin
saethlin / error.rs
Created May 25, 2017 18:17
rustc pls
error[E0277]: the trait bound `std::ffi::OsString: std::borrow::Borrow<str>` is not satisfied
--> src/echo.rs:12:52
|
12 | if let Some(val) = state.variables.get(key) {
| ^^^ the trait `std::borrow::Borrow<str>` is not implemented for `std::ffi::OsString`
|
= help: the following implementations were found:
<std::ffi::OsString as std::borrow::Borrow<std::ffi::OsStr>>
@saethlin
saethlin / clippy_noooo.rs
Created May 25, 2017 02:12
clippy is kill
╰ ➤ cargo clippy
/home/ben/.cargo/bin/cargo-clippy: symbol lookup error: /home/ben/.cargo/bin/cargo-clippy: undefined symbol: _ZN5rustc4util5ppaux89_$LT$impl$u20$core..fmt..Display$u20$for$u20$rustc..ty..sty..TraitRef$LT$$u27$tcx$GT$$GT$3fmt17h0ad16e3ee81d6918E
╰ ➤ cargo install clippy --force
Updating registry `https://github.com/rust-lang/crates.io-index`
Installing clippy v0.0.134
Compiling dtoa v0.4.1
Compiling lazy_static v0.2.8
Compiling unicode-xid v0.0.4
Compiling itoa v0.3.1
@saethlin
saethlin / CircularBuffer.rs
Created May 24, 2017 22:33
A fixed-size circular buffer for use in implementing shell history
struct CircularBuffer<T> {
buffer: Vec<T>,
head: usize,
tail: usize,
}
impl <T: Default> CircularBuffer<T>{
pub fn new(size: usize) -> Self {
CircularBuffer {
buffer: vec![Default::default(); size],
@saethlin
saethlin / derpy.rs
Created May 24, 2017 04:38
Clippy? Are you okay?
warning: use of `unwrap_or` followed by a function call
--> src/commands/ls.rs:30:33
|
30 | let dir = Path::new(options.value_of_os("directory").unwrap_or(state.directory.as_os_str()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `options.value_of_os("directory").unwrap_or_else(|| state.directory.as_os_str())`
|
= note: #[warn(or_fun_call)] on by default
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call
Point:
x, y, z f64
Particle:
position, velocity, acceleration Point
mass f64
particles = SoA(Particle, 100)
particles.position = random(0.03, 0.03)
particles.mass = 1e-6