Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Hacking

Pedro Ferreira pferreir

💭
Hacking
View GitHub Profile
View usb.rs
use core::cell::RefCell;
use cortex_m::interrupt::{free, Mutex};
use heapless::{consts::*, String};
use stm32f4xx_hal::otg_fs::{UsbBus, USB};
use usb_device::{class_prelude::UsbBusAllocator, prelude::*};
use usbd_serial::SerialPort;
type UsbSerial<'u> = SerialPort<'u, UsbBus<USB>>;
type UsbBusDevice<'u> = UsbDevice<'u, UsbBus<USB>>;
@pferreir
pferreir / countdown_itlt.lua
Last active Dec 3, 2020
OBS Studio countdown with red BG
View countdown_itlt.lua
obs = obslua
text_source_name = ""
img_source_name = ""
total_seconds = 0
cur_seconds = 0
last_text = ""
stop_text = ""
activated = false
View pass.rs
use amethyst::renderer::{
mtl::{TexAlbedo, TexEmission},
pass::Base3DPassDef,
plugins::RenderBase3D,
rendy::{
hal::pso::ShaderStageFlags,
mesh::{AsVertex, Normal, Position, TexCoord, VertexFormat},
shader::SpirvShader
},
skinning::JointCombined
View main.rs
use amethyst::{
assets::{AssetLoaderSystemData, ProgressCounter},
core::{Transform, TransformBundle},
ecs::System,
prelude::*,
renderer::{
bundle::RenderingBundle,
debug_drawing::DebugLines,
light::{Light, PointLight},
palette::{LinSrgba, Srgb},
View main.rs
use amethyst::{
assets::{AssetLoaderSystemData, ProgressCounter},
core::{Transform, TransformBundle},
ecs::System,
prelude::*,
renderer::{
bundle::RenderingBundle,
debug_drawing::DebugLines,
light::{Light, PointLight},
palette::{LinSrgba, Srgb},
View -
diff --git a/src/core/simulation/simulation.rs b/src/core/simulation/simulation.rs
index 414411e..3384367 100644
--- a/src/core/simulation/simulation.rs
+++ b/src/core/simulation/simulation.rs
@@ -63,7 +63,7 @@ impl<'a> Simulation<'a> {
}
}
InputChange::Money(amount) => {
- *state.resources.get_mut(&Resource::Money).unwrap() += amount;
+ state.subtract_resources(&vec![(Resource::Money, *amount)]);
View main.rs
use async_std::{
stream::StreamExt,
sync::{channel, Sender, Receiver}
};
use futures::join;
async fn producer_1(sender: Sender<String>) {
let mut i = 0;
loop {
let s = format!("PROD1 {}", i);
View openpgp.md
View testsvc.py
# run it like this:
# FLASK_ENV=development FLASK_DEBUG=1 FLASK_APP=testsvc.py flask run -p 12345
from functools import wraps
import requests
from flask import Flask, jsonify, request
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.exc import IntegrityError
from webargs import fields