Skip to content

Instantly share code, notes, and snippets.

View dyniec's full-sized avatar
:octocat:
I boop computers

Paweł Dybiec dyniec

:octocat:
I boop computers
View GitHub Profile
@dyniec
dyniec / reboot.go
Created November 24, 2020 17:31
Small service to do remote or timed restart
// Remote/delayed reboot
// Problem: I have machine which randomly has a problem with spawning new processes.
// It makes debugging this issue hard as I cannot ssh into the machine, and I have to ping
// somebody in the server room to reboot the machine
// Thankfully it seems that system and processes are still running as the machine is opening
// TCP or even TLS connections.
// Crude solution: Service that uses sysrq file to reboot the machine, exposed via http (over some vpn)
// Additionaly it has delayed reboot functionality so it could reboot the machine even if network is broken
// It could use some TLS cert authentication, but meh.
@dyniec
dyniec / corpus_frequency.js
Created November 14, 2020 15:48
Corpus bookmarklet
javascript:(function(){t = document.getElementById('contents');s=Array.from(t.getElementsByTagName('tr')).slice(1,-1).map(x=> x.firstElementChild.innerText).join(", ");alert(s);})();
use std::{io,time};
use argparse::{ArgumentParser, Store};
fn main() {
let mut delay = 1000;
{
let mut parser = ArgumentParser::new();
parser.refer(&mut delay).add_option(&["-t", "--time"],Store, "Delay per line in miliseconds");
parser.parse_args_or_exit();
}
@dyniec
dyniec / a.cpp
Last active April 19, 2018 07:13
Example of lazy pipes in linux ./a |./b
#include<cstdio>
int main()
{
int cnt=0;
while(true)
{
printf("%c",cnt&255);
fflush(stdout);
fprintf(stderr,"%d bytes\n",cnt);
cnt++;