Skip to content

Instantly share code, notes, and snippets.

View ttys3's full-sized avatar
💭
sad, ttyS0 has been taken by other user

ttys3

💭
sad, ttyS0 has been taken by other user
View GitHub Profile
@yongkyuns
yongkyuns / ffmpeg_example.rs
Created July 7, 2020 23:38
FFMPEG usage in rust using command and raw pixels
use std::io::prelude::*;
use std::process::{Command, Stdio};
fn main() {
let mut child = Command::new("ffmpeg")
// Overwrite file if it already exists
.arg("-y")
// Interpret the information from stdin as "raw video" ...
.arg("-f")
.arg("rawvideo")
// 👍 ✔ originally posted on:
// https://dirask.com/posts/10Wwaj
// we can run this code online under above link ☘
//
<!doctype html>
<html>
<body>
<div>
<img id="image" style="border: 1px solid silver; width: 320px; height: 240px" />
@romainl
romainl / Don't use Vim.md
Last active May 14, 2024 14:09
Don't use Vim for the wrong reasons

Don't use Vim

Don't do the crime, if you can't do the time.

-- Anthony Vincenzo "Tony" Baretta

Vim is an amazing text editor. I love it. Really, I wouldn't [organize][organize] a Vim advent calendar if I didn't. But, as amazing as it is, Vim is not for everyone. It can't solve all your problems, or be a TUI version of your favorite IDE, or make you a better programmer, or land you that dream job in the Bay Area. But Vim can help you be more mindful, focused, and efficient, as long as you approach it with the right mindset.

Don't get me wrong, I certainly welcome you to try Vim, but I'm not a proselyte. I don't thrive on newbies. I just want you to use the right tool for the job and not waste your—and anyone's—time on a fruitless quest.

@nstarke
nstarke / 0000-cve-2020-8597.md
Last active November 1, 2023 04:48
CVE-2020-8597 - Buffer Overflow in pppd

CVE-2020-8597 - Buffer Overflow in pppd

In this short tutorial we will go over how to reproduce the crash from CVE-2020-8597. This is a stack-based buffer overflow in the pppd binary.

We will use our own pppd binary compiled from source, using the latest version: 2.4.8.

To accomplish this goal, we will need two Virtual Machines connected by a virtual serial port. I typically use VirtualBox since it is open source, but the same sort of configuration should work on other hypervisors.

I spun up two VMs:

@stilllisisi
stilllisisi / aggregator.go
Last active July 5, 2023 06:08
【Go-多线程】Golang的channel实现消息的批量处理。当消息量特别大时,使用kafka之类的message queue是首选,但我们想用更加轻量的方案。
//这个方案需要实现以下几点:
//1.消息聚合后处理(最大条数为BatchSize),核心:
//(1)带buffer的channel相当于一个FIFO的队列
//(2)多个常驻的goroutine来提高并发
//(3)goroutine之间是并行的,但每个goroutine内是串行的,所以对batch操作是不用加锁的。
//2.延迟处理(延迟时间为LingerTime)
// 注意:为什么使用time.Timer而不是time.After,是因为time.After在for select中使用时,会发生内存泄露。
//3.自定义错误处理
//4.并发处理
@algal
algal / colorize-emacs.bashsource
Last active August 4, 2023 17:46
Setting up truecolor (24 bit color) in emacs in the terminal, under iTerm2, blink.sh, and others.
# sourcing this file will define a bash functions that
# tries to run subsequent calls to emacs with 24 bit color.
#
# It sets TERM=xterm-emacs-leg if
# - we've created a user-local terminfo record for xterm-emacs-leg, and
# - we're using iTerm2 or something has set COLORTERM=truecolor
#
# This will cause emacs to use 24 bit color only when it will work,
# inside or outside of tmux. I haven't found a way to auto-detect Blink.sh yet.
#
@imcsk8
imcsk8 / gist:78efd778b36bc6f3a29a872655643c79
Created January 30, 2020 22:02
CentOS 8 aarch64 rootfs creation
$ mkdir repos
$ cat <<EOF>> repos/centos.repo
[main]
arch=aarch64
basearch=aarch64
[centos8-base]
name=CentOS-8-Base
baseurl=http://mirror.centos.org/centos/8/BaseOS/aarch64/os/
gpgcheck=0
@ctrlcctrlv
ctrlcctrlv / rust-maintainer-perfectionism.md
Last active January 4, 2024 15:42
Rust maintainer perfectionism

Rust maintainer perfectionism, or, the tragedy of Alacritty

I did not submit this to Hacker News and did not intend that this post would have high circulation but have no real problem with it being there or with it having such. I have more recent comments below. This post is from January 2020 and predates the Modular Font Editor K (MFEK) project.

I have not worked on Rust projects in quite a while, and don't know if I ever will again. I feel many crate maintainers are way too perfectionist, for example, despite all the developer hours that went into this PR, it took the effort within years to be (halfway) merged.

There's always a reason not to merge, isn't there? It would be better done with a new nightly language feature, or the function signature should have a where clause, or the documentation is not perfect. There's always a new nit to pick in the world of Ru

@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@lilydjwg
lilydjwg / gh-check
Last active March 18, 2024 04:43
gh-check: speed test to known GitHub IPs
#!/usr/bin/python3
import asyncio
import time
import socket
import argparse
import aiohttp
class MyConnector(aiohttp.TCPConnector):