Skip to content

Instantly share code, notes, and snippets.

[{"rowId":0,"title":"Tales From the Loop","comments":"","watchDates":["01/01/2020","06/21/2023"],"type":1,"rating":"7","id":"f0d8fdc6-295f-4960-b728-2777f6651aa4","updatedAt":1687338657590,"createdAt":1687338657590},{"rowId":1,"title":"The Man Who Shot Liberty Valance","comments":"","watchDates":["01/01/2022"],"type":0,"rating":"8","id":"14bc7fca-9cd4-491b-af24-8c64e1f414e0","updatedAt":1687338657591,"createdAt":1687338657591},{"rowId":2,"title":"Sinbad (Series)","comments":"I absolutely love this show. The production isn't great; the writing is at times all over the place. It's one of those Xena/Hercules-tier serials that should have endured for years and hundreds of episodes, but aired in 2012 when tv show renewals weren't passed out as liberally as they had a decade prior.\n\nIt's unfortunate, because this is for me a \"comfort show\" of sorts. I love Elliot Knight as Sinbad, and I'm incredibly disappointed he has such a small repertoire beyond the show. I'll certainly re-watch though, and ordered the DVD
@exbotanical
exbotanical / no-gpt.js
Created April 12, 2023 17:19
Remove ChatGPT Posts from HackerNews
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://news.ycombinator.com/*?\?
// @icon https://www.google.com/s2/favicons?sz=64&domain=ycombinator.com
// @grant none
// ==/UserScript==
@exbotanical
exbotanical / threads_1.c
Created February 3, 2023 05:04
threading code listing from multi-threading series on YT
#include <pthread.h> // for POSIX threads
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // for pause and sleep
void *thread_routine(void *arg) {
char *thread_id = (char *)arg;
while (1) {
printf("%s\n", thread_id);
@exbotanical
exbotanical / fsm.c
Last active January 22, 2023 07:25
A simple finite state machine manager written in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct transition_t {
char* name;
char* target;
void (*action)(void);
} Transition;
@exbotanical
exbotanical / chat_server.c
Last active January 1, 2023 01:21
A chat server written in c with support for subscribable topics
#include <arpa/inet.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <time.h>
@exbotanical
exbotanical / semaphore.c
Last active January 1, 2023 01:22
personal implementation of semaphores for the C programming language
#include <stdlib.h>
#include <pthread.h>
#include <stdbool.h>
// canonical macro aliases from `semaphore.h`
#define P(sem) sem_wait(sem)
#define V(sem) sem_post(sem)
#define UP(sem) sem_wait(sem)
#define DOWN(sem) sem_post(sem)
@exbotanical
exbotanical / thread_barrier.c
Created July 16, 2021 15:10
simple implementation of POSIX thread barriers
#include <pthread.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct barrier {
uint32_t threshold;
uint32_t curr_wait; /* from 0 -> threshold - 1*/
pthread_cond_t cv;
pthread_mutex_t mutex; /* perform mutually exclusive ops on a thread barrier */
bool is_ready; /* is barrier disposition in progress? */
@exbotanical
exbotanical / compile.sh
Last active July 16, 2021 06:26
The Dining Philosopher
#!/usr/bin/env bash
gcc dining_philosopher.c -o main -lpthread
./main
@exbotanical
exbotanical / transfer_of_computation.c
Last active July 11, 2021 20:27
demonstration of 'transfer of computation' (POSIX threads)
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#include <errno.h>
// this code snippet demonstrates the 'transfer of computation' methodology,
// whereby two threads do not transfer data but a computation that acts upon
// this observed data
@exbotanical
exbotanical / win10_dupe_fname.js
Created July 2, 2021 23:00
An implementation of the Windows 10 "duplicate filename" algorithm
// the following is an exact implementation of the algorithm Windows 10 uses when
// duplicating filenames
// dummy data
const allFiles = [
'test',
'test - Copy (2)',
'test - Copy',
'name',
'othername'