Skip to content

Instantly share code, notes, and snippets.

View javier's full-sized avatar

javier ramírez javier

View GitHub Profile
@javier
javier / Exif-questdb-schema.sql
Created January 10, 2024 11:05
Exif-questdb-schema
CREATE TABLE CameraDetails (
Manufacturer SYMBOL,
Model SYMBOL,
Orientation SYMBOL,
Software STRING,
DateAndTime timestamp,
YCbCrPositioning SYMBOL,
Compression SYMBOL,
XResolution LONG,
YResolution LONG,
@javier
javier / questdb_partition_remover.sh
Last active October 23, 2023 10:37
questdb_cron_remove_partitions
#!/bin/bash
# This script needs both curl and jq installed.
# It will go over all the tables with daily partitioning and will remove all partitions older than 5000 days (change that after you are sure it works as you expect)
# It uses jq to parse the JSON output from the REST API, extracting the "dataset" element and flatten all the rows.
# Then it reads line by line and calls the QuestDB API with each ALTER TABLE statement.
# We get all the tables with daily partitioning and compose the ALTER TABLE statements
@javier
javier / odbQuest.py
Last active April 25, 2023 09:41
QuestDB ODBC ILP
# configuring ODBC https://solutions.posit.co/connections/db/best-practices/drivers/
# using ODBC from python https://github.com/mkleehammer/pyodbc/wiki/Getting-started
import pyodbc
con = pyodbc.connect(
driver = 'PostgreSQL Driver',
database = 'qdb',
server = 'localhost',
port = 8812,
uid = 'admin',
@javier
javier / CreateEnergy15minsDataset.ipynb
Last active February 8, 2023 17:51
Create notebook with energy time series data at 15 minutes interval. QuestDB demo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
$milliseconds = bcmul(microtime(true), 1000000000) ;
echo strval($milliseconds);
@javier
javier / download_dataset.py
Last active June 23, 2022 18:05
dataset_downloader_for_demo_questdb_io
import requests
import csv
def download_query(query):
with open("output.csv", "w") as outfile:
writer = csv.writer(outfile)
last_line = None
page = 0
while last_line != 0:
row_from = page * 1000000
@javier
javier / queries.sql
Last active June 14, 2022 16:46
Questdb basic demo
CREATE TABLE sensors (ID LONG, make STRING, city STRING);
INSERT INTO sensors
SELECT
x ID, --increasing integer
rnd_str('Eberle', 'Honeywell', 'Omron', 'United Automation', 'RS Pro') make,
rnd_str('New York', 'Miami', 'Boston', 'Chicago', 'San Francisco') city
FROM long_sequence(10000) x
;
@javier
javier / gist:fc90f3bbf265522d54526c2f0a44bdef
Created July 3, 2020 08:36 — forked from cmackay/gist:5863257
AppleScript to save and restore window position and sizes.
-- allSettings is a list of records containing {width:? height:? apps:{{name:? pos:? size:?},...}
-- for each display setup store the apps and their associated position and size
property allSettings : {}
-- create a variable for the current settings
set currentSettings to {}
display dialog "Restore or save window settings?" buttons {"Restore", "Save"} default button "Restore"
set dialogResult to result
@javier
javier / ffmpeg.md
Created May 13, 2020 09:36 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@javier
javier / BatchJob.java
Last active January 18, 2022 05:16
A tale of two streams workshop
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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