Skip to content

Instantly share code, notes, and snippets.

$outpath = (Join-Path "$env:USERPROFILE" "Downloads" "yt-dlp.exe")
try {
Invoke-WebRequest "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe" -OutFile "$outpath"
echo "update success: $outpath"
} catch {
echo "update fail: $outpath"
}
#include <signal.h>
#include <time.h>
#include <stdio.h>
#include <signal.h>
void sh(int sig)
{
for (double f = 0; f < 10; f += 0.5) {
printf(" f = %g\n", f);
usleep(100000);
#!/bin/bash
f=my-vault.kdbx
a=~/Sync
b=~/Dropbox
rsync -uc $a/$f $b/$f
rsync -uc $b/$f $a/$f
@b4284
b4284 / nc.c
Created January 17, 2021 12:43
#include <ncurses.h>
#include <panel.h>
#include <stdbool.h>
#include <string.h>
#include <locale.h>
#define WIDTH 80
#define HEIGHT 20
#define MAXTAB 10
(import (ice-9 regex)
(ice-9 rdelim))
(define (grep ps . fns)
(define re (make-regexp ps))
(define (grep-int p r)
(let ((l (read-line p)))
(if (not (eof-object? l))
(begin
(if (regexp-match? (regexp-exec r l))
@b4284
b4284 / matrix.scm
Last active January 10, 2019 18:08
(use-modules (srfi srfi-1)
(ice-9 threads)
(ice-9 futures))
(define (matrix-transpose a)
;; ((a1 a2 ... ax) ((a1 b1 c1)
;; (b1 b2 ... bx) => (a2 b2 c2)
;; (c1 c2 ... cx)) (a3 b3 c3))
(let A ((a' a) (b '()))
(if (fold (lambda (a b) (if b b (null? a))) #f a')
@b4284
b4284 / README.md
Last active January 5, 2019 07:25
Simulating corotines with POSIX threads

Simulating coroutines with POSIX threads

  • message.scm -- guile implementation
  • message.c -- c implementation

Run test.sh to run both implementations.

If "Aborted..." shows up means there has been inconsistent results.

(use-modules (ice-9 threads))
(define mtx (make-mutex))
(define cv (make-condition-variable))
(define v 0)
(lock-mutex mtx) ;; Lock first to declare master thread
(define t
(call-with-new-thread
@b4284
b4284 / readbooks.c
Last active January 2, 2019 17:11
Read books in parallel!
#include <stdio.h>
void clean_eof_array(int eof_i, FILE **farr, int size) {
fclose(farr[eof_i]);
farr[eof_i] = NULL;
for (int i = eof_i + 1; i < size && farr[i] != NULL; i++) {
farr[i - 1] = farr[i];
farr[i] = NULL;
}
}
@b4284
b4284 / Makefile
Created December 26, 2018 18:17
A practice of reading words from standard input using NASM
all: readword
readword: readword.o
ld -o $@ $^
readword.o: readword.asm
nasm -felf64 -o $@ $^