This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Binary tree with index, copied from https://sachanganesh.com/programming/graph-tree-traversals-in-rust/ | |
pub type Idx = usize; | |
pub struct TreeNode { | |
pub value: usize, | |
pub left: Option<Idx>, | |
pub right: Option<Idx>, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cell::RefCell; | |
use std::rc::Rc; | |
use std::rc::Weak; | |
pub type RefPoint = Rc<RefCell<Point>>; | |
pub type WeakPoint = Weak<RefCell<Point>>; | |
#[derive(Debug)] | |
pub struct Point { | |
x: f32, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cell::RefCell; | |
// `generational_arena` is a special type of arena that allows elements to be recycled, and the | |
// handles allocated from the arena do not hold a borrow on the arena. The handles are later used to | |
// retrieve concrete borrows on the arena temporarily. The check for live-ness is essentially | |
// performed at runtime, rather than being checked by the borrow checker. | |
use generational_arena::{Arena, Index}; | |
// Allocate `ARENA` at global/thread scope. The arena is wrapped in a RefCell so we can get | |
// runtime-checked mutable borrows of the arena. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -xg PATH /opt/local/bin /opt/local/sbin $PATH | |
# >>> conda initialize >>> | |
# !! Contents within this block are managed by 'conda init' !! | |
eval /Users/shinMac/anaconda2/bin/conda "shell.fish" "hook" $argv | source | |
# <<< conda initialize <<< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Cursor move to line begin/end in insert mode | |
inoremap <C-b> <C-o>^ | |
inoremap <C-e> <C-o>$ | |
inoremap <C-h> <Left> | |
inoremap <C-l> <Right> | |
inoremap <C-j> <Down> | |
inoremap <C-k> <Up> | |
" delete without yanking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use ease::*; | |
use ease::{Arrow, EaseType, Tweener}; | |
use nannou::prelude::*; | |
struct Model { | |
tweener: Tweener<Arrow>, | |
} | |
fn model(app: &App) -> Model { | |
app.new_window().size(512, 512).view(view).build().unwrap(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! A suite of common interpolation functions often referred to as "easing" and "tweening" | |
//! functions. This API is provided by the [pennereq crate](https://docs.rs/pennereq). | |
pub use crate::geom::{self, pt2, Point2}; | |
use crate::math::BaseFloat; | |
pub use pennereq::*; | |
type EaseFn<S> = fn(t: S, b: S, c: S, d: S) -> S; | |
#[derive(Debug, Copy, Clone)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::draw::Draw; | |
use std::cell::Cell; | |
use std::cell::RefCell; | |
use std::rc::Rc; | |
pub trait Drawable { | |
fn add_line(&mut self) -> &mut dyn Drawable; | |
fn shift(&mut self, x: f32, y: f32) -> &mut dyn Drawable; | |
} | |
#[derive(Debug, Clone, Copy)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::prelude::*; | |
use std::process::{Command, Stdio}; | |
fn main() { | |
let mut child = Command::new("ffmpeg") | |
// Overwrite file if it already exists | |
.arg("-y") | |
// Interpret the information from stdin as "raw video" ... | |
.arg("-f") | |
.arg("rawvideo") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
struct Point { | |
x: f32, | |
y: f32, | |
} | |
impl Point { | |
fn new() -> Self { | |
Point { x: 30.0, y: 5.0 } | |
// Default::default() // This also works | |
} |
NewerOlder