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 druid::{widget::Controller, Data, Env, Event, EventCtx, Selector, UpdateCtx, Widget}; | |
/// Bypass the `AppDelegate` entirely by appending the return from this function as a | |
/// `Controller` wrapping whatever you wish to perform a desired action when there is a change in the data | |
/// | |
/// # Example | |
/// | |
/// ``` | |
///TextBox::new() | |
/// .lens(AppData::foo) |
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
//! Place a widget anywhere in x,y pixel space | |
use druid::widget::prelude::*; | |
use druid::{Data, Point, WidgetPod}; | |
pub struct Place<T> { | |
children: Vec<ChildWidget<T>>, | |
} |
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
#!/bin/bash | |
############################################################################### | |
# This script is a wrapper over ffmpeg with well-tuned defaults and filters # | |
# to get the best out of your input devices # | |
# # | |
# Screen capture to file will prompt to trim, master and encode audio # | |
# # | |
# TODO: camera source / v4l2 sink still not implemented # | |
# # |
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
#!/bin/bash | |
# Take an input movie file, | |
# blend a thumbnail to the beginning | |
# normalize loudness and fade in audio | |
# fade out at end | |
# encode for youtube/sharing | |
# Generate a test video: | |
# ffmpeg -f lavfi -i testsrc -f lavfi -i aevalsrc="sin(100*t*2*PI*t)" -vf "drawtext=box=1:fontsize=70:text='%{pts\:flt}':x=(w-text_w)/2:y=(h-text_h)/2" -t 10 out.avi |
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
#![allow(dead_code)] | |
//! https://www.kernel.org/doc/html/v4.17/media/uapi/v4l/pixfmt-yuyv.html | |
//! | |
//! V4L2_PIX_FMT_YUYV — Packed format with ½ horizontal chroma resolution, also known as YUV 4:2:2 | |
//! Description | |
//! | |
//! In this format each four bytes is two pixels. Each four bytes is two Y's, a Cb and a Cr. Each Y goes to one of the pixels, and the Cb and Cr belong to both pixels. As you can see, the Cr and Cb components have half the horizontal resolution of the Y component. V4L2_PIX_FMT_YUYV is known in the Windows environment as YUY2. | |
//! | |
//! Example 2.19. V4L2_PIX_FMT_YUYV 4 × 4 pixel image |
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
fn main() { | |
let y = "y̆"; | |
let mut chars = y.chars(); | |
assert_eq!(Some('y'), chars.next()); // not 'y̆' | |
assert_eq!(Some('\u{0306}'), chars.next()); | |
// INTERESTING: chars is unicode compatible, it just gives you code points in between your graphemes | |
for c in y.chars() { | |
println!("{}", c.is_lowercase()); // true, false | |
} |
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
#!/bin/bash | |
SCRIPT_NAME="$(basename "$0")" | |
AUDIO_INTERFACE_NAME="Scarlett Solo USB" # Discover name with command `arecord -l` | |
AUDIO_INTERFACE_DETAILS=$(arecord -l | grep "${AUDIO_INTERFACE_NAME}") | |
AUDIO_CARD=$(echo "${AUDIO_INTERFACE_DETAILS}" | grep -o -E 'card [0-9]+:' | tr -dc '0-9') | |
AUDIO_DEVICE=$(echo "${AUDIO_INTERFACE_DETAILS}" | grep -o -E 'device [0-9]+:' | tr -dc '0-9') | |
AUDIO_BUFFER_SIZE="2048" # The lower the number, the less latency introduced, but more likely buffer overruns |
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
Would it be bad if someone figured out how to manipulate the hash function to get a certain result? | |
Would it be bad if someone found out the input from the hash? |
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
const QUANT: f32 = u16::MAX as f32; | |
struct CPoint(u16); | |
impl From<f32> for CPoint { | |
fn from(f: f32) -> Self { | |
assert!((0.0..=1.0).contains(&f), "given float {f} out of bounds"); | |
CPoint((f * QUANT) as u16) | |
} | |
} | |
impl From<CPoint> for 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::{ | |
sync::mpsc, | |
time::{Duration, Instant}, | |
}; | |
/// Warns on any function that is behaving slow | |
/// | |
/// Useful for when your code appears to be getting stuck somewhere | |
/// and you want a fast "debug print" way of knowing where. | |
#[inline] |