Skip to content

Instantly share code, notes, and snippets.

View pkit's full-sized avatar

Constantine Peresypkin pkit

View GitHub Profile
@pkit
pkit / docker-credential-gh
Created December 10, 2023 01:55
ghcr.io credential helper
#!/bin/bash
set -e
cmd="$1"
if [ "erase" = "$cmd" ]; then
cat - >/dev/null
exit 0
fi
if [ "store" = "$cmd" ]; then
cat - >/dev/null
@pkit
pkit / clickhouse_url_server.py
Created November 20, 2023 19:43
The most basic URL server for ClickHouse. Can be used with the `URL()` engine: `URL('http://localhost:8555/', JSONEachRow)`
import contextlib
import io
import json
import logging
import os
import socket
import sys
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from typing import Any, Iterator

Events table (ordered by insertion):

CREATE TABLE events (
  id UInt64,
  ts DateTime64(3),
  data TEXT
)
ENGINE=MergeTree()
ORDER BY tuple()
@pkit
pkit / big_int_128.patch
Created January 21, 2021 12:49
v8 exploits patches
diff --git a/src/numbers/conversions.cc b/src/numbers/conversions.cc
index 27f0a6ac3b..0d6eec63a4 100644
--- a/src/numbers/conversions.cc
+++ b/src/numbers/conversions.cc
@@ -392,7 +392,7 @@ void StringToIntHelper<LocalIsolate>::DetectRadixInternal(Char current,
template <typename LocalIsolate>
template <class Char>
bool StringToIntHelper<LocalIsolate>::ParseChunkInternal(Char start) {
- const int kChunkSize = 10240;
+ const int kChunkSize = 128;
@pkit
pkit / Makefile
Last active October 8, 2020 17:19
v8 BigInt parser test
CC = g++
CFLAGS = -Wall -std=c++11 -fno-rtti -O2 -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -I../include -I.. -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -fPIC -c
LDFLAGS = -Wall -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2 -fstack-protector-strong -fno-omit-frame-pointer
V8_OUT ?= ../out.gn/x64.release/obj
ZLIB_OUT = $(V8_OUT)/third_party/zlib
ZLIB_OBJS = $(ZLIB_OUT)/zlib_adler32_simd/adler32_simd.o $(ZLIB_OUT)/zlib_inflate_chunk_simd/inffast_chunk.o $(ZLIB_OUT)/zlib_inflate_chunk_simd/inflate.o $(ZLIB_OUT)/zlib_crc32_simd/crc32_simd.o $(ZLIB_OUT)/zlib_x86_simd/crc_folding.o $(ZLIB_OUT)/zlib_x86_simd/fill_window_sse.o
V8_LIBS = -lv8_base_without_compiler -lv8_compiler -lv8_base_without_compiler -lchrome_zlib -lcompression_utils_portable -ltorque_generated_definitions -lcppgc_base -lv8_cppgc_shared -lv8_snapshot -lv8_libplatform -lv8_libbase -lv8_libsampler -lchrome_zlib -lv8_libplatform
LIBS = -L/usr/lib/x86_64-linux-gnu -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed $(
const Pool = require('pg-pool');
const STATE = {
CANCELLED: 0,
ACTIVE: 1,
WAITING: 2,
}
export class ManagedPool extends Pool {
constructor (options) {
@pkit
pkit / gdrive.sh
Created January 14, 2019 09:14
Download from Google Drive in Linux command line (with curl)
#!/bin/bash
url="$1"
id=$(echo "$url" | grep -oP '(?<=https://drive.google.com/file/d/)[^/]+')
if [ -z "$id" ]; then
id=$(echo "$url" | grep -oP '(?<=https://drive.google.com/open\?id=)[^/]+')
if [ -z "$id" ]; then
echo "Cannot parse url: '$url'"
exit 1
fi
fi
@pkit
pkit / tensorflow-1.6.0-gpu-cuda-load.patch
Created March 23, 2018 12:02
Patch tensorflow 1.6.0 to dynamically load libcuda.so.1
diff --git a/tensorflow/core/common_runtime/gpu/gpu_cudamalloc_allocator.cc b/tensorflow/core/common_runtime/gpu/gpu_cudamalloc_allocator.cc
index 08961fc..5963c8a 100644
--- a/tensorflow/core/common_runtime/gpu/gpu_cudamalloc_allocator.cc
+++ b/tensorflow/core/common_runtime/gpu/gpu_cudamalloc_allocator.cc
@@ -16,6 +16,9 @@ limitations under the License.
#ifdef GOOGLE_CUDA
#include "cuda/include/cuda.h"
#include "tensorflow/stream_executor/cuda/cuda_activation.h"
+#include "tensorflow/stream_executor/platform/port.h"
+#include "tensorflow/stream_executor/dso_loader.h"
2014-11-12 05:31:24,453 FATAL [main] org.apache.hadoop.mapred.YarnChild: Error running child : java.lang.OutOfMemoryError: Java heap space
at parquet.bytes.CapacityByteArrayOutputStream.initSlabs(CapacityByteArrayOutputStream.java:65)
at parquet.bytes.CapacityByteArrayOutputStream.<init>(CapacityByteArrayOutputStream.java:57)
at parquet.column.values.rle.RunLengthBitPackingHybridEncoder.<init>(RunLengthBitPackingHybridEncoder.java:125)
at parquet.column.values.rle.RunLengthBitPackingHybridValuesWriter.<init>(RunLengthBitPackingHybridValuesWriter.java:36)
at parquet.column.ParquetProperties.getColumnDescriptorValuesWriter(ParquetProperties.java:61)
at parquet.column.impl.ColumnWriterImpl.<init>(ColumnWriterImpl.java:73)
at parquet.column.impl.ColumnWriteStoreImpl.newMemColumn(ColumnWriteStoreImpl.java:68)
at parquet.column.impl.ColumnWriteStoreImpl.getColumnWriter(ColumnWriteStoreImpl.java:56)
at parquet.io.MessageColumnIO$MessageColumnIORecordConsumer.<init>(MessageColumnIO.java:124)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDF6CbEXtCVtU8akiXveZiiT1napl6S/xCAtP+WIYHcyb8vrEeJlWNtHbm00a7MHsCYsmUDC2erBSnvMnbXw1ANdHQG1vbyLFcaUI1twudTEKoJqcamsEpIgeJxAbAOlPNXO5Fld9LU6UuD3wTeZJrrs2eEp5Dkasi0ky1g4Pa0YTA1/AotIo3euLsqMrKtsbJ62QXi3w+FeuUNqbznYslPAdm62Oj/rfdMx9pFFt5kdn2lbZ/k0zQPtUH4mG3LgcE3ZqN+hUO5BmpbnZ6O3kCYbEcAvaWm9mbGlAIFc4tHawUrQIg3NBB/rkAExX7WDhOFdrQTdb6XQfmBs2nqhX7H kit@dev