Skip to content

Instantly share code, notes, and snippets.

View kirlf's full-sized avatar
💻
Working

Vladimir Fadeev kirlf

💻
Working
View GitHub Profile
# Input format: JSONEachRow
# Note: ClickHouse should works on localhost, or port forwarding should be used in this example:
cat <FILE NAME>.json | curl 'http://localhost:8123/?input_format_skip_unknown_fields=1&query=INSERT%20INTO%20<DATABASE NAME>.<TABLE NAME>%20FORMAT%20JSONEachRow' --data-binary @-
import math
from collections import deque
class Node:
"""
A node of the binary search tree
Attributes
__________
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="app.diagrams.net" modified="2022-01-11T20:22:49.942Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36" etag="24cRRxXGFhsO2GzN6IQK" version="16.2.4" type="device"><diagram id="Svfi9QZZ8QGGwfDbvttr" name="Page-1">7V1bc9o4FP41zLQPZHyTbB6TtN12pu10N7Oz7b7sOFiAU2Oxtihhf/3KWAYsyWDwFVAyk9i6+HI+nauO5IH5OH/9LXIXsy/YQ8HA0LzXgfluYBgjC9K/ScE6LbAcIy2YRr6XFum7gif/P8QKNVa69D0U5xoSjAPiL/KFYxyGaExyZW4U4VW+2QQH+bsu3CkSCp7GbiCW/uV7ZJaWOoa9K/+I/Oksu7MOR2nN3M0aszeJZ66HV3tF5vuB+RhhTNKj+esjChLaZXRJ+30oqN0+WIRCUqbD6o8ngCaf7k1v8sd78PLy0f+0Ho7YZX65wZK9MXtass5IEOFl6KHkKvrAfFjNfIKeFu44qV1RzGnZjMwDVh24zyh4cMc/p5tujzjAEa0KcUjbP0xwSBjGukPPYxLhn4hrxJ4IRQS9Fr6rvqUgHXkIzxGJ1rQJ62CCtAcbdNBkGKx2ENpZ2WwPvm1Dlw2b6fbSO8rSA0bcUwitXSWhDStHaEuXENqRENrQmiK0M7pKQnMjWrdKjmjDaorQui3QFXlUdrJTHJEZnuLQDd7vSh92lNfo2a7NZ4wXjN4viJA1I6m7JDiPBnr1yfe94x/Jpe4AO3v3yq68OVlnJyF93+/7J3u9ktNdt81Z1i99v+SlDoNGaYCX0Zi1iifffvz+8gN9/0igFbiz+d+veJipLjea
LOAD DATABASE
FROM mysql://user:password@mysql57:3306/mysql_db
INTO postgresql://user:password@pgsql:5432/pg_db
CAST type int with extra auto_increment when (< precision 10) to serial drop typemod drop not null,
type int with extra auto_increment when (<= 10 precision) to bigserial drop typemod drop not null,
type int when (< precision 10) to int drop typemod,
type int when (<= 10 precision) to bigint drop typemod,
type tinyint with extra auto_increment to serial drop not null,
type smallint with extra auto_increment to serial drop not null,
from datetime import datetime
import pandas as pd
from clickhouse_driver import Client
client = Client('localhost')
db_name = "db_name"
tables_list = ["table_1", "table_2"]
db_table_list = ["{db}.{tb}".format(db=db_name, tb=tb) for tb in tables_list]
# coding=utf-8
import numpy as np
import matplotlib.pyplot as plt
import numpy.linalg as LA
import scipy.optimize as optim
class UnivFitFunc:
def __init__(self, err=5, Nmax=1000):
"""
Developed by Vladimir Fadeev
(https://github.com/kirlf)
Kazan, 2017 / 2020
Python 3.7
The result is uploaded in
https://commons.wikimedia.org/wiki/File:AdaptiveBeamForming.png
"""
%MatLab/Octave
clear all; close all; clc
%% Initialization
% channel parameters
sigmaS = 1; %signal power
sigmaN = 0.01; %noise power
% CSI (channel state information):
channel = [0.722-1j*0.779; -0.257-1j*0.722; -0.789-1j*1.862];
@kirlf
kirlf / huffman.py
Last active April 24, 2024 14:59 — forked from jasonrdsouza/huffman.py
Simple Huffman coding implementation
# Python 3.8
import math
from queue import Queue
from collections import Counter
class HuffmanCodes:
def __init__(self):
pass
def __huffman_tree_to_table(self, root, prefix, lookup_table):