This file contains 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 super::Event; | |
use super::{stringify_sendall_errors, Application, NetMessage}; | |
use crate::state::{ApplicationState, TermchatMessageType}; | |
use crate::ui; | |
use crate::util::{termchat_message, Result}; | |
use crossterm::event::{Event as TermEvent, KeyCode, KeyEvent, KeyModifiers}; | |
impl Application { | |
pub fn parse_input(&mut self, input: &str, state: &mut ApplicationState) -> Result<()> { | |
const SEND_COMMAND: &str = "?send"; |
This file contains 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; | |
use std::io::prelude::*; | |
use std::os::unix::io::AsRawFd; | |
use termios::*; | |
const KDSKBMODE: u64 = 0x4B45; | |
fn main() { | |
if let Err(e) = try_main() { | |
eprintln!("Something happened: {}", e); |
This file contains 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 copy_region() -> Result<()> { | |
let region = std::process::Command::new("slurp").output()?; | |
let mut region = String::from_utf8(region.stdout)?; | |
region.pop(); // remove \n | |
std::process::Command::new("grim") | |
.args(&["-g", ®ion]) | |
.arg(std::env::temp_dir().join("select.png")) | |
.spawn()? | |
.wait()?; | |
let mut lt = leptess::LepTess::new(None, "eng").unwrap(); |
This file contains 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
struct UnlimitedPeekable<T, I: Iterator<Item = T>> { | |
iter: I, | |
read: Vec<T>, | |
} | |
impl<T, I: Iterator<Item = T>> UnlimitedPeekable<T, I> { | |
fn peek_n(&mut self, n: usize) -> Option<&T> { | |
// 1- indexed | |
if n <= self.read.len() { | |
self.read.get(n - 1) | |
} else { |
This file contains 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
pub fn read_until_bytes<R: std::io::BufRead + ?Sized>( | |
r: &mut R, | |
delim: &[u8], | |
buffer: &mut Vec<u8>, | |
) -> std::io::Result<usize> { | |
let mut read = 0; | |
let mut count = 0; | |
loop { | |
let (done, used) = { | |
let available = match r.fill_buf() { |
This file contains 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 fon::{stereo::Stereo32, Audio, Sink}; | |
use pasts::{exec, wait}; | |
use wavy::{Microphone, MicrophoneStream, Speakers, SpeakersSink}; | |
const SAMPLE_RATE: f32 = 48_000.; | |
/// An event handled by the event loop. | |
enum Event<'a> { | |
/// Speaker is ready to play more audio. | |
Play(SpeakersSink<'a, Stereo32>), |
This file contains 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
#define _GNU_SOURCE | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/ioctl.h> | |
#include <sys/stat.h> | |
#include <sys/types.h> | |
#include <unistd.h> |
This file contains 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
import puppeteer from "https://deno.land/x/[email protected]/mod.ts"; | |
const cliRepl = Deno.run({ | |
cmd: ["deno", "repl", "--unstable", "--inspect"], | |
}); | |
const browser = await puppeteer.launch({ headless: false }); | |
const page = (await browser.pages())[0]; | |
await page.goto( |
This file contains 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 $ = async (e: string) => { | |
await Deno.run({ | |
cmd: ["sh", "-c", e], | |
}).status(); | |
}; | |
const MAKE = "make"; | |
const PUBLIC_DIR = "public"; | |
const OUT_DIR = "build"; |
This file contains 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 homeDir = () => { | |
switch (Deno.build.os) { | |
case "linux": | |
case "darwin": | |
return Deno.env.get("HOME"); | |
case "windows": | |
return Deno.env.get("USERPROFILE"); | |
} | |
}; | |
const binaryPathFromName = (name: string) => `${homeDir()}/.deno/bin/${name}`; |
OlderNewer