Skip to content

Instantly share code, notes, and snippets.

@poundifdef
poundifdef / main.go
Created March 28, 2024 19:02
Only produce when a consumer is ready
package main
import (
"fmt"
"sync"
"time"
)
func Produce(values chan<- int, ready <-chan bool) {
for {
sources:
scratch_logs:
type: "journald"
include_units: ["scratchworker.service", "scratchdb.service"]
init_logs:
type: "journald"
include_units: ["init.scope"]
@poundifdef
poundifdef / main.go
Last active March 10, 2024 16:15
Named pipes with O_NONBLOCK still block
package main
// go version go1.22.1 darwin/arm64
// M1 2020 macbook with OS version 12.5 (21G72)
import (
"fmt"
"os"
"syscall"
"time"
filter = identifier ,[not], ".", operator, [modifier] , operand;
identifier = quoted_identifier | plain_identifier;
quoted_identifier = '"',inside_quotes, '"';
plain_identifier = "[A-Za-z0-9_]+" ;
inside_quotes = '[!"\"".]+' ;
not = '.not';
operator = "[A-Za-z]+" ;
modifier = "(", plain_identifier, ")";
operand = element;
Element = QuotedString / UnquotedString / Number / Tuple / Set;
@poundifdef
poundifdef / flatten.py
Created September 22, 2023 19:29
Flatten JSON with Arrays
import json
def parse(obj, path = None, use_indices = False):
if path is None:
path = []
if isinstance(obj, list):
if use_indices:
return [p for i, item in enumerate(obj) for p in parse(item, path + [i], use_indices)]
return [p for i in obj for p in parse(i, path, use_indices) ]
if isinstance(obj, dict):
@poundifdef
poundifdef / disk_benchmark.c
Created September 24, 2022 18:19
Brief example showing the read performance difference between random vs linear disk reads
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
const unsigned int num_records = 100000000;
````.................-------::::-`
`.-:/+ossyhhddmmmmmmmmmmmmmmdddddddddddddddddddddmmy:
`-/oydmmmmmdyso++/::-:::///////:::::::---.`````````````./hmh/
-/ydmdhyso+++//:------:---.`````` ````.:::-. `-ymh-
.+hmds/.:/:-------..````...------:::::::::::::--.```-//- :dm+
-ymds:` `-```````....------..````` `..------..`.://:.`-+/- .hms`
omd+` `----------.` ::......--://:::-/+/.`-/-` `yNy`
oNy` :/:.``````...--` -o` `.-+/:-//- .-. `yNy`
Given I have a string "hello world"
When I split it based on the " " character
Then I expect two tokens
And I expect these tokens to be present:
| token |
| hello |
| world |
@poundifdef
poundifdef / gist:1c3637543394fc7a4085
Created October 14, 2014 17:02
The Love-Song of J. Alfred Prufrock by By T.S. Eliot
Let us go then, you and I,
When the evening is spread out against the sky
Like a patient etherized upon a table;
Let us go, through certain half-deserted streets,
The muttering retreats
Of restless nights in one-night cheap hotels
And sawdust restaurants with oyster-shells:
Streets that follow like a tedious argument
Of insidious intent
To lead you to an overwhelming question. . .
@poundifdef
poundifdef / gist:ec16836913cc4c9fa1fb
Created September 2, 2014 22:17
jira confluence stack trace
Cause
java.lang.IllegalStateException: Google properties not yet initialised
at com.atlassian.agmp.integration.common.enablement.impl.GooglePropertiesHolder.getGoogleProperties(GooglePropertiesHolder.java:40)
Stack Trace:[hide]
java.lang.IllegalStateException: Google properties not yet initialised
at com.atlassian.agmp.integration.common.enablement.impl.GooglePropertiesHolder.getGoogleProperties(GooglePropertiesHolder.java:40)
at sun.reflect.GeneratedMethodAccessor3946.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)