Skip to content

Instantly share code, notes, and snippets.

View drio's full-sized avatar
I don't know

David Rio Deiros drio

I don't know
View GitHub Profile
drio /
Last active January 6, 2024 15:00
producer consumer in go explained

Producer consumer pattern

Question: Can you write code implementing the consumer and producer pattern?

This is a classic concurrency problem where we have threads generating data to be consumed (producers) by other threads (consumers).

The implementation with POSIX threads can be a pain in the ass but it is quite straight forward in golang thanks to its concurrency constructs.

drio / aoc-2023-day1.js
Last active December 6, 2023 15:49
Advent of code - day 1 2023
import { pretty, linesFromStdin } from '../common.js';
const listNums = "zero, one, two, three, four, five, six, seven, eight, nine".split(",").map(e => e.trim())
function findMatches(line, str) {
const re = new RegExp(str, "g");
const matches = [...line.matchAll(re)]
return{ index }) => ({ s: index }))
"fields": {
"aaa_override_passphrase": "false",
"ap_name": "M131-stairb-4w-ap0",
"co_state": "client-status-run",
"guest_lan_client_info/idle_time_seconds": 0,
"guest_lan_client_info/phy_ifid": 0,
"guest_lan_client_info/wired_vlan": 0,
"idle_timeout": 0,
"idle_timestamp": 0,
<?xml version="1.0" encoding="UTF-8"?>
xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" Destination="" ID="_8e1833f5b65e46fd106f71c07611ae21" InResponseTo="id-870aba870f8c1097a5d42321e84297166b13f7c5" IssueInstant="2023-02-28T17:53:42.887Z" Version="2.0">
<ds:CanonicalizationMethod Algorithm=""/>
drio /
Last active January 20, 2023 17:28

Gist away!

package main
import (
drio /
Created November 21, 2022 14:53

Gist away!

ResponseId RESPONSE_ID ResponseId
Q2DocumentLink Q2_DOCUMENT_LINK Q2_Id
Q2DocumentName Q2_DOCUMENT_NAME Q2_Name
Q14DocumentLink Q14_DOCUMENT_LINK Q14_Id
Q14DocumentName Q14_DOCUMENT_NAME Q14_Name
Q15DocumentLink Q15_DOCUMENT_LINK Q15_Id
Q15DocumentName Q15_DOCUMENT_NAME Q15_Name
Q18Affiliation Q18_AFFILIATION Q18_3
Q18DisplayEmail Q18_DISPLAY_EMAIL Q18_2
Q18DisplayName Q18_DISPLAY_NAME Q18_1
drio /
Last active November 17, 2022 21:33

Demo for gocsv (ticket #159)

> cat demo.csv

> go run ./main.go --csvFile=demo.csv
drio /
Last active October 11, 2022 08:27

Unix batteries

Loads a few crucial tools in your new Unix/Linux box.


# In OSX, this will script will paste the cmd to the clipboard:
$ ./