Skip to content

Instantly share code, notes, and snippets.

View felipecrv's full-sized avatar
🌴
On vacation

Felipe Oliveira Carvalho felipecrv

🌴
On vacation
View GitHub Profile
@felipecrv
felipecrv / csv_client.py
Created September 4, 2024 23:26
Streaming a GZIP'd CSV HTTP response into a stream of Arrow RecordBatches
import urllib.request
import pyarrow.csv as csv
import gzip
CSV_FORMAT = 'text/csv'
response = urllib.request.urlopen('http://localhost:8000')
content_type = response.headers['Content-Type']
if content_type != CSV_FORMAT:
raise ValueError(f"Expected {CSV_FORMAT}, got {content_type}")
@felipecrv
felipecrv / cancellation.js
Created April 25, 2024 23:00
Concurrency Control for shared mutable state that gets mutated by asynchronous callbacks.
/* @flow */
export class CancellationToken {
source: CancellationTokenSource;
requestId: number;
constructor(source: CancellationTokenSource, requestId: number) {
this.source = source;
this.requestId = requestId;
}
@felipecrv
felipecrv / arrow.svg
Created July 14, 2023 18:30
Class and type predicate graph for Arrow C++
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@felipecrv
felipecrv / HalfSipHasher64.java
Last active June 11, 2023 16:40
Implementation of HalfSipHash-2-4-64 in Java.
/**
* Copyright (C) 2022 Felipe Oliveira Carvalho
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@felipecrv
felipecrv / Sampling.scala
Created June 30, 2022 06:53
Sampling and Shuffling
package rs.felipe.random
import java.util.Random
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
object Sampling {
/**
* Randomly sample up to k items from a sequence.
@felipecrv
felipecrv / union_find.ml
Last active June 27, 2022 13:03
Union-Find data-structure in OCaml
type 'a member =
{ mutable parent : 'a member
; mutable rank : int
; value : 'a
}
let make_set value =
let rec m = { parent = m; rank = 0; value } in
m
;;
@felipecrv
felipecrv / SBTTestEngine.php
Created September 11, 2018 21:30
sbt Test Engine for Arcanist/Phabricator #scala
<?php
final class SBTTestEngine extends ArcanistUnitTestEngine {
const SBT_ROOT = 'services';
public function getEngineConfigurationName() {
return 'sbt';
}
protected function supportsRunAllTests() {
@felipecrv
felipecrv / Sampling.scala
Last active July 19, 2018 19:14
Sampling and Shuffling sequences in Scala
package m79.random
import java.util.Random
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
object Sampling {
/**
* Randomly sample up to k items from a sequence.
@felipecrv
felipecrv / btree.js
Created April 1, 2018 13:32
In-memory B+ Tree implemented in Javascript with Flow type annotations
/* @flow */
const KEY_KIND_STRING = 1;
const KEY_KIND_NUMBER = 2;
const KEY_KIND_BOOL = 3;
const KEY_KIND_RECORD = 4;
type KeyKind = 1 | 2 | 3 | 4;
class KeyValue<K, V> {
key: ?K;
@felipecrv
felipecrv / HttpApiClient.scala
Last active April 8, 2018 13:56
A convenient HTTP API Client based on the Jetty HTTP client written in Scala
package m79.infra
import java.net.URI
import java.time.format.DateTimeFormatter
import m79.infra.HttpAPIClient.Call
import org.eclipse.jetty.client.HttpClient
import org.eclipse.jetty.client.api.{Request, Result}
import org.eclipse.jetty.client.util.{BufferingResponseListener, MultiPartContentProvider, StringContentProvider}
import org.eclipse.jetty.http.HttpMethod