Skip to content

Instantly share code, notes, and snippets.

@rparrett
rparrett / script.js
Created June 19, 2019 20:13
Userscript for showing GrubHub delivery fees in search results
// ==UserScript==
// @name Show Grubhub Delivery Fees
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Why on earth do I have to do this? I hate you.
// @author You
// @match https://www.grubhub.com/search*
// @grant none
// ==/UserScript==
@rparrett
rparrett / Cargo.toml
Last active September 6, 2022 22:59
Use FileReader to display uploaded text of text files dragged onto the seed-rs 0.6 drop zone example
[package]
name = "drop_zone"
version = "0.1.0"
authors = ["David O'Connor <david.alan.oconnor@gmail.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
[dependencies]
@rparrett
rparrett / main.rs
Last active June 6, 2024 21:33
Bevy 0.13 Typewriter Effect
//! Bevy 0.13 Typewriter Effect
//!
//! License: Apache-2.0 / MIT
use bevy::prelude::*;
const TEXT: &str = "This is some text that runs on for quite a while and occupies multiple lines. \
Let's add even more so we'll wrap onto a third line.";
#[derive(Component)]
@rparrett
rparrett / shapes.rs
Last active October 19, 2022 04:05
2d shapes for bevy 0.8 blog
// License: Apache-2.0 / MIT
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
fn main() {
App::new()
.insert_resource(ClearColor(Color::rgba(0.2, 0.2, 0.2, 1.0)))
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.run();
@rparrett
rparrett / mesh.rs
Last active October 19, 2022 04:04
Load a mesh with bevy_asset_loader 0.12
// License: Apache-2.0 / MIT
use bevy::prelude::*;
use bevy_asset_loader::prelude::*;
fn main() {
App::new()
.add_loading_state(
LoadingState::new(MyStates::AssetLoading)
.continue_to_state(MyStates::Next)
@rparrett
rparrett / line_segment.rs
Last active October 16, 2023 23:48
Bevy 0.11 single 2D line segment mesh
// License: Apache-2.0 / MIT
// Note: this is not a good strategy for performance if you need a lot of these things.
// Consider using rotated sprites which Bevy is heavily optimized for, or its "line gizmos."
use bevy::{
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
sprite::MaterialMesh2dBundle,
};
@rparrett
rparrett / generate-guide-stub.sh
Created October 19, 2022 23:03
Generate Bevy migration guide stub
#!/usr/bin/env zsh
# TODO not sure why this doesn't work in bash
if ! hash markdown-extract &> /dev/null
then
echo "markdown-extract required"
echo "cargo install markdown-extract"
exit 1
fi
@rparrett
rparrett / main.rs
Last active January 18, 2023 23:58
Bevy 0.9 Directional Light Playground
use std::f32::consts::PI;
use bevy::{pbr::NotShadowCaster, prelude::*};
#[derive(Component)]
struct Movable;
#[derive(Component)]
struct Rotation {
x: f32,
y: f32,
@rparrett
rparrett / 2d_material.rs
Created January 24, 2023 16:51
Bevy 0.9 - Changing a 2d material
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
#[derive(Resource)]
struct AlphaMaterialHandle(Handle<ColorMaterial>);
impl FromWorld for AlphaMaterialHandle {
fn from_world(world: &mut World) -> Self {
let mut materials = world.resource_mut::<Assets<ColorMaterial>>();
Self(materials.add(ColorMaterial::from(Color::PURPLE)))
}
}
@rparrett
rparrett / main.rs
Last active January 25, 2023 23:16
Bevy 0.10-dev Directional Light Playground
use bevy::{ecs::world::Ref, pbr::CascadeShadowConfig, prelude::*};
use std::f32::consts::PI;
#[derive(Component)]
struct LightRotation {
x: f32,
y: f32,
}
#[derive(Resource, Clone)]
struct ConfigParams {