Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Programming something in Rust, probably

Matthew J. Berger matthewjberger

🦀
Programming something in Rust, probably
View GitHub Profile
View playflashgames.md

add ?emulate=flash to the end of a newgrounds url to use ruffle for emulation

@matthewjberger
matthewjberger / configuration.nix
Created Jun 22, 2021
/etc/nixos/configuration.nix minimal configuration for using kde plasma
View configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
View main.rs
fn main() {
let mut array = Array::default();
array.push(3);
array.push(1);
array.push(3);
array.push(2);
array.push(5);
println!("Popped: {:#?}", array.pop_max(9));
}
View api.yaml
swagger: '2.0'
info:
version: '2.0'
title: Recipe Search API
description: Our Recipe Search API allows you to search through millions of web recipes and integrate this information into your mobile or web applications.
schemes:
- https
host: api.edamam.com
basePath: /
tags:
@matthewjberger
matthewjberger / main.rs
Created May 27, 2021
Rust matches macro
View main.rs
/// Returns whether the given expression matches any of the given patterns.
///
/// Like in a `match` expression, the pattern can be optionally followed by `if`
/// and a guard expression that has access to names bound by the pattern.
///
/// # Examples
///
/// ```
/// let foo = 'f';
/// assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));
@matthewjberger
matthewjberger / main.rs
Created May 13, 2021
rodio playing an ogg file
View main.rs
thread::spawn(move || {
use ambisonic::rodio::{source::Source, Decoder, OutputStream, Sink};
use std::fs::File;
use std::io::BufReader;
// Get a output stream handle to the default physical sound device
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
// Load a sound from a file, using a path relative to Cargo.toml
let file = BufReader::new(File::open("assets/music/theme.ogg").unwrap());
// Decode that sound file into a source
@matthewjberger
matthewjberger / main.rs
Created May 13, 2021
using ambisonic audio library on a background thread (works with winit)
View main.rs
// use with ambisonic = "0.4.1"
use std::sync::mpsc::{self, Sender};
use std::thread;
pub struct Audio {
control_channel: Sender<bool>,
}
impl Audio {
@matthewjberger
matthewjberger / main.cpp
Last active May 7, 2021
sometimes you need to set boundaries
View main.cpp
#include <vector>
#include <algorithm>
#include <iostream>
int main() {
std::vector<int> nums = {2, 4, 6, 8, 10};
// prior
auto a = std::lower_bound(nums.rbegin(), nums.rend(), 3, std::greater<int>{});
std::cout << *a << std::endl;
@matthewjberger
matthewjberger / _notes.txt
Last active Apr 28, 2021
Notes on using vulkan to render SDF
View _notes.txt
// struct Vertex {
// pos: [f32; 3],
// uv: [f32; 2],
//}
// AngelCode .fnt format structs and classes
// http://www.angelcode.com/products/bmfont/doc/file_format.html
// struct bmchar {
// x: u32,
// y: u32,
@matthewjberger
matthewjberger / Cargo.toml
Last active Apr 24, 2021
serialization/deserialization of legion ecs as a member of another struct
View Cargo.toml
[dependencies]
legion = "0.4.0"
serde = "1.0.125"
serde_json = "1.0.64"
lazy_static = "1.4.0"