Skip to content

Instantly share code, notes, and snippets.

@pquentin
pquentin / employees.kql
Created March 11, 2024 09:50
Dev Console queries to create the ES|QL employees test dataset
PUT employees
{
"mappings": {
"properties": {
"avg_worked_seconds": {
"type": "long"
},
"birth_date": {
"type": "date"
},
@pquentin
pquentin / secretly_sync.py
Created September 8, 2023 06:26
Experimenting with run_secretly_sync_async_fn
import trio
class SyncBackend:
def return_2(self):
return 2
class AsyncBackend:
async def return_2(self):
@pquentin
pquentin / client.py
Created July 24, 2020 16:55
WebSocket server with message handler and worker
import time
import trio
from trio_websocket import open_websocket_url
async def send_one_message(i):
try:
async with open_websocket_url("ws://127.0.0.1:8000/foo") as ws:
await ws.send_message(f"hello, {i}!")
@pquentin
pquentin / fanout.py
Created May 25, 2018 04:16
Fanning out a generator with trio
import trio
async def producer():
for e in [1, 2, 3]:
yield e
async def consumer(iterator):
total = 0
#!/usr/bin/env python3
import asyncio
import time
import aiohttp
START = time.monotonic()
import difflib
import glob
import os
import sys
from tokenize import tokenize as std_tokenize
from tokenize import ASYNC, AWAIT, NAME
import click
@pquentin
pquentin / keybase.md
Created November 13, 2016 07:49
Keybase proof

Keybase proof

I hereby claim:

  • I am pquentin on github.
  • I am quentinp (https://keybase.io/quentinp) on keybase.
  • I have a public key ASBWiaCHqgBFxL_zX0rogjwaZjym4igjjUQsFMCKBWDajgo

To claim this, I am signing this object:

@pquentin
pquentin / gist:1474f29440ac560f6c33
Created September 15, 2014 07:32
Crawl a Dokuwiki user page and suppages
#!/bin/bash
rm -rf hostname
wget \
-e robots=off \
--recursive --level=inf \
--no-verbose \
--page-requisites \
--convert-links \
@pquentin
pquentin / unusedstrings.js
Created August 28, 2014 13:39
First draft of unusedstrings.py in JS
"use strict";
let fs = require('fs'),
_ = require('underscore');
function match_stuff(regexp, data, cb) {
let match;
while ((match = regexp.exec(data)) !== null) {
cb(match[1]);
}
@pquentin
pquentin / unusedstrings.py
Created August 25, 2014 14:42
Compare codefirefox localization file with __ calls in the code
#!/usr/bin/env python3
from glob import glob
import re
import json
def get_code_strings():
for filename in glob("views/*.jade"):
content = open(filename).read()