Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# -*- coding: utf-8 -*-
# https://stackoverflow.com/questions/47113813/using-pyarrow-how-do-you-append-to-parquet-file
# Create a virtualenv or pipenv with pyarrow installed
import pyarrow as pa
import pyarrow.parquet as pq
def append_to_parquet_table(ii, filepath=None, writer=None):
filename = f"/home/user/files/2020-01-09T{ii:02}_00_00Z_PT1H.parquet"
print("Merging: {}".format(filename))
table = pq.read_table(filename)
@dazzag24
dazzag24 / README.TXT
Created March 23, 2020 21:14
influxdb-2.0.0-beta docker command
mkdir $HOME/influxdbv2
docker run -p 9999:9999 --name influxdb --restart=unless-stopped -v $HOME/influxdbv2:/root/.influxdbv2 quay.io/influxdb/influxdb:2.0.0-beta --reporting-disabled
@dazzag24
dazzag24 / gist:2dcf3c9a3afceb78e44248ee61aad218
Created March 31, 2020 19:44
Find out which packages are taking up the most space you can use the following command
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
wget -r -p -U "Mozilla/5.0 (iPhone; CPU iPhone OS 12_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Mobile/15E148 Safari/604.1" https://www.example.com
@dazzag24
dazzag24 / rename_with_file_date.sh
Created May 12, 2020 20:48
Rename files based on creation date of file
convert () {
local f=$1
echo "Processing ${f}"
local filedate=$( stat -c '%y' ${f} | awk -F"." '{print $1}' | awk -F" " '{printf "%s %s", $1, $2}' | sed 's/:/./g' - )
echo "${filedate}-${f}"
cp ${f} "../101MEDIA/${filedate}-${f}"
}
@dazzag24
dazzag24 / multiprocess_restart_test.py
Created May 28, 2020 14:27
Maintain a pool of multiprocessing workers if any of them die or are killed
import time
import signal
import multiprocessing as mp
def worker(id):
while True:
print("Inside worker {}".format(id))
time.sleep(10)
def proc_stop(p_to_stop):
@dazzag24
dazzag24 / proxy.rs
Created June 11, 2020 21:06 — forked from Plecra/proxy.rs
A smol proxy server
use anyhow::*;
use futures::io::{copy, AsyncReadExt, AsyncWriteExt};
use futures::stream::StreamExt;
use log::*;
use smol::Async;
use std::net;
const PORT: u16 = 5000;